Skip to content

Timeout-compaction doesn't escalate when compaction fails to reduce context #64962

Description

@OpenCodeEngineer

Bug

When timeout-compaction runs but does not actually reduce the context (e.g., the compaction model produces output but fails to summarize effectively), the system doesn't escalate to a different approach. It logs [timeout-compaction] compaction did not reduce context and falls through to normal error handling, which means the user gets a "Context overflow" error.

Observed log

[timeout-compaction] compaction did not reduce context for azure/grok-4-1-fast-reasoning; 
falling through to normal handling

Root cause

In run.ts, the timeout-compaction path:

  1. Detects timeout + high context usage
  2. Triggers compaction with the current model
  3. If compaction "succeeds" (no error) but context is still over threshold → falls through
  4. No escalation to compact_then_truncate, no model switch, no session rotation

The system treats "compaction ran but didn't help" as unrecoverable, when there are still options:

  • Try a different model with better summarization capability
  • Escalate to compact_then_truncate (aggressive mode)
  • Force session rotation with a handoff summary

Expected behavior

After compaction completes but context is still over threshold:

  1. Try the next compaction fallback model (if available — see Compaction fails permanently when Azure content filter blocks summarization — no model fallback #64960)
  2. If no more models: escalate to compact_then_truncate mode
  3. If that still doesn't reduce enough: force a fresh session with a handoff summary from the last assistant message
  4. Log a clear warning: "session force-rotated due to irrecoverable context overflow"

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper 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:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.impact:session-stateSession, 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.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions