Skip to content

[Bug]: Pre- compaction memory flush sends empty user message to Anthropic API #75305

@sableassistant3777-source

Description

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

When a session approaches the context limit and auto-compaction triggers, OpenClaw's pre-compaction memory flush constructs a user message with empty string content (""). The Anthropic API rejects this with a 400 error, causing the session to reset unexpectedly

Steps to reproduce

Let a session run long enough to approach the auto-compaction threshold. The flush
triggers automatically — no user action required.

Expected behavior

The pre-compaction flush completes silently and the session continues or compacts cleanly.

Actual behavior

Telegram User sees: "Something went wrong while processing your request. Please try again,
or use /new to start a fresh session." — and the session is reset.

Root Cause (suspected by claude)

The flush prompt text exists in the session trajectory as a system message, but the
"messages" array passed to the API contains only an empty string. The flush prompt
content appears to not be serialized correctly before the API call.

OpenClaw version

2026.4.27

Operating system

Windows 11

Install method

No response

Model

Anthropic/claude-sonnet-4.6

Provider / routing chain

Telegram > Openclaw Gateway > anthropic/claude-sonnet-4.6

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

This ends up causing issues in sessions that use a fair amount of context, i assume that there are a decent number of people hitting this problem. It happens to me multiple times a day and results in me needing to run /compact if that even works

Additional information

NOT_ENOUGH_INFO

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions