fix: trust paste-commit marker so Claude Code TUI agents stop failing paste-not-rendered#2229
Merged
Merged
Conversation
…ling paste-not-rendered #2192's paste verification confirmed delivery by finding the prompt's literal text in the TUI buffer. Claude Code collapses a multi-line bracketed paste into a [Pasted text #N] chip and hides the body text, and reflows single lines with cursor-positioning escapes instead of literal spaces — so the text check false-negatived and every claude-code-tui CoS agent died with paste-not-rendered after 3 retries despite the paste landing (100% repro, 2026-07-05). - New isPasteConfirmed(): the TUI's own paste-commit marker count exceeding the prompt's own marker count is authoritative proof of delivery, checked first; literal-text verification is the fallback only for the markerless path. - verifyPasteRendered() now compares with all whitespace removed, so a space-less reflowed line still matches. - agentTuiSpawning.js submits on marker/text confirmation and only retries/fails when a markerless paste never renders (the genuine #2192 swallowed case). - Pinned real-incident transcripts as regression tests. Claude-Session: https://claude.ai/code/session_01S64MA1pN4QiuXiT8uUVJd7
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.
Problem
The #2192 paste-verification guard confirmed a pasted prompt had landed in a TUI by searching the post-paste buffer for the prompt's literal text. That broke every
claude-code-tuiCoS agent (100% reproduction across real runs, 2026-07-05 — agent-65e4d17f, agent-1f0bda99, agent-656efa6e, …), because Claude Code:[Pasted text #N +M lines]chip and hides the body text — so the literal prompt text is genuinely absent from the buffer even though the paste landed perfectly.Onthetaskspage…has no spaces and a single-space-normalized substring match fails.Both made the text check false-negative, so agents retried 3× and died with
paste-not-rendereddespite the paste succeeding.Fix
isPasteConfirmed(buffer, { verifiablePrefix, promptMarkerCount })intuiHandshake.js. It checks two signals in priority order:countPasteMarkers(buffer) > promptMarkerCount— is authoritative proof of delivery (the prompt's own echoed markers are subtracted out), checked first.verifyPasteRenderednow compares with all whitespace removed (was: collapsed to a single space), so a space-less reflowed line still matches.agentTuiSpawning.jssubmits as soon as the paste is confirmed (marker or text), and only enters the retry/fail path when a markerless paste never renders — preserving the genuine OpenCode TUI prompt paste silently swallowed — 'Prompt pasted (ready)' logged but text never reaches the input #2192 swallowed-paste protection.Tests
Real 2026-07-05 incident transcripts (ANSI-stripped, verbatim from
raw.txt) are pinned as regression tests: the collapsed-chip-hides-body case, the space-less reflow case, the echoed-marker-not-mistaken-for-commit case, and the genuinely-swallowed case. Full server suite green (16702 passed).Follow-up
A narrow remaining edge — a multi-line prompt that itself embeds literal
[Pasted text #N]chips can still false-negative — is tracked in #2228 (low severity; deferred on reviewer recommendation so this fix ships the 100%-repro common case).https://claude.ai/code/session_01S64MA1pN4QiuXiT8uUVJd7