ExAgent.Tool.Advisor (ExAgent v2.3.0)

View Source

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

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 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 runs as a separate run and its usage is added to the tool result instead.

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 — consultations per user message, failed ones included (default 3).
  • :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.