When an assistant message is aborted mid-stream (e.g., after context compaction at 200k tokens), the toolCall blocks with partialJson get persisted to the session JSONL. OpenClaw's repair mechanism inserts synthetic tool_result entries for these. But at API call time, transformMessages() drops the aborted assistant entirely (stopReason === "aborted") while keeping the synthetic tool_result — creating orphaned results that make every subsequent API call fail with unexpected tool_use_id.
Stream abort (pi-ai/anthropic.js)