Skip to content

Tool results intermittently lost - 'missing tool result in session history' transcript repair #15008

@sekhri

Description

@sekhri

Bug Description

Tool results are intermittently not persisted to the session JSONL file. When the session is reloaded for the next API call, OpenClaw detects an orphaned tool_use without a matching tool_result and injects a synthetic error: [openclaw] missing tool result in session history; inserted synthetic error result for transcript repair.

Impact

  • User sees no response after a tool call — has to ask again
  • Happens on trivial tools (file reads, simple shell commands) — not tool-specific
  • Occurs 3-5 times per session in active use
  • Makes the assistant unreliable for any tool-dependent workflow

Environment

  • OpenClaw version: 2026.2.9
  • OS: macOS (Darwin 24.6.0, arm64)
  • Node: v25.6.0
  • Channel: Telegram
  • Model: anthropic/claude-opus-4-6

Reproduction

  1. Have an active Telegram DM session
  2. Send messages that trigger tool calls (e.g. exec, read, cron)
  3. Intermittently, the tool result is lost and the synthetic error appears
  4. No response is delivered to the user

Observations

  • Happens even when no concurrent activity (no heartbeat, no cron jobs running)
  • Happens on the simplest possible tool calls (e.g. ls | wc -l)
  • Frequency seems to increase with session length/activity
  • Compaction mode is safeguard with memoryFlush: enabled
  • Session file is JSONL — the tool_use line is written but the tool_result line is not persisted

Suspected Cause

The JSONL append for tool_result is not reliably flushed to disk before the session is read for the next turn. Could be:

  • Missing fsync / write not awaited before proceeding
  • Stream buffering in Node.js file writer
  • Race condition if compaction or another process reads the file before the write completes

Workaround

None reliable. User must re-send their message to retry.

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