openclaw - 💡(How to fix) Fix Auto-compaction produces empty-content assistant messages that hard-kill sessions (Venice HTTP 400) [1 comments, 2 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#73829Fetched 2026-04-29 06:14:32
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
mentioned ×2subscribed ×2closed ×1commented ×1

When auto-compaction fails or is interrupted mid-run, it can write structurally invalid assistant messages with content: [] (empty array) into the session JSONL file. Every subsequent turn then returns HTTP 400 (no body) from Venice — zero input tokens, zero output tokens — because the API rejects a conversation history containing empty assistant turns. The fallback provider (OpenAI) also fails for the same reason: same broken payload, same rejection.

The session becomes permanently dead. OpenClaw's own repair pass (session file repaired: rewrote 2 assistant message(s)) does not fully resolve it — the 400s continue after repair.

Error Message

  1. Session JSONL now contains trailing assistant messages with content: [], stopReason: error, usage.input: 0, usage.output: 0 2026-04-28T18:28:52.442+01:00 [agent/embedded] [context-overflow-diag] sessionKey=*** provider=venice/claude-sonnet-4-6 source=assistantError messages=407 compactionAttempts=0 error=Context overflow: estimated context size exceeds safe threshold during tool loop. 2026-04-28T21:12:47.662+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body) 2026-04-28T21:12:48.289+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body) 2026-04-28T21:19:44.755+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body) "stopReason": "error",
  2. Detect that a session tail contains consecutive zero-token error-stop assistant messages and quarantine/reset automatically before attempting the next turn

Root Cause

When auto-compaction fails or is interrupted mid-run, it can write structurally invalid assistant messages with content: [] (empty array) into the session JSONL file. Every subsequent turn then returns HTTP 400 (no body) from Venice — zero input tokens, zero output tokens — because the API rejects a conversation history containing empty assistant turns. The fallback provider (OpenAI) also fails for the same reason: same broken payload, same rejection.

Fix Action

Workaround

Rename the poisoned .jsonl to .jsonl.poisoned so it is not resumed. OpenClaw will create a fresh session on the next turn.

Code Example

2026-04-28T18:28:52.442+01:00 [agent/embedded] [context-overflow-diag] sessionKey=*** provider=venice/claude-sonnet-4-6 source=assistantError messages=407 compactionAttempts=0 error=Context overflow: estimated context size exceeds safe threshold during tool loop.
2026-04-28T18:28:52.442+01:00 [agent/embedded] context overflow detected (attempt 1/3); attempting auto-compaction for venice/claude-sonnet-4-6

2026-04-28T21:12:46.854+01:00 [agent/embedded] session file repaired: rewrote 2 assistant message(s) (b21b827c-...)
2026-04-28T21:12:47.662+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body)
2026-04-28T21:12:48.289+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body)

2026-04-28T21:19:43.895+01:00 [agent/embedded] session file repaired: rewrote 2 assistant message(s) (b21b827c-...)
2026-04-28T21:19:44.755+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body)

---

{
  "type": "message",
  "message": {
    "role": "assistant",
    "content": [],
    "provider": "venice",
    "model": "claude-sonnet-4-6",
    "usage": { "input": 0, "output": 0 },
    "stopReason": "error",
    "errorMessage": "400 status code (no body)"
  }
}
RAW_BUFFERClick to expand / collapse

Summary

When auto-compaction fails or is interrupted mid-run, it can write structurally invalid assistant messages with content: [] (empty array) into the session JSONL file. Every subsequent turn then returns HTTP 400 (no body) from Venice — zero input tokens, zero output tokens — because the API rejects a conversation history containing empty assistant turns. The fallback provider (OpenAI) also fails for the same reason: same broken payload, same rejection.

The session becomes permanently dead. OpenClaw's own repair pass (session file repaired: rewrote 2 assistant message(s)) does not fully resolve it — the 400s continue after repair.

Reproduction

  1. Run a tool-heavy session until context overflow is detected during a tool loop
  2. Auto-compaction triggers (compactionAttempts=0, source=assistantError)
  3. Compaction fails or is interrupted (e.g. WhatsApp watchdog timeout firing simultaneously)
  4. Session JSONL now contains trailing assistant messages with content: [], stopReason: error, usage.input: 0, usage.output: 0
  5. Every subsequent turn — including a simple "ping" — returns 400 status code (no body) from Venice immediately
  6. session file repaired log entry appears but does not resolve the 400s
  7. Session is unrecoverable without manual file quarantine/rename

Log Evidence

2026-04-28T18:28:52.442+01:00 [agent/embedded] [context-overflow-diag] sessionKey=*** provider=venice/claude-sonnet-4-6 source=assistantError messages=407 compactionAttempts=0 error=Context overflow: estimated context size exceeds safe threshold during tool loop.
2026-04-28T18:28:52.442+01:00 [agent/embedded] context overflow detected (attempt 1/3); attempting auto-compaction for venice/claude-sonnet-4-6

2026-04-28T21:12:46.854+01:00 [agent/embedded] session file repaired: rewrote 2 assistant message(s) (b21b827c-...)
2026-04-28T21:12:47.662+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body)
2026-04-28T21:12:48.289+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body)

2026-04-28T21:19:43.895+01:00 [agent/embedded] session file repaired: rewrote 2 assistant message(s) (b21b827c-...)
2026-04-28T21:19:44.755+01:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-sonnet-4-6 provider=venice error=400 status code (no body)

Poisoned Session File Pattern

Trailing entries in the dead session JSONL:

{
  "type": "message",
  "message": {
    "role": "assistant",
    "content": [],
    "provider": "venice",
    "model": "claude-sonnet-4-6",
    "usage": { "input": 0, "output": 0 },
    "stopReason": "error",
    "errorMessage": "400 status code (no body)"
  }
}

Multiple such entries exist consecutively at the tail of the file. content: [] violates the Anthropic/OpenAI API contract — empty assistant turns are structurally invalid.

Impact

  • Session becomes permanently unrecoverable
  • The user sees [assistant turn failed before producing content] on every turn including trivial inputs like "ping"
  • The fallback provider also fails (same payload sent to both)
  • session file repaired log entry is misleading — it does not resolve the 400s
  • Without manual intervention, every new message appended to the session continues to fail

Expected Behaviour

Compaction failure should either:

  1. Not write empty-content assistant entries into the session file, or
  2. Detect that a session tail contains consecutive zero-token error-stop assistant messages and quarantine/reset automatically before attempting the next turn

Workaround

Rename the poisoned .jsonl to .jsonl.poisoned so it is not resumed. OpenClaw will create a fresh session on the next turn.

Environment

  • OpenClaw: 2026.4.25 (aa36ee6)
  • Provider: venice/claude-sonnet-4-6 via openai-completions API
  • Compaction mode: safeguard
  • Compaction model: openai/gpt-4o-mini
  • Context at overflow: 407 messages, overflow during tool loop
  • OS: macOS Darwin 25.4.0 arm64

extent analysis

TL;DR

Manually renaming the poisoned session JSONL file to prevent resumption or implementing a detection mechanism to quarantine sessions with consecutive zero-token error-stop assistant messages can resolve the issue.

Guidance

  • Identify and rename the poisoned session JSONL file to .jsonl.poisoned to prevent OpenClaw from resuming it.
  • Consider implementing a session validation check before attempting to process a turn, to detect and quarantine sessions with trailing empty-content assistant messages.
  • Review the auto-compaction failure handling to ensure it does not write structurally invalid messages to the session file.
  • Verify that the fallback provider (OpenAI) is correctly handling sessions with empty assistant turns.

Example

No code snippet is provided as the issue is more related to the handling of session files and auto-compaction failures rather than a specific code error.

Notes

The provided workaround of renaming the poisoned session file is a temporary solution. A more permanent fix would involve modifying the auto-compaction failure handling and session validation to prevent the creation of structurally invalid messages.

Recommendation

Apply the workaround of renaming the poisoned session file to .jsonl.poisoned to immediately resolve the issue, and then investigate implementing a more robust session validation and auto-compaction failure handling mechanism to prevent similar issues in the future.

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

openclaw - 💡(How to fix) Fix Auto-compaction produces empty-content assistant messages that hard-kill sessions (Venice HTTP 400) [1 comments, 2 participants]