feat(handoff): scale transcript budget to the destination context window - #686
Conversation
Handoff transcripts are truncated from the front, so a 50k-char budget (~12k tokens) drops the start of the conversation — goal, constraints, decisions — and hands the next agent a transcript that begins mid-word. Size the budget from the destination model's context id instead, claiming 35% of it and never going below the previous-generation default of 400k chars. A 1M-context handoff now carries ~350k tokens instead of ~12k. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
SDSLeon
left a comment
There was a problem hiding this comment.
Deep review (findings-only, PR tests verified 11/11 locally). Direction looks right — scaling the ceiling to the destination window instead of a fixed 50k is the correct fix for front-truncation eating the goal/constraints. Details inline.
Scope question to confirm: since gui→gui handoffs now take the thread-transcript route (own thread on switch, thread mention on fork — nothing copied), this PR only affects context-file handoffs: anything involving a terminal, mirrored threads, read_thread disabled, and the mobile path. Is that the intended readership? Related: 35% of the destination window rides the new session's first message for the rest of its run — deliberate trade vs. a smaller share?
|
@playtix-brain please fix and respond to comments, thank you! |
SDSLeon
left a comment
There was a problem hiding this comment.
Reviewed the adopted changes at 638ca74 and resolved the five prior review threads. No remaining Important findings after behavior, integration, compatibility, and simplification review.
Destination-based sizing is covered through the desktop dialog; mobile and failed-file delivery stay within the existing remote JSON limit. Small contexts retain the original ask, parser behavior remains compatible with saved settings, and successful attachment delivery preserves the larger transcript.
Validation: 115 targeted tests passed, including long Unicode/escaped payloads and mobile switch/fork paths. Typecheck plus touched-file standard/type-aware lint and formatting passed. GitHub CI is running and will be checked before merge.
Stored-history handoffs used a fixed 50,000-character budget, discarding useful earlier conversation even when the destination had a much larger context window. Desktop context files now scale to approximately 35% of the destination window (four characters per token), while preserving the original ask and prioritizing recent conversation over tool activity.
This affects stored-history
context-filehandoffs. Provider-side extraction andthread-transcripthandoffs continue through their existing paths. No persisted or wire shape changes are required.Validation: 115 targeted tests passed across transcript selection, desktop dialog wiring, mobile switch/fork delivery, attachment success/failure, shared parser compatibility, and handoff strategy. Typecheck and touched-file standard/type-aware lint and formatting checks passed.