fix(chat): suppress leaked token budget banners - #7626
Conversation
be5851a to
748cada
Compare
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Sound, bounded mitigation at the right shared layer, but it fingerprints one provider's exact English artifact and smuggles a broader Stop/rollback rework along. Watch
[DESIGN-REVIEWED] e00588a |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of All lenses run; verifying counts are complete. Final review: First-Principles-Verdict: CONCERNS The banner fix earns its place, but it patches one of six delivery surfaces, and a pre-existing Stop-race fix rides along inside it. What this change shipsIntent: stop a provider-internal "You have N weighted tokens left" line from becoming the final assistant message (and stealing the file-change card) — a FIX, backed by two screenshots.
Watch
[FIRST-PRINCIPLES-REVIEWED] e00588a |
GPT 5.6 Review (fork) —
|
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed Review detailsThe candidate list contains one item. Let me evaluate it against the falsification bar. CANDIDATE 1 — hardcoded literal Verifying the evidence: the diff line 162 defines Applying the three-part bar:
This is a latent-coupling/duplication concern, and Step 1 mandates rejecting anything in the duplication category. It also fails (a) and (c). Dropped. No candidate survives. During falsification I read the recovery path, the stage-loop stop-generation gating, No findings. [OPUS-REVIEWED] e00588a |
748cada to
c7e954e
Compare
c7e954e to
e00588a
Compare
|
|
Maintainer rerun requested for the current-head GPT 5.6 Review ( |
|
|
Fast-forward bridge preserving the prior fork tip after a reviewed fresh-base rebase.
|
Open PR relationship auditThis is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion. Relationship findings
No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit. |
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: Three mechanical blockers: (1) rebase onto current main and reconcile If you'd prefer I don't touch this PR, add the |
|
@rubencu Thanks for this. The audit found two open PRs that overlap this one, so sharing the detail here to let the three of you sequence the work. #8288 (@Pearcekieser) is the hard collision. Both PRs rewrite the same #9156 (@buluoray) is lighter. It moves the Suggested order: agree on one file-change-attribution implementation and one one-shot policy, ideally as a small shared PR, then rebase onto it. Both this PR and #8288 are currently dirty. Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong. |
|
Rebase onto main
Also worth settling: |
Problem / Motivation
Long-running model turns can emit a provider-internal context-budget sentence such as
You have 8154 weighted tokens leftas ordinary assistant prose. In observed dashboard sessions, that sentence became the final assistant row and inherited the turn's file-change card instead of the user receiving a real completion summary.Why it matters
The artifact is confusing on its own, but it can also make incomplete work look finished. Normal chats may end without a useful answer, and orchestrated stages can be captured or skipped even though the model emitted only provider metadata.
What changed (motivation → approach → change)
The symptom comes from provider text entering the same streamed-text path as a real answer. This change handles it narrowly at the authoritative turn and orchestration boundaries:
You have <N> weighted tokens leftshape for provenance-bearing tool, orchestrator-stage, and synthetic provider-recovery turns. Preserve quoted/natural token discussion, mid-turn text, any real answer that follows, and all text when the user explicitly requested this literal phrase.end_turnor structural provider artifact is terminal-eligible; capture requires a real non-compaction assistant result after the current stage separator.record_roundand remove only that round on every pre-capture exit, including Stop, cancellation, timeout, internal error, missing/timed-out subagent manager, empty/compaction-only result, capture failure, and teardown. Prior completed results, escalation state, and task-failure history remain authoritative.Broader no-provenance and no-tool/status-only compaction handling is intentionally out of scope and tracked in #7961.
Tests
origin/main(18aef5166): the completetest_dashboard_chat.pyplus provider-banner, post-compaction, regeneration, file-change, orchestrator-cancellation, and config-load suites.context_management.py, reproduced on pristine main and outside the changedabort_rounddocstring. isort, flake8, mypy, andgit diff --checkpass across all changed files.Manual verification
Verified two independent saved dashboard screenshots/transcripts showing the same exact provider artifact attached to different file-change cards. Both raw rows were assistant content, not a context-meter UI label; the second screenshot was treated as corroborating evidence for the same defect, not as evidence to widen the matcher beyond the proven provenance boundary.
Related Issues
no linked issue: the dashboard bug was reported directly; #7961 tracks the broader cross-surface/no-provenance follow-up.
Pattern harvest
Rule candidate: review-prompt
Pattern: provider-only status text emitted through the assistant channel must be sanitized at authoritative persistence boundaries using explicit provenance, with bounded continuation and cancellation-safe orchestration.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)