adk_toolset (erlang_adk v0.7.0)

View Source

Generic immutable/dynamic toolset descriptor.

Toolsets let one provider-backed object advertise multiple model-visible schemas while resolving execution out of band. The descriptor contains no model arguments and is never sent to an LLM. OpenAPI and MCP implement the same two callbacks without being special-cased by adk_agent or Runner. A descriptor owns an immutable, compiled schema snapshot; refresh/1 deliberately replaces that snapshot for a mutable backend. Plain module tools are immutable for the lifetime of their loaded BEAM code version.

Summary

Functions

Produce a JSON-safe correction response for a rejected model call. Only schema structure is included; model-provided values are deliberately excluded so validation failures cannot reflect secrets into history.

Materialize a preflighted target after the caller's policy gate.

Locate a catalog entry and validate arguments without calling a live dynamic resolver. Runner uses this boundary to enforce runtime policy before resolved_call/4 can consult credentials, transports, or mutable backends.

Re-read and compile the advertised schemas of a descriptor.

Resolve a model call to either a module or a bounded executor call.

Validate model-generated arguments against one already checked tool schema. Validation errors contain only structural paths and constraints; rejected argument values are never copied into the reason.

Types

descriptor/0

-type descriptor() :: {adk_toolset, module(), term()}.

Functions

expand_tools(Tools)

-spec expand_tools([module() | descriptor()]) -> {ok, [map()]} | {error, term()}.

invalid_arguments_response(Reason)

-spec invalid_arguments_response(term()) -> map().

Produce a JSON-safe correction response for a rejected model call. Only schema structure is included; model-provided values are deliberately excluded so validation failures cannot reflect secrets into history.

is_descriptor(_)

-spec is_descriptor(term()) -> boolean().

materialize(Target, Name, Args, Context)

-spec materialize(term(), binary(), map(), map()) ->
                     {ok, {module, module()} | {resolved, adk_tool_executor:resolved_call()}} |
                     {error, term()}.

Materialize a preflighted target after the caller's policy gate.

new(Module, Handle)

-spec new(module(), term()) -> {ok, descriptor()} | {error, term()}.

preflight(Tools, Name, Args)

-spec preflight([module() | descriptor()], binary(), map()) ->
                   {ok, term()} | {error, not_found | term()}.

Locate a catalog entry and validate arguments without calling a live dynamic resolver. Runner uses this boundary to enforce runtime policy before resolved_call/4 can consult credentials, transports, or mutable backends.

refresh(Descriptor)

-spec refresh(descriptor()) -> {ok, descriptor()} | {error, term()}.

Re-read and compile the advertised schemas of a descriptor.

Descriptors created by new/2 are immutable catalog snapshots. Dynamic backends remain live when a call is resolved, while a deliberate refresh creates a new snapshot if the set of advertised tools has changed.

resolve(Tools, Name, Args, Context)

-spec resolve([module() | descriptor()], binary(), map(), map()) ->
                 {ok, {module, module()} | {resolved, adk_tool_executor:resolved_call()}} |
                 {error, not_found | term()}.

Resolve a model call to either a module or a bounded executor call.

schemas(Descriptor)

-spec schemas(descriptor()) -> {ok, [map()]} | {error, term()}.

validate_arguments(Schema, Args)

-spec validate_arguments(map(), map()) -> {ok, map()} | {error, {invalid_tool_arguments, term()}}.

Validate model-generated arguments against one already checked tool schema. Validation errors contain only structural paths and constraints; rejected argument values are never copied into the reason.