-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
fix(compaction): retry loop can burn tokens when summarizer model is unavailable #58838
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.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.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.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.
Type
Fields
Priority
None yet
Bug Description
summarizeChunks()insrc/agents/compaction.tsusesretryAsync()with 3 attempts per chunk to handle transient errors during compaction. However, when the summarizer model is persistently unavailable (overloaded, rate-limited, or misconfigured), the retry loop burns tokens across multiple chunks without making progress.In a multi-chunk compaction scenario (common with long channel conversations), this means:
Each retry sends the chunk to the model, consuming input tokens even though the response fails. With large chunks (~4K tokens each), a 5-chunk compaction can waste 60K+ tokens before finally throwing.
Expected Behavior
After N consecutive compaction failures, the system should stop attempting compaction and fall back to the previous summary (or a placeholder). This prevents cascading token waste when the summarizer is down.
A circuit breaker pattern would be appropriate:
Affected Code
src/agents/compaction.ts:263—retryAsync()call insummarizeChunks()summarizeWithFallback()andsummarizeInStages()