Skip to content

feat(auto): surface routing scope and per-turn receipts#4500

Merged
Hmbown merged 4 commits into
mainfrom
agent/091-routing-observability
Jul 18, 2026
Merged

feat(auto): surface routing scope and per-turn receipts#4500
Hmbown merged 4 commits into
mainfrom
agent/091-routing-observability

Conversation

@Hmbown

@Hmbown Hmbown commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • record a typed Auto routing receipt with the effective provider-safe strong/fast pair, selected tier, source/reason, selection scope, and routing data path
  • carry the receipt from accepted dispatch through the authoritative turn route and retain it for the completed-turn inspector
  • redact the complete classifier prompt after recent tool results have been flattened, using the same exact configured-secret boundary as model-bound tool output
  • derive receipt pairs from a runnable pair that actually contains the selected model, so non-default OpenRouter families cannot be reported as the provider's default DeepSeek pair
  • persist the latest provider identity, model, and receipt atomically across automatic snapshots, /save, fork, rename, and session restore while keeping older session JSON loadable
  • replace the vague select per turn picker hint with localized disclosure of local vs. DeepSeek classifier behavior and the last resolved provider/model
  • show the exact resolved route, pair, tier, reason, scope, and classifier data path in Ctrl+O Turn Inspector output

Why

Auto routing can select across the runnable provider inventory and send the latest request plus bounded recent context to DeepSeek / deepseek-v4-flash. Before this lane, the picker did not disclose that behavior and the decision metadata was not attached to the exact turn. The initial implementation also exposed two release blockers: flattened tool results could bypass structured tool-result redaction, and a non-default OpenRouter model could inherit the provider default's unrelated pair in its receipt.

This makes the existing behavior observable, auditable, secret-safe, model-family-correct, and durable across TUI session lifecycle operations without copying credentials, endpoints, provider failure text, or raw classifier errors into diagnostics.

User impact

The model picker now states whether a routing request may be sent and shows the last resolved route. After dispatch, the localized toast identifies the concrete route and source. The Turn Inspector keeps the detailed receipt aligned with the authoritative runtime route, including classifier-fallback cases where data was sent before the local heuristic took over. The latest receipt remains available after saving and resuming the session.

Verification

Exact tested head: e6215f6a354ee9764a81bdddada728cf3d5455ca
Rebased base: 8ab67a0bc03ac78406677339f3e4e3714e138885

  • cargo fmt --all -- --check
  • git diff --check origin/main...HEAD
  • cargo clippy -p codewhale-tui --bin codewhale-tui --locked -- -D warnings
  • cargo test -p codewhale-tui --bin codewhale-tui --locked model_routing — 27 passed
  • cargo test -p codewhale-tui --bin codewhale-tui --locked model_inventory — 10 passed
  • cargo test -p codewhale-tui --bin codewhale-tui --locked localization::tests:: — 17 passed
  • cargo test -p codewhale-tui --bin codewhale-tui --locked model_bound_request_ — 3 passed
  • cargo test -p codewhale-tui --bin codewhale-tui --locked commands::groups::session::session::tests — 31 passed
  • cargo test -p codewhale-tui --bin codewhale-tui --locked auto_route_receipt — 2 passed

Deliberate residual scope

Refs #4405
Refs #4411

@Hmbown Hmbown added this to the v0.9.1 milestone Jul 17, 2026 — with ChatGPT Codex Connector
@Hmbown Hmbown added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request tui Terminal UI behavior, rendering, or interaction ux User experience, interaction, or presentation polish v0.9.1 Targeting v0.9.1 labels Jul 17, 2026 — with ChatGPT Codex Connector
@Hmbown
Hmbown force-pushed the agent/091-routing-observability branch from 6a8cfe6 to e6215f6 Compare July 17, 2026 22:28
@Hmbown

Hmbown commented Jul 17, 2026

Copy link
Copy Markdown
Owner Author

Release-blocker fixes are pushed at exact head e6215f6a354ee9764a81bdddada728cf3d5455ca, rebased on current main 8ab67a0bc03ac78406677339f3e4e3714e138885.

Resolved in this head:

  • classifier prompts now pass through exact configured-secret redaction after tool results are flattened into bounded routing context
  • receipt pairs are derived from the selected runnable model family, so a non-default OpenRouter route cannot be labeled with the provider default DeepSeek pair
  • the latest Auto provider identity, model, and receipt persist atomically across automatic snapshots, /save, fork, rename, and resume; legacy session JSON still loads without migration

Exact-head local gates are green: fmt, diff check, bin clippy with warnings denied, 27 routing tests, 10 inventory tests, 17 localization tests, 3 model-bound redaction tests, 31 session lifecycle tests, and 2 receipt persistence tests. Hosted CI restarted for the rebased head and is currently queued/running.

The PR body now reflects the corrected durability claim and the remaining scope: latest TUI receipt persistence is included; a historical receipt ledger and runtime-thread/sub-agent receipt surfaces are not. The release changelog lane in #4487 should list this PR after merge. Contributor credit is unchanged; no external contributor material was added by this fix.

Hmbown added 4 commits July 17, 2026 19:39
Record provider-safe strong/fast pairs, selected tier, scope, reason, and local/classifier data path for every Auto selection. Redact classifier inventory inputs and reject unready provider/model recommendations.
Carry Auto decision metadata with the exact authoritative turn, disclose classifier scope and data flow in the localized model picker, and show resolved route diagnostics in the Turn Inspector. Document the classifier context boundary and fallback behavior.
Update resolved-route diagnostics atomically at dispatch time so the inspector cannot combine a newly selected provider/model with stale Auto decision metadata. Keep the Auto picker row construction isolated from provider rows.
Redact flattened routing context at the classifier boundary and derive receipt pairs from the selected model family.

Persist the latest atomic Auto route receipt across automatic and explicit session lifecycle paths while keeping legacy sessions loadable.

Signed-off-by: Hunter B <hmbown@gmail.com>
@Hmbown
Hmbown force-pushed the agent/091-routing-observability branch from e6215f6 to 1e7c016 Compare July 18, 2026 02:50
@Hmbown

Hmbown commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

Rebased cleanly onto exact main 0c6109cfb56f058bee75e76f885a04ac644f284b (including #4498's hook EOF fix) and force-pushed with an exact lease.

New exact head: 1e7c0164499c6890cfe26bbd83dc940c00501e79

Local exact-head verification passed:

  • cargo fmt --all -- --check
  • git diff --check origin/main...HEAD
  • TUI model_routing (27), model_inventory (10), localization (17), model-bound request (3), session (31), and auto-route receipt (2) tests
  • cargo clippy -p codewhale-tui --bin codewhale-tui --locked -- -D warnings

Fresh exact-head CI and CodeQL are running now; I will not mark ready or merge until the platform matrix is green.

@Hmbown
Hmbown marked this pull request as ready for review July 18, 2026 03:10
Copilot AI review requested due to automatic review settings July 18, 2026 03:10
@cursor

cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@Hmbown
Hmbown merged commit e9c4dbb into main Jul 18, 2026
19 of 20 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@claude

claude Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

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

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request tui Terminal UI behavior, rendering, or interaction ux User experience, interaction, or presentation polish v0.9.1 Targeting v0.9.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants