openclaw - 💡(How to fix) Fix Delivery-mirror session token overflow (204k > 200k) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#63116Fetched 2026-04-09 07:58:21
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

The delivery-mirror session for Telegram DMs accumulated 204,765 tokens, exceeding Anthropic's 200k token limit and causing a request loop. Auto-compaction did not prevent this overflow.

Error Message

Error message (from last message in session): "errorMessage": "400 {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 204765 tokens > 200000 maximum"},"request_id":"req_011CZqTVoL6iU2FwWBpy3d1Z"}"

Root Cause

Why compaction didn't prevent this:

  1. Model mismatch: The delivery-mirror session uses model: "delivery-mirror", not the configured compaction model (claude-sonnet-4-5). Compaction may not apply to internal routing sessions.

  2. Session type: Delivery-mirror sessions are OpenClaw's internal routing layer. They shouldn't accumulate conversational history like user-facing sessions do.

  3. Token accounting: Session shows contextTokens: 1000000 (likely a placeholder) but totalTokens: 736865. Actual API call had 204k tokens, suggesting the delivery-mirror transcript grew unbounded.

Fix Action

Workaround

Immediate fix:

rm -f /Users/ivy/.openclaw/agents/main/sessions/[session-id].jsonl

User-facing fix: In Telegram chat, send: /reset

Code Example

{
  "key": "agent:main:telegram:direct:8799946229",
  "kind": "other",
  "channel": "webchat",
  "displayName": "webchat:g-agent-main-telegram-direct-8799946229",
  "model": "delivery-mirror",
  "contextTokens": 1000000,
  "totalTokens": 736865
}

---

"errorMessage": "400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"prompt is too long: 204765 tokens > 200000 maximum\"},\"request_id\":\"req_011CZqTVoL6iU2FwWBpy3d1Z\"}"

---

"compaction": {
  "reserveTokensFloor": 60000,
  "model": "anthropic/claude-sonnet-4-5",
  "memoryFlush": {
    "enabled": true,
    "softThresholdTokens": 8000
  }
}

---

rm -f /Users/ivy/.openclaw/agents/main/sessions/[session-id].jsonl
RAW_BUFFERClick to expand / collapse

Bug Report: Delivery-Mirror Session Token Overflow

Date: 2026-04-08
Reporter: Catherine Rouleau (via Stan agent)
OpenClaw Version: 2026.3.13
Session Key: agent:main:telegram:direct:8799946229

Summary

The delivery-mirror session for Telegram DMs accumulated 204,765 tokens, exceeding Anthropic's 200k token limit and causing a request loop. Auto-compaction did not prevent this overflow.

Details

Session info from sessions_list:

{
  "key": "agent:main:telegram:direct:8799946229",
  "kind": "other",
  "channel": "webchat",
  "displayName": "webchat:g-agent-main-telegram-direct-8799946229",
  "model": "delivery-mirror",
  "contextTokens": 1000000,
  "totalTokens": 736865
}

Error message (from last message in session):

"errorMessage": "400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"prompt is too long: 204765 tokens > 200000 maximum\"},\"request_id\":\"req_011CZqTVoL6iU2FwWBpy3d1Z\"}"

Observable behavior:

  • User sent message in solo Telegram chat
  • OpenClaw attempted to deliver via delivery-mirror session
  • Anthropic API rejected request (204k > 200k limit)
  • OpenClaw retried multiple times, appearing as "looping" to user
  • User received same diagnostic response 6+ times

Configuration

Auto-compaction is enabled in /Users/ivy/.openclaw/openclaw.json:

"compaction": {
  "reserveTokensFloor": 60000,
  "model": "anthropic/claude-sonnet-4-5",
  "memoryFlush": {
    "enabled": true,
    "softThresholdTokens": 8000
  }
}

Analysis

Why compaction didn't prevent this:

  1. Model mismatch: The delivery-mirror session uses model: "delivery-mirror", not the configured compaction model (claude-sonnet-4-5). Compaction may not apply to internal routing sessions.

  2. Session type: Delivery-mirror sessions are OpenClaw's internal routing layer. They shouldn't accumulate conversational history like user-facing sessions do.

  3. Token accounting: Session shows contextTokens: 1000000 (likely a placeholder) but totalTokens: 736865. Actual API call had 204k tokens, suggesting the delivery-mirror transcript grew unbounded.

Expected Behavior

Delivery-mirror sessions should either:

  1. Not accumulate full conversation history (they're routing only)
  2. Be subject to aggressive compaction (much lower threshold than user sessions)
  3. Auto-reset periodically if they must hold history

Workaround

Immediate fix:

rm -f /Users/ivy/.openclaw/agents/main/sessions/[session-id].jsonl

User-facing fix: In Telegram chat, send: /reset

Impact

  • Severity: Medium — blocks user interaction until manual intervention
  • Frequency: Unknown (first observed occurrence)
  • Workaround: Available (session reset)

Recommendation

  1. Delivery-mirror sessions should not accumulate conversational history, OR
  2. Apply aggressive auto-compaction to delivery-mirror sessions (e.g., reserveTokensFloor: 150000), OR
  3. Add session-type-specific compaction rules to prevent internal routing sessions from overflowing

Environment

  • OS: macOS (Darwin 25.2.0 arm64)
  • Node: v25.8.1
  • Model: anthropic/claude-sonnet-4-5 (default)
  • Channel: Telegram (solo DM)
  • Session scope: dmScope: "per-channel-peer"

Transcript location (if needed for debugging): /Users/ivy/.openclaw/agents/main/sessions/ddd4e93a-5e9f-4eb0-ba8e-eb05dd2b7fde.jsonl (Note: file was deleted as workaround, may not exist by time this is reviewed)

extent analysis

TL;DR

Delete the problematic session file or send /reset in the Telegram chat to immediately resolve the issue, and consider implementing aggressive auto-compaction for delivery-mirror sessions to prevent future occurrences.

Guidance

  • Identify and remove or reset sessions that have exceeded the token limit to prevent request loops.
  • Review the compaction configuration to ensure it applies to delivery-mirror sessions, considering a lower reserveTokensFloor for these sessions.
  • Consider implementing session-type-specific compaction rules to handle internal routing sessions differently than user-facing sessions.
  • Monitor the frequency of such issues to determine if the current workaround is sufficient or if a more permanent fix is needed.

Example

To immediately fix the issue, you can delete the session file as suggested in the workaround:

rm -f /Users/ivy/.openclaw/agents/main/sessions/[session-id].jsonl

Alternatively, the user can send /reset in the Telegram chat.

Notes

The provided workaround addresses the immediate issue but does not prevent future occurrences. Implementing aggressive auto-compaction or session-type-specific compaction rules may be necessary for a long-term solution.

Recommendation

Apply aggressive auto-compaction to delivery-mirror sessions, such as setting reserveTokensFloor to a lower value (e.g., 150000), to prevent token overflows and subsequent request loops. This approach is chosen because it directly addresses the root cause of the issue (token accumulation in delivery-mirror sessions) without requiring significant changes to the existing system.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING