Skip to content

feat(handoff): scale transcript budget to the destination context window - #686

Merged
SDSLeon merged 4 commits into
Porabuild:masterfrom
playtix-brain:feat/handoff-context-budget
Sep 10, 2026
Merged

feat(handoff): scale transcript budget to the destination context window#686
SDSLeon merged 4 commits into
Porabuild:masterfrom
playtix-brain:feat/handoff-context-budget

Conversation

@playtix-brain

@playtix-brain playtix-brain commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

  • 200k context: 280,000 characters; 1M context: 1,400,000 characters. Unknown sizes use 400,000 characters. File context is capped at 4,000,000 characters for remote attachment delivery.
  • Small windows receive proportionally smaller transcripts, with message truncation that retains the original request and includes header/gap costs in the budget.
  • Numeric context parsing is shared with the existing settings parser, including case, commas, decimals, and 1k–10M bounds.
  • Mobile uses the destination budget capped at 50,000 characters. Desktop attachment failures use the same inline ceiling, retaining the beginning and end with an omission marker. This accommodates the remote 1 MiB JSON request limit, including duplicated prompt/segments and escaped text.

This affects stored-history context-file handoffs. Provider-side extraction and thread-transcript handoffs 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.

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 SDSLeon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Comment thread src/renderer/actions/handoffTranscript.ts Outdated
Comment thread src/renderer/actions/handoffTranscript.ts Outdated
Comment thread src/renderer/actions/handoffTranscript.ts Outdated
Comment thread src/renderer/actions/handoffTranscript.ts
Comment thread src/renderer/actions/handoffTranscript.test.ts
@SDSLeon

SDSLeon commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

@playtix-brain please fix and respond to comments, thank you!

@SDSLeon SDSLeon self-assigned this Sep 10, 2026

@SDSLeon SDSLeon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@SDSLeon
SDSLeon merged commit ff93eee into Porabuild:master Sep 10, 2026
15 checks passed
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.

2 participants