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
#44138 was closed as fixed by the messagesToSummarize + turnPrefixMessages check in src/agents/pi-hooks/compaction-safeguard.ts:727 (shipped in 2026.3.22). That fix is present in 2026.4.15 — verified at dist/model-context-tokens-z5hvDVkk.js:4558-4561 of the published bundle.
But the message above comes from a different code path: the outer pre-check that runs before the Pi SDK builds a preparation object.
Because this guard only sees the raw session.messages slice (after limitHistoryTurns()), it has no preparation / turnPrefixMessages context to consult. steipete's split-turn fix for the inner safeguard was not mirrored here.
Failure mode
isRealConversationMessage accepts a toolResult only if a meaningful user message exists within the previous 20 entries. On long sessions where most recent activity is Read/Grep/Bash tool-call sequences, the trimmed window can land on a stretch of toolResult / heartbeat entries with no user message inside the 20-message lookback. Every entry then fails the test and the user sees the skip even though the session is at 118% of context and had plenty of real conversation upstream.
Repro shape
Long-running Discord-thread session, mostly tool calls (Read/Grep/Bash) interleaved with brief user prompts.
/compact → Compaction skipped: no real conversation messages yet • Context 236k/200k (118%).
Sending a fresh plain-text user turn and re-running /compact succeeds.
Suggested fix direction
Mirror the intent of the inner-safeguard fix in the outer pre-check. Two options:
Pass turnPrefixMessages (or equivalent prefix context) into the outer guard so it has the same view the inner safeguard now has.
Bypass the outer pre-check entirely when the estimated token count is over the configured compaction threshold — a session at 118% of context window should never be short-circuited as "idle".
Option 2 is the conservative one and eliminates the misclassification risk without touching message-classification heuristics.
Symptom
Manual
/compacton a long, tool-heavy Discord-thread session reports:The session is clearly not idle — context is at 118%.
Why this is a separate issue from #44138
#44138 was closed as fixed by the
messagesToSummarize+turnPrefixMessagescheck insrc/agents/pi-hooks/compaction-safeguard.ts:727(shipped in2026.3.22). That fix is present in2026.4.15— verified atdist/model-context-tokens-z5hvDVkk.js:4558-4561of the published bundle.But the message above comes from a different code path: the outer pre-check that runs before the Pi SDK builds a
preparationobject.dist/compact-Fl3cALvc.js:910→containsRealConversationMessages(session.messages)dist/model-context-tokens-z5hvDVkk.js:3726→isRealConversationMessageBecause this guard only sees the raw
session.messagesslice (afterlimitHistoryTurns()), it has nopreparation/turnPrefixMessagescontext to consult. steipete's split-turn fix for the inner safeguard was not mirrored here.Failure mode
isRealConversationMessageaccepts atoolResultonly if a meaningful user message exists within the previous 20 entries. On long sessions where most recent activity is Read/Grep/Bash tool-call sequences, the trimmed window can land on a stretch oftoolResult/ heartbeat entries with no user message inside the 20-message lookback. Every entry then fails the test and the user sees the skip even though the session is at 118% of context and had plenty of real conversation upstream.Repro shape
/compact→Compaction skipped: no real conversation messages yet • Context 236k/200k (118%)./compactsucceeds.Suggested fix direction
Mirror the intent of the inner-safeguard fix in the outer pre-check. Two options:
turnPrefixMessages(or equivalent prefix context) into the outer guard so it has the same view the inner safeguard now has.Option 2 is the conservative one and eliminates the misclassification risk without touching message-classification heuristics.
Environment
2026.4.15/compact