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
[BUG] compaction causes AGENTS.md to be re-attached because extract() skips compacted Read results #31764
After session compaction, the extract() function in instruction.ts skips tool results that were compacted (part.state.time.compacted). This means the system forgets which AGENTS.md/CLAUDE.md files were already loaded by Read tool calls, causing duplicate re-attachment of instruction files.
if(part.type==="tool"&&part.tool==="read"&&part.state.status==="completed"){if(part.state.time.compacted)continue// <-- this skips after compaction
When compaction summarizes old messages, the Read tool results are marked as compacted. The extract() function skips these, returning an empty set. The resolve() function then re-loads and re-attaches AGENTS.md files that were already loaded, causing:
Duplicate instructions in the AI context window
Wasted tokens
AGENTS.md being re-read multiple times across compaction boundaries
Steps to reproduce
Start a session with an AGENTS.md file in the project
The instruction file is loaded via system() at startup
Let the conversation grow long enough for compaction to trigger
After compaction, a new Read tool call triggers resolve()
The extract() function returns empty (compacted results skipped)
If #31764 is intentionally a focused follow-on to #30807 (compaction-only, as opposed to prune + compaction), please clarify that in the description so maintainers can track them separately.
Activity
github-actions commentedon Jun 10, 2026
This issue might be a duplicate of existing issues. Please check:
instruction.tsskips compacted/pruned Read results causing AGENTS.md re-attachment. That issue was filed by the same author and covers this exact root cause along with a second prune loop bug.extract()skip logic).If #31764 is intentionally a focused follow-on to #30807 (compaction-only, as opposed to prune + compaction), please clarify that in the description so maintainers can track them separately.