Repository navigation
fix: stop silently truncating handoffs, imports, stashed prompts and pasted context - #7
Merged
Merged
Conversation
…d show omissions A provider or model switch passed at most 16,000 tokens of history to the new provider (clamped to 64,000), however large the target model's window was, and only the model was told that history was left out. The history allowance now defaults to half of the target model's context window when it is known, or 200,000 tokens otherwise, still bounded by the existing room calculation for native context, the request, and working space. T3CODE_CONTEXT_HANDOFF_TOKEN_CAP still sets a fixed allowance, now clamped to 1,024-1,000,000. Handoffs are prepared up to that ceiling and narrowed at delivery, where the window is known. When delivery leaves items out, the run gets a system notice in the thread saying how many did not fit, alongside the existing recovery hint to the agent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fork merge-back summary cut every user and assistant message to 240 characters, and side chat context was capped at 8,000 characters built from the same cut lines. Merge-back summaries now carry each message in full within the handoff token budget. When the budget forces cuts, the oldest items are dropped whole and the summary says how many were omitted and where to read them. Side chat context also keeps whole messages and is capped at 64,000 characters, keeping its existing "Earlier items truncated" marker. Command and file-change lines stay compact since they are activity references, not conversation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…with reasons Thread import offered only conversations from the last 30 days, imported at most 100 transcripts per run, kept 200 messages per thread, skipped transcripts over 32 MiB of kept history or 100,000 records, and discovered at most 5,000 transcripts per source. Anything skipped became an unexplained "N threads could not be imported" count. Import now takes every conversation of the selected projects, whatever its age, and every visible message. The kept-history budget is 256 MiB and the record limit 10 million; discovery takes 100,000 transcripts per source, with metadata budgets scaled to keep the same per-transcript average. The 4 GiB per file and per-import read limits stay. Each skipped transcript now carries its file and reason through the import result, and the Welcome page warning lists them grouped by reason. The history budget stays well under 1 GiB because a thread is parsed and committed whole: importing 100 MB of message text measured about 530 MB of peak heap, with the event loop blocked at most 78 ms; the shell stream drops transcript bodies and thread views page their history, so the import adds no large websocket payloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The prompt stash held 20 entries and silently deleted the oldest on overflow (the desktop V1 migration applied the same cap), and each entry dropped images past a fixed 2.7M-character budget even when storage had room. The stash no longer has an entry cap or eviction. It lives in localStorage, which shares a few megabytes with drafts, so a write that exceeds the quota leaves the existing stash untouched, keeps the new prompt in the composer, and tells the user storage is full. Images are kept whenever the write fits; when it does not, the largest are left out one at a time until it does, and the user is told which ones. Mobile has no prompt stash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fore cutting Terminal selections were cut at 64,000 characters, review comment text at 16,000 and diffs at 32,000, all well under the 120,000-character prompt limit, and the only sign was a "... truncated ..." line at the end of the context. Each of these now uses the full prompt limit; a prompt whose combined context is over the limit is already refused with a visible error. When a single terminal selection or review comment is longer than the limit, the composer shows a warning banner naming it before the message is sent. Mobile already refuses oversized terminal selections instead of cutting them. The 120,000-character prompt limit is unchanged: it is also enforced by the server (provider send input, scheduled tasks, attachment prompt budget), so raising it is not a client-only change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 120,000-character limit was checked only against the typed prompt, while the server renders attached context records (terminal output, review comments) into the provider prompt with no total check, so a message with large attached context could exceed the limit unnoticed. Message intake now measures the prompt with its context records rendered in, for sends, queued-message edits and thread launches, and refuses an over-limit message with a visible error naming the excess. The web composer measures the same projected text before sending and shows the same message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndow With the larger handoff budget, a prepared handoff could hold up to 1M tokens of history three times: in history.messages, in summaryText rendered from the same messages, and again in the handoff turn item's summary. When a handoff carries history, summaryText is now only its coverage note, and the fork merge-back summary is capped at 16,000 bytes (whole messages, oldest dropped with a count); the messages themselves live only in history. Handoffs prepared at turn start, where the target model's window is known, keep no more history than half that window. Handoffs prepared at dispatch, before the window is known, still use the 1M ceiling and are narrowed at delivery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A side chat's first turn prepends up to 64,000 characters of parent activity to the prompt, but the handoff history budget counted only the user's text and the restart note, so history plus side chat context could overflow a small-window model. The budget now counts everything sent beside history, including the side chat context, through one helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…equests Import kept up to 256 MiB of message text per thread, but a thread is parsed and committed whole, and measured peak heap runs at a few times the kept text. Committing large threads in chunks was tried and did not lower the measured heap needed (about 450-500 MB for 204 MB of text either way), since the parsed thread itself dominates, so the budget is lowered to 128 MiB instead. One import request now covers a project's whole history and can run for minutes, so the web client allows it the long-running grace period before flagging it as slow. The client has no hard timeout for it, and connected sidebars receive one coalesced update per imported thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The import result listed every skipped transcript path, which for a project with thousands of skips is a large response and an unreadable warning, and any skip, including sessions with no user messages, kept a project marked as not fully imported so it was offered again every time. The result now carries, per reason, the full count and at most 50 example paths; the Welcome page merges them across projects and shows "and N more". Sessions with no user messages, which importing again cannot change, no longer keep a project marked unfinished. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ures The prompt stash and composer drafts share localStorage's few-megabyte quota. Without the old entry cap the stash could fill it, after which draft saves failed silently in a debounced write; the stash also treated any storage error as "storage full". Stashed images are now left out, with the existing visible warning, once the stash would pass about 60% of the quota (3M characters), so drafts keep room. Only a QuotaExceededError counts as storage full; other write errors leave the stash as it was with their own message and do not drop images. Draft writes that fail now show a persistent toast saying drafts are not being saved, once per failure streak. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With handoffs sized from the target model's window, switching a long thread to a large-window model can send a lot of history on its first turn. Say so, since it costs tokens with usage-billed providers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several paths cut content without telling the user: provider/model switches passed ~16k tokens of history, fork merge-back cut each message to 240 characters, thread import capped runs at 100 threads and threads at 200 messages and skipped older or larger threads with a generic count, the prompt stash deleted the oldest entry at 20, and pasted terminal/review/diff context was cut at 16-64k characters.
T3CODE_CONTEXT_HANDOFF_TOKEN_CAPclamped to 1M), counting side-chat context; a thread notice says when history was left out. History is stored once. Merge-back keeps whole messages and drops the oldest with a count. Side-chat context 64k characters.Known limits: provider-switch and merge-back handoffs are prepared before the target window is known (bounded at delivery); threads imported earlier keep their old 200-message cut.
vp test runThreadMessageIntake, ContextHandoffService, ContextHandoffBudget, ProviderSwitch.integration, ThreadMergeBack.integration, ThreadFork.execution, SteeringCompletion.integration, ProviderTurnStartService, AgentSessionImporter, AgentSessionScanner (apps/server)vp test runcomposerSubmission, projectImport.logic, promptStashStore, lib/storage (apps/web); agentSessions (contracts)vp run check:changedClaude Opus 5.5 via Claude Code (T3 Code).