#context overflow doom loop

1 messages ยท Page 1 of 1 (latest)

plucky fjord
#

The main session is stalled. Can't compact context.

16:13:09 debug agent/embedded {"subsystem":"agent/embedded"} embedded run start: runId=6ad586ff-000c-4b52-a5e8-6d037a2cf864 sessionId=7311a5a8-95c1-4e23-9c52-088faad0a37a provider=openai-codex model=gpt-5.2 thinking=medium messageProvider=telegram
16:13:09 debug agent/embedded {"subsystem":"agent/embedded"} embedded run prompt start: runId=6ad586ff-000c-4b52-a5e8-6d037a2cf864 sessionId=7311a5a8-95c1-4e23-9c52-088faad0a37a
16:13:09 debug agent/embedded {"subsystem":"agent/embedded"} embedded run agent start: runId=6ad586ff-000c-4b52-a5e8-6d037a2cf864
16:13:17 debug agent/embedded {"subsystem":"agent/embedded"} embedded run agent end: runId=6ad586ff-000c-4b52-a5e8-6d037a2cf864
16:13:17 debug agent/embedded {"subsystem":"agent/embedded"} embedded run compaction start: runId=6ad586ff-000c-4b52-a5e8-6d037a2cf864
16:13:17 debug agent/embedded {"subsystem":"agent/embedded"} embedded run prompt end: runId=6ad586ff-000c-4b52-a5e8-6d037a2cf864 sessionId=7311a5a8-95c1-4e23-9c52-088faad0a37a durationMs=8261
16:13:23 error [clawdbot] Unhandled promise rejection: Error: Context overflow: Summarization failed: Codex error event: Your input exceeds the context window of this model. Please adjust your input and try again. (code=context_length_exceeded). Your input may be too large for the context window.
    at AgentSession._runAutoCompaction (file:///root/.nvm/versions/node/v25.2.1/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:1456:11)
    at processTicksAndRejections (node:internal/process/task_queues:103:5)
    at AgentSession._checkCompaction (file:///root/.nvm/versions/node/v25.2.1/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:1318:4)
    at _handleAgentEvent (file:///root/.nvm/versions/node/v25.2.1/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:315:4)
stone drumBOT
#

This is the classic context overflow doom loop โ€” the session context is so huge that even the summarization attempt exceeds gpt-5.2's context window. The model can't summarize itself when it's drowning in context.

The session is dead in the water. You need to:

  1. Clear the session entirely:

    pnpm clawdbot session clear 7311a5a8-95c1-4e23-9c52-088faad0a37a
    

    โš ๏ธ This nukes the conversation history โ€” start fresh.

  2. Or if you need to save it, manually export the transcript before clearing.

Prevention for next time:

  • Enable auto-compaction with a model that has larger context (like opus or gpt-4o)
  • Lower the compactionThreshold in config to compact before it hits the wall
  • Consider splitting into multiple sessions if this is a long-running project
#

The root issue: gpt-5.2 has a smaller context window than the accumulated session size, so compaction itself fails. This is a known edge case in pi-coding-agent.

Want me to help you configure better compaction settings for the future? ๐Ÿฆ

plucky fjord
#

Yeah how do I lower the compaction threshold?

stone drumBOT
#

Looking at the config schema, here's what you can tweak:

Compaction Settings (agents.defaults.compaction)

agents:
  defaults:
    compaction:
      reserveTokensFloor: 15000  # Minimum tokens to keep after compaction
      memoryFlush:
        enabled: true
        softThresholdTokens: 100000  # Trigger flush at 100k tokens

Context Pruning (agents.defaults.contextPruning) โ€” Recommended

This is more aggressive and prevents the doom loop:

#
agents:
  defaults:
    contextPruning:
      mode: aggressive           # 'off' | 'adaptive' | 'aggressive'
      softTrimRatio: 0.3         # Trim to 30% when threshold hit
      hardClearRatio: 0.1        # Hard reset at 10% of context window
      keepLastAssistants: 2      # Keep last 2 assistant messages

Quick Fix

Add this to your config:

agents:
#
  defaults:
    contextPruning:
      mode: aggressive
      softTrimRatio: 0.25
      hardClearRatio: 0.05

This will proactively trim context before it hits the overflow wall, avoiding the doom loop entirely.

The key insight: reserveTokensFloor alone won't save you if context already exceeded the model's window. Context pruning intercepts earlier. ๐Ÿฆ

plucky fjord
#

Where do I fidn these settings?

stone drumBOT
#

Your config is at: /srv/clawdbot/state/clawdbot.json

Add these settings under agents.defaults:

{
  "agents": {
    "defaults": {
      "model": { ... },
      "contextPruning": {
        "mode": "aggressive",
        "softTrimRatio": 0.25,
        "hardClearRatio": 0.05
      },
      "compaction": {
        "reserveTokensFloor": 15000,
#
        "memoryFlush": {
          "enabled": true,
          "softThresholdTokens": 100000
        }
      }
    }
  }
}

Then run: pnpm clawdbot gateway restart (or /restart if using commands)

The key file path: /srv/clawdbot/state/clawdbot.json ๐Ÿฆ

plucky fjord
#

the main session is stuck. how do i hard reset?

stone drumBOT
#

The stuck session ID is: 7311a5a8-95c1-4e23-9c52-088faad0a37a

Run:

pnpm clawdbot session clear 7311a5a8-95c1-4e23-9c52-088faad0a37a

Or from Discord command channel:

/session clear 7311a5a8-95c1-4e23-9c52-088faad0a37a

This nukes the session history and lets you start fresh. ๐Ÿฆ

plucky fjord
#

/session clear 7311a5a8-95c1-4e23-9c52-088faad0a37a