Skip to content

Cover route_multi in the routing eval; relabel out-of-scope as decline - #2879

Merged
malibio merged 2 commits into
mainfrom
issue-2877-routing-eval-multi
Sep 23, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-2877-routing-eval-multi

Conversation

@malibio

@malibio malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Closes #2877

Summary

  • route_multi coverage. Adds multi and decline expectation kinds. Two compound scenarios expect route_multi. Two single-intent-at-length scenarios (singleIntentAtLength) must not route multi; these are the negative case the guard clauses defend against.
  • Global multi guard. Every non-multi scenario fails if Stage 1 routes multi. Per-query retrieval after a split can still land the right skill, so without this an over-splitting regression would pass on downstream effects.
  • multi_rejected log tag. A route_multi call with fewer than 2 usable queries used to log none, which looked the same as "no routing tool called". It now logs multi_rejected (routing::undecided_routing_tag, unit-tested), so the rejection path the issue flagged is now measured.
  • out-of-scope-weather → decline. Follows the decision in the issue comment: assert the turn outcome (no route_clarify, no mutating tool, the turn ends in a reply) and leave Stage 1's tool choice unasserted. This corrects a label against ADR-038's existing fall-through clause, so no ADR amendment is needed.
  • clarification-then-fallthrough. Keeps the label and adds a comment: the scored turn follows a clarification and the user's answer, so the at-most-one-clarification contract applies (clarify_suppressed). The label tests that contract, not whether the prompt is clear on its own.
  • Baseline. The header states the Stage-1 constant-answer baseline (13 query / 3 clarify / 2 multi → 13/18 = 72.2%). A test pins it against the scenario list, and every run's summary prints it.

Test plan

  • New scripts/eval/fixtures/routing.test.ts (9 tests). Mutation-checked: removing the global multi guard fails 2 of them.
  • guidance_is_not_contaminated_by_eval_prompts passes with the 4 new prompts
  • New Rust test a_rejected_route_multi_is_tagged_apart_from_no_decision
  • bun run quality:fix clean; pre-push gate (test:all + build + e2e) passed
  • Live routing-eval run not performed (needs the daemon + model). The new scenarios haven't been measured against the locked model yet.

🤖 Generated with Claude Code

…line (closes #2877)

- Add `multi` and `decline` expectation kinds. Two compound scenarios
  expect route_multi; two single-intent-at-length scenarios must not.
- Every non-multi scenario now fails if Stage 1 routes multi, so an
  over-splitting regression can't pass on downstream effects.
- Log a route_multi call with fewer than two usable queries as
  `multi_rejected` instead of `none`. It is the over-selection the guard
  clauses target, and it was indistinguishable from "no routing tool".
- out-of-scope-weather: `decline` asserts the turn outcome (no
  route_clarify, no mutation, a reply) and leaves Stage 1's tool choice
  unasserted, per ADR-038's existing fall-through clause.
- clarification-then-fallthrough: add a comment justifying the label via the
  at-most-one-clarification contract.
- The header states the Stage-1 constant-answer baseline (13/18 = 72.2%).
  It is pinned by a test and printed in every run's summary.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #2879

Review Type: Initial review (no prior reviews or comments on the PR)

Summary

This is a tightly scoped, net-positive change. It closes the eval's blind spot for route_multi with positive and negative scenarios. A global guard means an over-splitting regression can't pass on downstream effects. out-of-scope-weather is relabelled exactly as the maintainer's comment specified, and the header baseline is pinned by a test so it can't drift. The Rust change is small and correct: multi_rejected separates a failed route_multi from "no routing tool called". The deferred let routing_decision_tag: &str; also makes the compiler prove that every path assigns a tag, which beats a mutable "none" default that could be silently left in place. I found no blocking issues.

Requirements Check

  • ✅ The expectation model covers route_multi, with a negative case. The new multi kind has two compound scenarios (multi-task-and-search, multi-schema-and-search) and two negatives flagged singleIntentAtLength (single-intent-long-task, single-intent-long-search). I checked each prompt against its label. Both compound prompts join two independent actions ("…and also pull up…", "…then separately find…"). Both negatives are a single action with extra detail: one task with priority and a note, and one search whose three topics describe the same set of notes.
  • ✅ A decision is recorded on out-of-scope-weather. It now expects decline, which asserts the turn outcome: no clarify, no mutating tool, and a non-empty reply. Stage 1's tool choice is left unasserted, as the issue comment directs, and the ADR-038 fall-through clause is cited in both the comment and the PR body.
  • ✅ clarification-then-fallthrough is justified in a comment. The comment explains that the scored turn falls under the at-most-one-clarification contract (clarify_suppressed).
  • ✅ The header states the baseline. It reads 13 query / 3 clarify / 2 multi → 13/18 = 72.2%. I recomputed this from the issue's 11/4 split: −1 clarify (weather), +2 query, +2 multi. It matches. The figure is pinned by routing.test.ts and printed in every run summary.
  • ✅ Tests and quality checks pass. The PR reports that quality:fix is clean and the pre-push gate passed. It also has 9 new bun tests (mutation-checked) and a new Rust unit test. The live routing run against the locked model is honestly marked as not done. That is an eval measurement, not a merge gate.

Code Review Findings

🔴 Critical

None.

🟡 Improvements

  • 📁 scripts/eval/fixtures/routing.ts (askedToClarify): Part of this check can never be true. turns.some(t => t.toolsCalled.includes("route_clarify")) looks for a tool that never shows up there. toolsCalled comes from the main loop's [tool] lines (runner.ts:272), and Stage 1's routing tools are never recorded as main-loop tool calls. The check therefore rests entirely on routingDecision === "clarify". That is the right signal, but a reader will assume two independent checks are in place.
    • Principle: code should say what it actually does (KISS / avoid misleading dead branches).
    • Fix: drop the toolsCalled half, or add a comment that it is defence-in-depth for a future tool surface.
  • 📁 scripts/eval/fixtures/routing.test.ts (baseline pin test): The test pins only part of the baseline sentence. The regex covers scores X/Y = Z% but not the 13 query / 3 clarify / 2 multi breakdown in the same sentence. If someone adds a clarify scenario, the hits/total check fails and forces an edit, but a breakdown left stale would still pass. The test's own comment says a stale figure is worse than none, and that applies here too.
    • Principle: single source of truth for derived documentation.
    • Fix: extend the regex to capture (\d+) query / (\d+) clarify / (\d+) multi and assert the per-decision counts.

🟢 Nits

  • Nit: 📁 packages/agent/src/local_agent/routing.rs (undecided_routing_tag doc): The doc comment misdescribes one case. It says "none" covers "(or emitted unparseable arguments)". But a route_multi call with unparseable JSON is tagged multi_rejected, because the function only looks at tool names. That behaviour is right (the model still reached for multi), but the doc should say "unparseable arguments to route_query/route_clarify". The same applies to the new None => arm comment in agent_loop.rs.
  • Nit: 📁 scripts/aichat.ts:230-232: Leftover line break. The comment reflow left // Take the last, in case on a line of its own, which reads like an editing leftover. Rejoin it with the next line.
  • Nit: 📁 packages/agent/src/local_agent/agent_loop.rs (~3551 and ~3624): Two comment lines run long. The widened outcome lists push them past the surrounding wrap width. Re-wrap for consistency with the adjacent comment block.
  • Nit: 📁 scripts/eval/fixtures/routing.ts (constantAnswerBaseline): Empty input would print NaN. An empty scenario list gives total = 0, and the summary would print NaN%. This can't happen with the shipped fixture, so it's noted only for completeness.

Standards Check

  • Backward-compatibility code: none; the old clarify label and its adversarial workaround were removed outright.
  • GitHub issue numbers in code or comments: none. The only one is closes #2877 in the commit message, which is allowed.
  • Test placement: the new tests live under scripts/ and are DOM-free, so the bun:test exception applies.
  • Comment style: comments explain why (the over-splitting pass-through risk, the ADR-038 fall-through) rather than what, matching the surrounding style.

Recommendation

APPROVE. The two 🟡 items are small, local clean-ups that are worth folding in during address-review. Neither affects correctness of the scoring or of the Rust tag.

🤖 Generated with Claude Code

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

- askedToClarify reads routingDecision only. route_clarify never appears
  in toolsCalled (Stage-1 chunks aren't forwarded), so the second check
  could never fire.
- The baseline test now also pins the header's 13/3/2 per-decision split
  (mutation-checked: altering the header fails it).
- The undecided_routing_tag doc and None-arm comment now say that a
  route_multi call with unparseable arguments counts as multi_rejected.
- Re-wrap the comment lines the widened outcome lists pushed long.

Skipped: the NaN% guard for an empty scenario list. The shipped fixture
can't be empty, and the baseline test would fail first.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary

Fixed in a409abc:

  • 🟡 Clarify check: askedToClarify now reads only routingDecision. route_clarify never appears in toolsCalled because Stage-1 chunks aren't forwarded, so that half of the check could never be true.
  • 🟡 Baseline test: it now also checks the header's 13 query / 3 clarify / 2 multi split. Changing a number in the header makes it fail.
  • 🟢 Comment wording: the undecided_routing_tag doc and the None-arm comment now say that a route_multi call with unparseable arguments counts as multi_rejected.
  • 🟢 Line wrapping: re-wrapped the long comment lines in agent_loop.rs and rejoined the stray line in aichat.ts.

Skipped:

  • 🟢 NaN% on an empty scenario list: the shipped fixture can't be empty, and the baseline test would fail first.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED
Rationale: Apart from comment fixes, the commit removes a check that could never be true and tightens one test. Scoring behaviour doesn't change. The pre-push gate (test:all + build + e2e) passed.

@malibio
malibio merged commit b0be644 into main Sep 23, 2026
@malibio
malibio deleted the issue-2877-routing-eval-multi branch September 23, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Routing eval has no route_multi coverage, and two scenario labels conflate out-of-scope with ambiguous

1 participant