Advisor Tool

AdvisorTool lets an agent consult a stronger or different model for advice in the middle of a task. The agent runs on a fast model and calls the tool with a question when it reaches a hard decision; the advisor reads the question, the agent's context and the recent conversation, and returns advice as the tool's result. The agent acts on it.

It is the provider-neutral counterpart of Google ADK's ModelConsultTool and of Claude's advisor tool, and any Llm can be the advisor.

Installation

AdvisorTool is in adk-tool and needs no feature of its own:

[dependencies]
adk-agent = "3.0.0"
adk-model = { version = "3.0.0", features = ["anthropic"] }
adk-tool = "3.0.0"

Usage

use std::sync::Arc;

use adk_agent::LlmAgentBuilder;
use adk_model::anthropic::{AnthropicClient, AnthropicConfig};
use adk_tool::AdvisorTool;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let key = std::env::var("ANTHROPIC_API_KEY")?;
    let worker = AnthropicClient::new(AnthropicConfig::new(key.clone(), "claude-haiku-5-5"))?;
    let advisor = AnthropicClient::new(AnthropicConfig::new(key, "claude-sonnet-5-5"))?;

    let consult = AdvisorTool::builder(Arc::new(advisor))
        .max_consultations_per_run(2)
        .max_output_tokens(2_048)
        .build();

    let _agent = LlmAgentBuilder::new("support")
        .instruction("Resolve the customer's issue with your tools.")
        .model(Arc::new(worker))
        .tool(Arc::new(consult))
        .build()?;
    Ok(())
}

The agent's model sees a tool named consult_advisor with two arguments:

ArgumentRequiredMeaning
questionyesWhat the agent needs advice on: the decision, the problem, or the plan to check
contextnoFacts the advisor needs that the conversation may not show

The tool's description tells the agent to consult before a hard or irreversible decision, when it is stuck, and before it reports a complex task as done. Replace it with AdvisorToolBuilder::description to change when the agent consults.

What the advisor sees

The advisor's request has two contents and no tools, so the advisor can only answer:

  1. Its system instruction (AdvisorToolBuilder::instruction replaces the default, which asks for a recommended decision, ordered next steps and the risks to check).
  2. The handover: the consulting agent's name, the question, the context, and the agent's conversation rendered as a transcript — text, tool calls and tool results, each call or result cut at 2,000 characters, thinking left out — of at most 24,000 characters, the most recent kept.

history_chars(0) sends only the question and context.

Result

The tool returns a JSON object:

statusFieldsWhenCounted
okadvice, advisorModel, consultations, usageThe advisor answered; advice cut off at max_output_tokens ends with a note saying soYes
limit_reachedmessage, consultationsThe run has used its consultations; the advisor is not called—
errorerror, message, advisorModel, consultationsThe advisor failed (error is the provider's code), refused (tool.advisor.refused), or returned no text (tool.advisor.empty)Only when the advisor responded
invalid_requestmessagequestion is missing or emptyNo
{
  "status": "ok",
  "advice": "Do not release ORD-42 yet: the fraud hold needs a manual review first...",
  "advisorModel": "claude-sonnet-5-5",
  "consultations": { "used": 1, "max": 2, "remaining": 1 },
  "usage": { "inputTokens": 812, "outputTokens": 164, "thinkingTokens": null, "totalTokens": 976, "costUsd": 0.003264 }
}

The call and its result are a function call and a function response in the run's event stream, like any tool.

Governance

ControlBehaviour
Governed tool pathThe call is authorized like any tool call: policy, approvals and the signed audit record apply before it runs. The tool is read-only
Run budgetThe advisor's call is one model call, and its tokens and cost count, against the run's RunBudget
Spend ledgerThe call reserves and commits under the advisor's provider, attributed to advisor:{agent}; org and vendor caps cover it. spend_agent sets another attribution
Per-run capmax_consultations_per_run (3 by default) per root invocation; 0 turns consultation off
Kill switchA frozen run fails the call with governance.frozen before the advisor is called, and a freeze during the consultation ends it
Refusals by the runA budget or spend-ledger refusal fails the call with its own error; the consultation is not counted

A cap keyed to the consulting agent's own id (urn:adk:agent:{app}/{agent}) does not cover the advisor's spend; key a cap to advisor:{agent}, or to the org or vendor, to bound it.

Consultation counts live in the tool, so a run resumed in another process starts its count again; the run budget still bounds it.

Configuration

Builder methodDefaultEffect
nameconsult_advisorThe tool's name
descriptionWhen to consultWhat the agent's model reads
instructionConcise, actionable guidanceThe advisor's system instruction
max_consultations_per_run3Consultations per run
max_output_tokensThe advisor client'sCaps each answer
effortThe advisor client'sThe advisor's reasoning effort
history_chars24,000Conversation shown to the advisor
spend_agentadvisor:{agent}Spend-ledger attribution

Choosing a pairing

The advisor pays off when it is clearly stronger than the agent and the agent actually consults. Pair a fast agent model with a frontier advisor — claude-haiku-5-5 consulting claude-sonnet-5-5, or a Gemini Flash model consulting a Pro one — and compare against the stronger model alone at a lower effort before you adopt it.