Skip to content

Wire a Stage-2-reachable route_clarify tool, so ambiguity resolution isn't prose-only #2149

Closed

Description

@mstomar125

Context

packages/agent/goldens/dev-ambiguous-clarify.toml (core#2122's golden corpus) measures that calling a route_clarify tool to ask the user which of several candidates they meant is more reliable than answering in prose: "asking in PROSE instead of calling route_clarify... Prose looks reasonable in a transcript and is invisible to anything downstream that expects a tool call."

The gap

route_clarify currently exists only as a Stage-1 routing tool (routing::stage1_tool_definitions(), alongside route_query/route_multi) — it is not registered in the Stage-2 tool registry (local_agent::tools) at all, so no Stage-2 skill can whitelist it and no Stage-2 turn can call it. Today's clarification path is entirely prose-based: skill_rules::AMBIGUITY_CLARIFY's imperative text (interpolated into graph_editing_guidance() and elsewhere) instructs the model to "ask one specific clarifying question rather than retrying," with no structured tool call backing it.

core#2120 (which authored the dev-domain retargeting this corpus case belongs to) deliberately did not build Stage-2 route_clarify support — it's a real feature addition (tool registration, skill whitelisting, and agent_loop.rs turn-termination handling for a mid-Stage-2 clarification, distinct from how Stage-1's clarify already terminates a turn), not plumbing that makes existing assembly match a golden.

What's needed

  1. Register a Stage-2-callable route_clarify tool (or reuse the Stage-1 one's shape/handler if that's structurally sound) in local_agent::tools.
  2. Whitelist it on the skills where ambiguity resolution is a real Stage-2 outcome (at minimum wherever AMBIGUITY_CLARIFY is currently interpolated — Graph Editing, per skill_pipeline.rs).
  3. Handle a Stage-2 route_clarify call in agent_loop.rs the same way Stage-1's is handled: surface the question + options to the user and end the turn, without executing further tool calls.
  4. Retarget graph_editing_guidance() (and any other skill carrying AMBIGUITY_CLARIFY) to instruct calling the tool rather than answering in prose, once it exists.

Not in scope for this issue

Deciding the exact prompt wording for the new instruction — that's measurement work belonging with core#2122-style tuning once the mechanism exists to measure against.

Activity

  1. mstomar125 commented on Aug 19, 2026

    @mstomar125
    ContributorAuthor

    Resolved in #2161.

    Registered `Tool::RouteClarify` in the Stage-2 tool registry (`packages/agent/src/local_agent/tools.rs`), whitelisted it on Graph Editing (the only skill carrying `AMBIGUITY_CLARIFY`), retargeted that rule's imperative text plus the parallel "multiple_matches" clause in `graph_editing_guidance()` from prose to calling the tool, and added an interception in `agent_loop.rs` (before the generic tool executor, same pattern as the duplicate-write/second-create_schema guards) that surfaces the question and ends the turn — no further tool calls, matching Stage 1's clarify handling.

    Shape decision: reused Stage 1's tool name but not its argument shape. Stage 1's `options` is flat strings (no natural id — a query phrase is the whole candidate); Stage 2 clarification is almost always about disambiguating specific already-resolved records, so `options` carries `{id, label}` pairs instead — the exact shape `dev-ambiguous-clarify.toml` already measured. Implementation was made to match that golden case rather than the reverse.

    Full detail, root-cause reasoning, and test coverage in PR #2161.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions