Skip to content

Session corruption: 'missing tool result in session history' on long-running commands #1577

@drkraft

Description

@drkraft

Bug Description

When executing long-running commands (like clawdbot doctor), the agent session gets corrupted with:

[clawdbot] missing tool result in session history; inserted synthetic error result for transcript repair.

This breaks the agent loop and prevents any response from being sent to the user.

Steps to Reproduce

  1. Ask the agent to run clawdbot doctor (or any command that takes >10s)
  2. The command starts running in a background session (e.g., session calm-nexus)
  3. Agent calls process poll to check status
  4. Session history gets corrupted
  5. Agent fails to respond

Observed Behavior

  • The tool call is made but the result is not properly recorded
  • Clawdbot inserts a "synthetic error result for transcript repair"
  • The agent loop breaks silently - no response is sent
  • Bug reproduced multiple times in the same conversation

Expected Behavior

Long-running commands should complete and return results without corrupting the session history.

Environment

  • Clawdbot version: 2026.1.16-2
  • Channel: Telegram
  • Model: anthropic/claude-opus-4-5
  • Command: clawdbot doctor

Session transcript excerpt

07:19:32 - bash tool call: clawdbot doctor
07:19:42 - toolResult: "Command still running (session calm-nexus, pid 944829)"
07:19:46 - process poll tool call
[MISSING TOOL RESULT - session corrupted]
08:42 - User reports agent "crashed"

Workaround

None found. The bug reproduces even when trying different approaches (background execution, timeout wrapper, etc.).

Related

This may be related to how yieldMs and background process handling interacts with the transcript recording.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions