-
-
Notifications
You must be signed in to change notification settings - Fork 52.6k
Closed
Description
Bug Description
Thread sessions forked from a parent DM session inherit the parent's full context. When the parent session has accumulated tokens near/above the model's context limit, newly forked thread sessions are born dead — every API call immediately returns prompt is too long: N tokens > 190000 maximum and the user gets no response.
The failure is silent on Slack — no error message is sent to the user. Messages are simply swallowed.
Steps to Reproduce
- Use Slack DM channel with
thread.inheritParent: true(default) - Have extended conversations in the parent DM session until it accumulates ~170k+ tokens
- Start a new thread (Slack auto-creates a thread session forked from parent)
- The thread session immediately hits context overflow on first API call
- User sees no response — the error is logged but never surfaced
Observed Behavior
From gateway error log:
[session-init] forking from parent session: parentKey=agent:main:slack:direct:... → sessionKey=...thread:... parentTokens=169508
[agent/embedded] embedded run agent end: isError=true error=Context overflow: prompt too large for the model.
From Anthropic API:
{"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 193390 tokens > 190000 maximum"}}Key details:
contextTokensconfig is set to 1,000,000 but this is a cap, not an override — model's actual limit (190k for Opus 4-6) takes precedence- Auto-compaction attempts (up to 3) fail because the inherited context is already too large
- The error response has
usage: {input: 0, output: 0}— no tokens consumed - No error message is sent to the Slack channel — complete silent failure
Expected Behavior
- Thread sessions should NOT inherit full parent context when parent is near/over the context limit — compact before forking, or fork with a summary only
- Context overflow errors should be surfaced to the user on Slack (e.g., "
⚠️ Context overflow — starting fresh session") instead of silently dropping the message - Parent sessions should auto-compact proactively before hitting the model limit, not only on overflow
Environment
- OpenClaw version: 2026.2.24 (npm)
- Model: anthropic/claude-opus-4-6 (190k context limit)
- Channel: Slack (Socket Mode)
- Config:
contextTokens: 1000000,compaction.mode: "default",thread.inheritParent: true
Impact
This caused 3 separate incidents over 2 days where Slack became unresponsive. Each required manual session file deletion + gateway restart to recover. The silent failure mode means the user has no idea why the bot stopped responding.
Related Issues
- Auto-compaction not triggered during tool-use loops, leading to unrecoverable context overflow #24800 — Auto-compaction not triggered during tool-use loops
- Feature: Context overflow warning before hitting limit #13097 — Context overflow warning before hitting limit
- [Bug]: Context-overflow recovery can finalize empty instead of deterministic fallback #19550 — Context-overflow recovery can finalize empty instead of deterministic fallback
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels