Skip to content

fix(coding-agent): reopen oversized sessions and wrap tool output - #1388

Open
leeseunguk wants to merge 2 commits into
code-yeongyu:mainfrom
leeseunguk:fix/resume-budget-and-output-width
Open

fix(coding-agent): reopen oversized sessions and wrap tool output#1388
leeseunguk wants to merge 2 commits into
code-yeongyu:mainfrom
leeseunguk:fix/resume-budget-and-output-width

Conversation

@leeseunguk

@leeseunguk leeseunguk commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Let an existing session reopen with its saved provider/model even when its restored history exceeds that model's startup budget, so the user can compact or change models from the UI.
  • Keep fixed prompt/tool/reserve viability checks, admission to different explicit or fallback models, and request-time compaction/final-provider admission.
  • Wrap completed and expanded bash_output results using the existing ANSI-aware wrapper instead of returning over-wide physical lines.

Reproduction and scope

An isolated source CLI session with a 100,000-token model and 112,006 tokens of saved history exits before the TUI with ModelUsabilityBudgetError: required 148,861 tokens, even with speculation lead already zero. This follows #1341; omitting speculation lead alone cannot recover this case.

Unlike the model-recovery approach in #1263, this change keeps the saved model and opens the session for recovery without selecting another provider. Switching to a different target still validates the restored history.

The output-width issue is separate: the tool component can emit 102/180-column lines inside a 98-column box. The TUI's normal-mode width dump is not proof of a process crash, so this PR does not attribute the startup exception to that diagnostic.

Validation

  • Reproduced the startup failure on current main, then reran the same isolated source CLI fixture in a real 98-column PTY: saved history rendered, the editor echoed unsubmitted input, and normal shutdown exited 0.
  • Model-admission, compaction, and output-width regressions: 38 tests passed across 4 files.
  • Completed output was also exercised through the actual renderer: 98-column Box limit respected and the end of the long ANSI-colored payload preserved.
  • Full monorepo npm run build passed on the final runtime changes.
  • Repository TypeScript check, dependency/import/lockfile checks, and browser smoke check passed.
  • Isolated harness checks: 10/10; RPC startup checks: 4/4; CLI smoke: 8/8. Real credentials were unchanged.

The broader mock-loop self-test has an unrelated baseline failure: textual-tool-leak recovery cases fail on the unchanged checkout (13/22 overall), while the normal local mock-provider round trip passes. This PR does not modify that behavior.

Independent local gate review approved both commits with high confidence.


Summary by cubic

Resuming a session with its saved model no longer fails on oversized restored history, so the TUI opens and the user can compact or switch models from the UI. Completed and expanded bash_output results now wrap with the ANSI-aware wrapper instead of emitting over-wide lines.

Bug Fixes

  • Same-model resume skips the live-history budget check; switching to a different explicit or fallback model still validates the full transcript.
  • Fixed prompt, tool, and reserve viability checks still apply on resume.
  • Wrapping is display-only; partial preview behavior is unchanged.

Written for commit 48e9171. Summary will update on new commits.

Review in cubic

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.

1 participant