Learning resourcesReviewed · OpenRouter

Build a Token-Efficient Review Agent

Build a Token-Efficient Review Agent is an OpenRouter tutorial for developers adding selective AI second opinions to review workflows, but its beta Advisor tool can add cost and latency. JavaScript examples show a lower-cost executor model handling routine work and optionally consulting another model through a compact review packet. The spending gate uses uncertainty signals rather than a monetary limit, and the page provides no measured savings.

Researched 23 Nov 2026

In short.

Build a Token-Efficient Review Agent is an OpenRouter tutorial for developers adding selective AI second opinions to review workflows, with a beta dependency and no demonstrated cost or quality gains. It supplies JavaScript request construction, compact prompt guidance, multiple-reviewer configuration and telemetry recommendations. Its main design is selective escalation: offer a stronger model only when predefined uncertainty signals appear. The sample does not enforce a spending ceiling or the requested one-call limit, and integration, billing and runtime behavior remain unassessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage is the complete selected documentation page at [https://openrouter.ai/docs/cookbook/building-agents/advisor-server-tool.md], including all embedded examples, the beta notice, validation guidance and next-step links. The documentation index and linked Advisor, SDK, API, caching and human-in-the-loop pages are excluded. No code or API calls were executed; compatibility, response quality, savings, latency and billing behavior remain unassessed.

The overview

Identity

This OpenRouter cookbook page teaches developers to build a small implementation-plan reviewer using an executor model and the Advisor server tool. It is a tutorial with embedded examples, rather than a packaged application or installable agent. The source is [https://openrouter.ai/docs/cookbook/building-agents/advisor-server-tool.md].

Assessment

The guide offers a concrete starting point for an existing OpenRouter application that needs occasional second opinions on engineering plans. It explains the request shape, information boundary and routing decisions in enough detail to adapt them.

Its value is the integration pattern. The page does not demonstrate that this pattern improves review accuracy or reduces total spending. The examples construct requests and configuration; sending requests, processing responses and connecting telemetry remain application work.

Users

The intended users are developers maintaining review, planning or agent workflows that already call OpenRouter. The examples focus on engineering decisions involving migrations, billing paths, missing tests and uncertain ownership.

Beginners can follow the basic idea: use an inexpensive model for ordinary work and ask another model about a narrowly defined uncertainty. Implementing it requires familiarity with JavaScript, API requests and the application's existing model-call path. Experienced developers will find details about server-tool parameters, conversation replay and API-specific streaming behavior.

Capabilities

The sample enables a named plan-reviewer tool when a task includes billing-path, large-diff, missing-rollback, missing-tests, schema-change or unknown-owner signals. It also demonstrates separate schema-reviewer and cost-reviewer tools with different instructions and configurable models.

The telemetry guidance covers model identifiers, Advisor enablement, finish reason and returned usage fields while excluding prompts and advice from logs. did_enable_advisor records whether the tool was offered; it does not establish that the executor used it.

The page states that an Advisor entry can stream advice through the Responses API. Chat Completions ignores that stream setting, and Messages streaming is described as planned.

Using it

Requirements

The stated prerequisites are Node.js 20 or newer, an OpenRouter API key in OPENROUTER_API_KEY, an existing OpenRouter review or agent workflow, a lower-cost executor model and a stronger Advisor model.

The example uses openai/gpt-4o-mini as executor and ~anthropic/claude-opus-latest as Advisor. Their current availability, prices and suitability are not established by this page. No package installation command or complete project scaffold is supplied. For a new TypeScript agent, the page recommends the Agent SDK callModel API.

Mechanism

The application first checks whether any task signal matches its predefined set. When none matches, the request omits tools. When a signal matches, it supplies an openrouter:advisor entry with tool_choice set to auto, allowing the executor to decide whether consultation is useful.

The Advisor model is configured in flat parameters. With forward_transcript set to false, the Advisor receives its own instructions and the executor's compact prompt argument instead of the full parent conversation. The packet summarizes the decision, affected files, uncertainty signals and proposed change.

Multiple Advisors are separate tools entries, rather than a nested parameters.advisors roster. The page warns that Advisor identity depends on array position during conversation replay, so changing entry order can mix up reconstructed reviewer memory.

Setup

Configure the API key and model identifiers, define a compact task object, and adapt the supplied eligibility function and Advisor configuration. Send the resulting requestBody through the application's existing OpenRouter request path.

Connect telemetryContext to the returned finish reason and usage fields. Constructing that object alone does not emit logs. The page recommends excluding keys, cookies, raw diffs, full prompts and full generated advice from telemetry.

Applications using the Agent SDK need to adapt the same gate and tool configuration to their executor loop. Exact SDK and API schemas are linked references whose contents are outside the supplied page.

Example

The worked example asks whether to ship a migration plan that moves usage-event writes to a monthly partitioned table. Its packet names a migration file and a write-service file, summarizes routing by workspace_id and created_at, and supplies schema-change, missing-rollback and billing-path signals.

Under the shown eligibility rule, those signals enable plan-reviewer. The executor can then request a focused second opinion about assumptions, rollback steps, tests or cheaper alternatives. The page provides no resulting review, executed migration or observed API response.

Assessment & evidence

Limitations

Advisor is explicitly described as beta. Compatibility, reliability and behavior across the linked API surfaces were not assessed.

The executor is instructed to call Advisor at most once, but the shown code does not enforce that limit. Likewise, its spending gate is a heuristic rather than a hard budget control. These distinctions matter when predictable usage is required.

A compact packet can omit information needed for a sound review, and the predefined signals can miss uncertainty outside their list. These are design risks inferred from the information filtering and routing logic; the page supplies no evaluation measuring them.

Reasoning

The design aims to limit expensive-model work in three ways: keep routine reasoning with the executor, restrict when consultation is available, and send only a concise question to the Advisor. This gives developers concrete controls over consultation frequency and context size.

The tradeoff is dependence on the executor's judgment and summary quality. A second model can review only what it receives, and a shorter prompt does not by itself demonstrate lower total cost or a better decision. Whether the tradeoff works for a particular workload remains unknown.

Alternatives

The simplest option within the recipe is to leave routine tasks with the executor alone. A single plan reviewer suits one focused uncertainty; separate schema and cost reviewers are suggested when different review questions need different instructions.

The page also describes full-transcript forwarding as an option when broader context matters, with a potential token-cost tradeoff. It points to response caching for repeated stable executor prefixes and human-in-the-loop controls when consultation should involve a person. Those linked implementations and their effectiveness are not assessed here.

Evidence

The evidence is the complete captured OpenRouter page at [https://openrouter.ai/docs/cookbook/building-agents/advisor-server-tool.md], including its examples, beta warning, telemetry guidance and validation checklist. Its captured source SHA-256 is 63bdf358f9c9cb61bc88d9eb729dde5957df70ff6a928db89d65ca14c7aaa46a.

The telemetry JSON illustrates expected field names, rather than an observed execution result. No code or API calls were executed. Review accuracy, actual token savings, runtime latency and billed cost are not assessed.

Access & freshness

Costs

Actual cost is unknown. The page supplies no prices, measured token totals, latency figures or savings benchmark. Advisor performs an additional model call and can increase spending and response time.

The main example sets a 500-token executor output limit and a 220-token Advisor completion limit; the specialist examples use 180-token Advisor limits. These limits constrain output, not total monetary spending. The gate checks task signals rather than account balance, prices or accumulated spend.

The page recommends using returned usage.cost when available, or estimating Advisor spend from current model pricing. Usage fields are provider-dependent, so the presence and billing interpretation of required fields need verification in the intended integration.

Rights

The captured page contains no explicit license for its prose or sample code. Permission for commercial reuse or redistribution is unknown from this evidence.

The page also does not establish provider retention terms or ownership terms for submitted content and generated advice. Disabling transcript forwarding and excluding content from application logs do not establish those terms.

Freshness

The page was captured on 23 November 2026 at 10:54:53.782 UTC. Its publication date, last substantive update and release version are not provided.

Beta status and streaming statements describe that capture. The examples do not establish a fixed underlying version for ~anthropic/claude-opus-latest. Subsequent changes to model availability, prices or server-tool behavior are unknown.

Actions

Start with a bounded review task and signals that match its actual uncertainties. Keep model choices configurable, use forward_transcript set to false for compact consultation, and maintain stable Advisor ordering when replaying conversations.

Before relying on the integration, verify that routine requests omit Advisor, eligible requests expose the intended tool, and logs exclude private content. Distinguish tool enablement from actual invocation, and verify the usage fields needed for billing.

Add enforced call or spending limits if the application requires them. Measure review usefulness, end-to-end latency and total billed cost on representative tasks before assuming this pattern saves money.

Evidence for this report

selected-page.txtselected · checked 2026-11-23