-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Bug: compaction/reset paths can break session invariants (messageProvider + token accounting) #69269
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
Problem
Compaction/reset paths can break session invariants in two related ways:
messageProviderIn practice this causes downstream consumers to see one real conversation as multiple logical sessions, and can also trap a session in repeated compaction safeguard loops after the transcript has already been cleared.
Concrete affected paths
Today this cluster shows up across several connected paths:
handleAutoCompactionStart/Endcompact.queued.tsemitResetCommandHookssessions.resetviaemitGatewayBeforeResetPluginHooktokensAfter === 0Reproduction A: provider invariants
agent:main:feishu:default:direct:ou_xxxctx.sessionKey+ctx.messageProviderto build stable session identity/new,/reset, orsessions.resetctx.messageProvidermissing, mixed-case, or inferred from a non-channel key shapeunknownor treatsTelegram/telegramas different providersReproduction B: token accounting invariants
totalTokens/ cost state was not reset consistentlyExpected
Compaction/reset code paths should preserve the same session invariants everywhere:
messageProviderwhen one is actually knownActual
Different paths currently preserve different subsets of those invariants, so downstream systems must guess or degrade.
Scope
This is broader than the original single-field hook bug. It covers the coordinated compaction/reset invariant cluster now reported separately in: