ExAgent. Tool. CodeMode
(ExAgent v3.0.0)
View Source
Capability that lets the model chain tool calls in one turn.
Stability — Candidate.
Give new/1 the names of tools already in the agent's inventory. Each step
must name a configured ordinary JSON function tool offered on the current
request. The runtime checks tool eligibility and binding syntax for the
whole program before any step dispatches. Steps that declare
requires_deferral: true require a durable run. A tool that requests a
durable wait after dispatch leaves the effect unconfirmed and fails the run.
Each step uses its tool's declared :effect and its ordinary validation,
hooks, permissions, guardrails and usage reservations. A live :ask
requires the synchronous :approve callback for that step. The wrapper and
each admitted step use one call from the run's tool budget.
The model supplies a JSON object with a calls array. A call has a tool
name, an args object and optional bindings. A binding supplies an unset
field in args. Nest objects in bindings to fill fields under arguments
such as "input". A binding cannot replace a supplied value. Its array
starts with a zero-based earlier call index
followed by object keys or zero-based array indices. An index on its own
takes the entire result. This program binds the second call's id to the
first result under "input".
%{"calls" => [
%{"tool" => "lookup", "args" => %{"query" => "spring"}},
%{"tool" => "describe", "args" => %{}, "bindings" => %{"input" => %{"id" => [0, "id"]}}}
]}The program returns the last accepted result. A failed step stops the
remaining calls. Notices identify the step and tool when the runtime
observes the stop. A failed batch reports confirmed nested outcomes in
ExAgent.RunError.confirmed_program_steps. This host evidence includes
references and effect types. The program's call and return are the only
entries added to the model history.
Nested tool events include :program_call_ref, the one-based
:program_step and :effect. Arguments and returns use the run's ordinary
byte limits. The effective tool return limit also bounds the combined
results retained for future bindings. A result is released after its last use.
Use the finite sequence for dependent calls in live sync or streaming runs.
Persisted continuations reject the definition with
{:unsupported, {:code_mode, :continuation}}. Use ordinary tool calls
across model requests in a persisted agent to journal each step.
Summary
Functions
Build the capability. :tools is a required list of distinct tool names.
:name defaults to "run_tool_program", :max_calls to 8 (range 1–32),
:timeout to 5,000 milliseconds for each of admission and execution, and
:max_heap_bytes to 8 MiB for the program task. Nested calls use their own
task controls within the program's execution deadline and the run deadline.
Invalid or duplicate options raise ArgumentError.
Return the program entry point contributed to the agent inventory.
Types
@type t() :: %ExAgent.Tool.CodeMode{ max_calls: pos_integer(), max_heap_bytes: pos_integer(), name: String.t(), timeout: pos_integer(), tools: [String.t()] }
Functions
Build the capability. :tools is a required list of distinct tool names.
:name defaults to "run_tool_program", :max_calls to 8 (range 1–32),
:timeout to 5,000 milliseconds for each of admission and execution, and
:max_heap_bytes to 8 MiB for the program task. Nested calls use their own
task controls within the program's execution deadline and the run deadline.
Invalid or duplicate options raise ArgumentError.
@spec tools(t()) :: [ExAgent.Tool.t()]
Return the program entry point contributed to the agent inventory.