You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prompt loop reloads all messages from DB every iteration, breaking prompt cache byte-identity #31525
filterCompactedEffect(sessionID) reloads ALL messages from the DB at the start of every prompt loop iteration. Between reloads, the DB can return rows with different object identity (new allocations), even though the message content hasn't changed. This breaks Anthropic's prompt cache, which relies on byte-identical prefixes to avoid reprocessing cached content.
Steps to reproduce
Start a session with many messages
Observe that each prompt loop iteration reloads all messages from the DB
Prompt cache hit rate drops because message object identity changes between iterations
Expected behavior
Messages should be cached across prompt loop iterations, with only new messages appended. A full reload should only happen after operations that modify the message list (subtasks, compaction, overflow).
You're right — I was mutating historical messages via a plugin, so I was breaking the prompt cache myself. The byte-identity framing here is wrong: Anthropic's cache is content-based, not object-identity-based, so a plain DB reload that produces identical content wouldn't break it.
The only real remnant is a minor perf angle — filterCompactedEffect does a full message-table reload on every loop iteration even when nothing changed — but that's redundant DB I/O at most, not a cache-correctness issue, and it overlaps with #24841 / #22208 anyway.
Activity
github-actions commentedon Jun 9, 2026
This issue might be a duplicate of existing issues. Please check:
filterCompactedEffectreloads all messages from DB every loop iteration, breaking Anthropic prompt cache byte-identity (same author, same component, same analysis)filterCompactedEffectIf this is intentionally a follow-up or refinement of those issues, please reference them in the description.
rekram1-node commentedon Jun 9, 2026
?? Are u mutating historical messages or somehting??
BYK commentedon Jun 9, 2026
I did yes through a plug-in
rekram1-node commentedon Jun 9, 2026
well thats expected behavior then haha ur breaking the prompt cache urself
BYK commentedon Jun 10, 2026
You're right — I was mutating historical messages via a plugin, so I was breaking the prompt cache myself. The byte-identity framing here is wrong: Anthropic's cache is content-based, not object-identity-based, so a plain DB reload that produces identical content wouldn't break it.
The only real remnant is a minor perf angle —
filterCompactedEffectdoes a full message-table reload on every loop iteration even when nothing changed — but that's redundant DB I/O at most, not a cache-correctness issue, and it overlaps with #24841 / #22208 anyway.Closing this. Apologies for the noise.