Skip to content

Make MAX_OVERFLOW_COMPACTION_ATTEMPTS config-driven (currently hardcoded to 3) #80638

@Cedric20011203

Description

@Cedric20011203

Summary

MAX_OVERFLOW_COMPACTION_ATTEMPTS = 3 is a hardcoded const at pi-embedded-Bcz04p2i.js:1955 (verified in 2026.5.7 tarball). When a long-lived agent hits context-overflow, the runtime tries up to 3 LLM-summarizer compactions before bubbling the error. Each attempt is a billable model round-trip. For agents on per-seat ChatGPT Team/Pro/Enterprise quotas, a sustained overflow loop burns the seat very fast.

Real-world impact

A long-lived agent:<bot>:main session running openai-codex/gpt-5.5:

  • 7 context-overflow events in 17 hours.
  • Each triggered up to 3 compaction calls.
  • ~21 billable compaction calls × ~34K tokens each, on top of normal traffic.
  • Seat hit 66-hour cooldown.

The 2026.5.4 post-compaction loop guard helps when the agent is repeating the same (tool, args, result) triple, but it does not protect against compaction itself running 3× per overflow on a session where the summary is structurally too large.

Proposed fix

Expose as agents.defaults.compaction.maxOverflowAttempts (default 3, lower to 1 to fail-fast on overflow). Sibling keys (compaction.mode, compaction.reserveTokens, compaction.recentTurnsPreserve) suggest this slot is the natural home.

Related

(Re-filed from badlogic/pi#4 — filed in wrong repo originally.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.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: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.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions