openclaw - 💡(How to fix) Fix lossless-claw compaction breaks tool_calls/tool message chain → 499 error on model switch

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…

Error Message

  1. Send a message → 499 error

Root Cause

lossless-claw compaction appears to drop assistant messages containing \ ool_calls\ while preserving the corresponding \ ool\ role messages. This creates orphaned \ ool\ messages that violate the OpenAI API message format, causing 499 errors when the reconstructed context is sent to the model API.

Fix Action

Workaround

Send /reset\ before switching models to clear conversation history.

RAW_BUFFERClick to expand / collapse

Bug Description

When switching models mid-conversation on WeChat (openclaw-weixin channel), the API returns:

\
❌ 499 Messages with role 'tool' must be a response to a preceding message with 'tool_calls' (错误码: invalid_request_error) \\

Root Cause

lossless-claw compaction appears to drop assistant messages containing \ ool_calls\ while preserving the corresponding \ ool\ role messages. This creates orphaned \ ool\ messages that violate the OpenAI API message format, causing 499 errors when the reconstructed context is sent to the model API.

Environment

  • Channel: openclaw-weixin (WeChat official account)
  • Model switches: credit-based model → API-based model
  • Session scope: \per-channel-peer\ (long-lived session, same peer keeps same session)
  • lossless-claw config: \contextThreshold: 0.6, \ reshTailCount: 64\

Reproduction Steps

  1. Start a conversation on WeChat using credit-based model
  2. Have a long conversation where tool calls are made (so lossless-claw compacts history)
  3. Switch the model to an API-based model
  4. Send a message → 499 error

Expected Behavior

lossless-claw should either:

  • Keep \ ool_calls\ and \ ool\ messages together (both preserved when within freshTail), or
  • Remove both when compacting (never orphan one without the other)

Workaround

Send /reset\ before switching models to clear conversation history.

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 lossless-claw compaction breaks tool_calls/tool message chain → 499 error on model switch