Skip to content

A Stage-2 prose clarification escapes the at-most-one contract, and erases the prior clarification from the intent window #2905

Closed

Description

@malibio

Overview

ADR-038's clarification contract — at most one clarification per intent — is enforced only for clarifications the agent module composed itself. A Stage-2 clarification asked in free prose is invisible to the guard, and worse, it erases a legitimate prior clarification from the window the guard examines.

Reachable today, and observed: clarification-then-fallthrough fails 0/3 reps in the routing eval, deterministically, with the model asking a second clarifying question in prose and making no tool call.

The mechanism

session_already_clarified works through answered_clarifications (packages/agent/src/local_agent/agent_loop.rs:1225), which identifies the current intent by scanning backward for the last assistant message that does not begin with CLARIFICATION_OPENER:

const CLARIFICATION_OPENER: &str = "I can take that a couple of ways";

let intent_start = session.messages.iter()
    .rposition(|m| matches!(m.role, Role::Assistant)
                   && !m.content.starts_with(CLARIFICATION_OPENER))
    .map_or(0, |idx| idx + 1);

That design is deliberate and its doc comment explains why: clarifications are composed by the module, so "their own text is the record", and matching a string the module wrote itself is exact rather than heuristic.

It holds only while every clarification goes through the composer. Stage 2 can ask a clarifying question as ordinary prose, which carries no opener.

Two failures, not one

1. The new clarification is not counted. A prose clarification never matches the opener, so session_already_clarified returns false on the next turn and Stage 1's clarify_suppressed fallback never fires. The loop ADR-038 specifies against is open.

2. A prior clarification is erased. This is the more serious half and was not in the eval write-up. Because intent_start treats any non-opener assistant message as the end of the previous intent, a prose clarification is read as a resolution — it closes the intent. So a legitimate earlier route_clarify drops out of the window entirely.

The consequence is that alternating clarifications can run indefinitely: each prose clarification resets the intent, discarding the record of the composed one before it.

Why this is not (only) a guidance fix

Worth stating explicitly, because the guidance-shaped fix is cheaper and will otherwise be taken on its own.

Prose asking for restraint is the weakest available channel. ADR-064 measured a constraint in the tool schema at 100% compliance, the same rule in resident prose at 87.5%, and absent at 62.5%. "At most one clarification per intent" is a contract, and ADR-038 treats it as one.

The rule would ask the model to know something the system cannot tell it. Guidance saying "do not ask a second clarifying question" requires the model to remember it already asked. That is precisely what session_already_clarified exists to answer — if the model tracked it reliably, the guard would be unnecessary.

Failure 2 is definitionally not a guidance problem. No instruction changes what intent_start computes. A prose clarification erases the prior one regardless of what the model was told.

Where guidance does belong

One narrow rule helps and is the structural fix rather than a substitute for it: Stage 2 should route a clarification through route_clarify rather than asking in prose. That is tool-selection guidance, which ADR-064 rule 2 says tool descriptions own, and a clarification that goes through the composer carries the opener, so the guard sees it.

Note the eval suggests guidance alone will not land it: in clarification-then-fallthrough the model made no tool call at all across 3 reps. It is not choosing prose over route_clarify; it is not reaching for a tool. So the detection needs to hold even when the guidance is ignored.

Approaches worth weighing

Not proposing one — this is a design decision.

  • Mark the turn's outcome structurally. A Stage-2 turn that ends with no tool call and an interrogative reply is recordable as a clarification without inspecting its text. Keeps the exactness property the opener was chosen for.
  • Make Stage 2 clarify through the composer. Removes the second path rather than detecting it. Larger change; interacts with how Stage 2 ends a turn.
  • Widen the text match. Tempting and probably wrong — the existing comment argues the opener is exact because the module wrote it. Matching prose the model wrote gives that up and would misfire on any reply containing a question.

Acceptance Criteria

  • A clarification asked in Stage-2 prose is counted against the at-most-one-per-intent contract
  • A Stage-2 prose clarification does not erase a prior route_clarify from the current intent window
  • The detection does not rely on matching text the model wrote, only text the module wrote or a structural property of the turn
  • Guidance directs Stage 2 to clarify via route_clarify, as tool-selection guidance — but the detection holds when that guidance is not followed
  • clarification-then-fallthrough passes in the routing eval, and a test pins the erasure case (composed clarification → prose clarification → the composed one is still counted)
  • Tests pass (bun run test:all), code passes bun run quality:fix

Technical Specifications

Reference Files

  • packages/agent/src/local_agent/agent_loop.rs:1225 — answered_clarifications, intent_start, and the doc comment explaining why the opener is matched
  • packages/agent/src/local_agent/agent_loop.rs:79 — CLARIFICATION_OPENER
  • packages/agent/src/local_agent/agent_loop.rs:3592 — the clarify_suppressed branch that never fires in this case
  • scripts/eval/fixtures/routing.ts — clarification-then-fallthrough, failing 0/3

Related

Activity

  1. added
    bug
    on Sep 23, 2026
  2. malibio commented on Sep 27, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 278 files / 5396 tests passed

  3. self-assigned this
    on Sep 27, 2026
  4. malibio commented on Sep 27, 2026

    @malibio
    CollaboratorAuthor

    WIP handoff (commit 63b7184 on branch issue-2905-prose-clarification-guard): each assistant turn now persists a structural outcome (acted/clarified/replied); the clarification guard reads that instead of the opener text, so a prose clarification is counted and no longer erases a prior route_clarify. Stage 2 is re-prompted once when it replies in prose after an answered clarification, and route_clarify's description says never to ask in a plain reply. test:changed passes. Remaining: routing-eval run for clarification-then-fallthrough (stopped mid rep 1 before reaching it), quality:fix, PR, review.

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

Metadata

Metadata

Assignees

Labels

backendbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions