adk_provider_result (erlang_adk v0.7.0)

View Source

Checked envelope for provider-specific result metadata.

Providers must keep the legacy result terms when they have no metadata. When metadata is present, {provider_result, Envelope} is the reserved LLM result tag. The envelope is internal Erlang data; provider_metadata/1 returns the bounded JSON-safe projection suitable for adk_event.actions.

Summary

Functions

Decode and revalidate an untrusted provider-result tuple. This check is intentionally repeated at the agent boundary because callbacks and custom providers can manufacture result terms without using new/4.

Types

envelope/0

-type envelope() ::
          #{version := pos_integer(),
            provider := binary(),
            type := binary(),
            outcome := outcome(),
            metadata := map()}.

outcome/0

-type outcome() :: {ok, term()} | {tool_calls, list()} | streamed.

result/0

-type result() :: {provider_result, envelope()}.

Functions

decode(_)

-spec decode(term()) -> {ok, outcome(), map()} | {error, term()} | not_provider_result.

Decode and revalidate an untrusted provider-result tuple. This check is intentionally repeated at the agent boundary because callbacks and custom providers can manufacture result terms without using new/4.

max_metadata_bytes()

-spec max_metadata_bytes() -> pos_integer().

new(Provider, Type, Outcome, Metadata)

-spec new(binary(), binary(), outcome(), map()) -> {ok, result()} | {error, term()}.

provider_metadata(Result)

-spec provider_metadata(result()) -> {ok, map()} | {error, term()}.