Skip to content

[Bug]: Thread sessions inherit overflowed parent context, born dead with silent failure #26905

@markshields-tl

Description

@markshields-tl

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

  1. Use Slack DM channel with thread.inheritParent: true (default)
  2. Have extended conversations in the parent DM session until it accumulates ~170k+ tokens
  3. Start a new thread (Slack auto-creates a thread session forked from parent)
  4. The thread session immediately hits context overflow on first API call
  5. 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:

  • contextTokens config 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

  1. 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
  2. Context overflow errors should be surfaced to the user on Slack (e.g., "⚠️ Context overflow — starting fresh session") instead of silently dropping the message
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions