Repository navigation
[PR] fix: a covered tool-result id held by another tool call is missing - #6919
MohammadErfan-Jabbari wants to merge 1 commit into
Conversation
Claude Code replaces older screenshots with one placeholder text near the request-size limit. Tool results that share a caption share a base id (ranxianglei#3642 hashes tool name and text only), so later results inherit the covered ordinals and the fold hides them instead of the evicted ones. A covered id whose current message carries a different tool_use_id than its anchor is now treated as missing and re-claimed by exact toolCallId; the message holding it may be claimed only by that rung. rewriteBlocks keeps a target that is itself a claimed id, so ids handed along a chain of duplicates survive. Fixes ranxianglei#6916 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 #6919 is the only PR addressing #6916. Nearest neighbors checked and distinct: #5360/#5196 (post-restart ref reuse — kernel ref-space mechanism, different failure domain), #5398 (retiring persistently-unmatched coverage — the opposite direction: coverage that never re-matches, vs. this PR's coverage that re-matched onto the wrong duplicate), #5836 (test-only repro of legacy coverage loss). No parallel fix in flight. Review in progress — local verification so far:
Full review with regression analysis follows shortly. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Review — fix: covered tool-result id held by another tool call is missing (#6916)Verdict: mergeable (human merge — §7.4 identity tier, correctly self-assessed in the PR body). All completed CI lanes green (13/13, 0 failed); 6 guard lanes still queued at review time (mysql-contract, kernel-guard, unused-exports, config-surface-guard, lifecycle-ledger-guard, docs-sync) — the diff touches none of those domains, expected to pass. Branch is 18 commits behind master at review time; trial merge shows 0 conflicts and master has not touched What I verified
Behavior changes (disclosed, both intended)
Suggested labels (not applied — source PR is author-owned)
结构化八问
判定:可合并(待 6 个排队中的 guard 车道转绿,预期通过;按 §7.4 身份逻辑档由人工合并)。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI update: all 30 lanes now completed — 18 success, 12 skipped (gated e2e), 0 failed. The 6 previously-queued guard lanes (mysql-contract, kernel-guard, unused-exports, config-surface-guard, lifecycle-ledger-guard, docs-sync) all passed. Nothing outstanding on the review side; ready for a human merge whenever. |
Fixes #6916
Problem
Near the request-size limit, Claude Code replaces older screenshots with one placeholder text. A tool result's id hashes its tool name and text only (#3642), so screenshots that share a caption share one base id and are told apart by position. When the oldest ones become placeholder text, every later screenshot inherits a covered id, the fold hides those later screenshots, and the evicted ones go out unfolded. The drift line counts only the ids that vanished, so it understates the leak.
Fix (host side, no kernel change)
In
src/fold-reconcile.ts:planReconciliation: a covered id whose current message carries a different non-emptytoolCallIdthan its anchor (anchors[id].t) counts as missing (displaced). It is claimed back only by the existing exact-toolCallIdrung, never by similarity, and the message that wrongly held the id is a candidate for that rung only. A displaced id already claimed is skipped.rewriteBlocks: a replacement target that is itself a claimed id may leave its slot in the same pass, so ids handed along a chain of duplicates survive.Identity stays exact: the change only uses the protocol's own tool-call id, which bili already stores per folded tool result.
Both compression modes
Fold reconcile runs on the resent history in both modes, and the change acts only when a covered id's message carries a different tool-call id than its anchor. A history with unique or unshifted tool results takes the same path as before.
Tests
tests/issue6916-media-eviction-displaced-ids.test.ts(new) replays the shape scrubbed from the real session: 30 screenshot turns with one shared caption, a fold over screenshots 0 to 8, then the first 15 screenshots evicted to one placeholder. On master the fold ends up on screenshots 15 to 23; with the fix it stays on 0 to 8, and the next pass claims nothing. The negative case (duplicates that keep their tool-call id are not moved) passes on both.verif-subset-guardpasses: 349 pass, 2 skipped.npm run typecheckis clean.Review tier
This changes message-identity logic in fold reconcile (KDD #11), so per §7.4 it stays with a human reviewer. No config, persistence-format, wire-shape or kernel change.
🤖 Generated with Claude Code