ExAgent.Tool.Advisor (ExAgent v3.0.0)

View Source

A tool that lets the agent consult a stronger (or different) model mid-task.

Stability — Candidate.

A fast, cheap model can run the loop and ask for advice only when it is stuck, planning or about to take a risky step. The advisor receives a bounded text transcript of the conversation so far (the latest user message and the most recent entries) plus the agent's question, and answers in text. It has no tools and never acts.

advisor = ExAgent.Tool.Advisor.new(model: strong_model, max_uses: 3)

ExAgent.new(model: fast_model, tools: [advisor | tools])

If the advisor fails, the agent receives a note saying so as a :tool_error result and continues on its own; the run's own limits still stop it at the next check.

The transcript is plain text, so the advisor may use any provider: it never receives the executor's provider replay data such as signed reasoning. Inside a run the advisor runs through ExAgent.run_child/4, so its usage counts toward the run's usage, limits and deadline. With a persisted continuation, it returns an unavailable note if the run or an ancestor has a model request, token, cost or model concurrency limit, even when capacity remains. To consult another model under those limits, use a continuation-aware delegation. Otherwise, the consultation runs separately under the scope's deadline and adds its reported usage to the tool result.

Options for new/1:

  • :model (required) — the advisor model.
  • :name — tool name (default "consult_advisor").
  • :description — tool description for the agent; the default says when to use it.
  • :instructions — the advisor's system prompt.
  • :max_uses — maximum consultations per user message (default 3). Failed consultations count. Calls in one model response reserve places in order. If an earlier call has invalid arguments, a later call can receive a limit notice even though a place went unused. That notice counts toward the limit on subsequent steps of the same turn.
  • :max_transcript_bytes — transcript size (default 32_000).
  • :model_settings — settings for the advisor model.
  • :timeout — how long one consultation may take, in milliseconds (default 120_000). It bounds the advisor's run as a deadline (never extending the run's own), so a slow provider request ends in the "unavailable" note; the tool's timeout is set 5 seconds longer, replacing :tool_timeout.

Summary

Functions

Build the advisor tool. Raises ArgumentError for invalid options.

Functions

new(opts)

@spec new(keyword()) :: ExAgent.Tool.t()

Build the advisor tool. Raises ArgumentError for invalid options.