Skip to content

kernel: fold signed thinking with its run (batched read loops) - #11

Merged
Zayik merged 1 commit into
masterfrom
claude/project-thread-klkh1w
Nov 1, 2026
Merged

Zayik merged 1 commit into
masterfrom
claude/project-thread-klkh1w

Conversation

@Zayik

@Zayik Zayik commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Requested by David · project thread

Problem

On Haiku 5.5 (Anthropic wire, signed thinking), almost nothing was foldable. In a replayed session at 224K context, only 14,241 tokens were foldable, against 113,888 on stock upstream. So the 50K nudge fired late (about 130K) or never, which put sessions past the 100K long-context price step.

Cause: computeProtectedRefs Rule 2 (the last preserveRecentTokens) skips read/bash payloads (neverPreserveRecentTools). On a batched read loop ([signed thinking][4 reads][4 results]), the window walks back over little but thinking messages and protects every one of them, while their calls and results stay foldable. The carve then strips the thinking from any fold, and INV3 (ranxianglei#4885, from the cherry-picked upstream PR ranxianglei#4898) correctly withdraws the whole run as a partial split. Net effect: every Haiku turn is unfoldable.

Fix

Signed thinking follows its run. In computeProtectedRefs, if no other member of a signed run (its calls or prose) is protected, the thinking leaves the protected set, so the run folds as one unit. Recommend and apply both use computeProtectedRefs, so what gets advertised stays foldable.

Kept as before:

Evidence

Live check (Haiku 5.5 via Copilot, 4 sessions, same fixture and defaults)

before with fix
cost per session (pi table) $0.21 $0.109
first nudge 122-142K 96-102K
turns past 100K about 48% 7%
Anthropic 400s 0
tests 9/9 9/9 (4/4 sessions)

32 of 65 signed thinking messages were folded, and every session continued normally. Partial-split withdrawals still fired live (2 in one session).

Known limit: a session that reads the whole repo in a few giant turns can reach about 220K before any nudge. No growth threshold can catch that.

🤖 Generated with Claude Code

https://claude.ai/code/session_013kJPjm1Dk8kfpvXQY1hZE7

computeProtectedRefs put every thinking message of a batched read loop on
the protected list. neverPreserveRecentTools drops read/bash payloads from
the recent window, so Rule 2 walked back over little but thinking while the
calls and results stayed foldable. The carve then stripped the thinking from
every fold and INV3 (ranxianglei#4885) withdrew the whole run as a partial split.

A replayed Haiku session advertised 14,241 tokens at 224K context, so the
growth nudge came late or not at all. INV3 was right to refuse the split;
the recent zone was manufacturing it.

Thinking in a signed run with no other protected member now leaves the zone,
so the run folds as one unit on both the recommend and apply sides. The same
replay advertises 114,686 tokens. Partial splits are still withdrawn. Unsigned
reasoning is untouched (ranxianglei#564), a run whose call or prose is protected keeps
its thinking, and the latest run stays protected so an open tool loop keeps
its signature.

acp-kernel 0.0.176 -> 0.0.177.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Zayik Zayik self-assigned this Nov 1, 2026
@Zayik
Zayik merged commit f61f2a4 into master Nov 1, 2026
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.

1 participant