Skip to content

[Bug] Parallel tool_use / tool_result mismatch permanently corrupts session state #28661

Description

@Fuzzy-and-Fluffy

[Bug] Parallel tool_use / tool_result mismatch permanently corrupts session state

Description

When an agent attempts multiple concurrent tool calls, there is a race condition or mismatch where tool_result blocks do not correctly pair with their respective tool_use IDs. This mismatch can break the session's context state, causing the agent to get stuck in a loop (hallucinating, repeating previous outputs, or failing with API errors due to malformed tool sequences).

Steps to Reproduce

  1. An agent triggers multiple parallel tool calls (e.g., concurrent I/O or content extraction).
  2. The tools complete and return their results to the gateway.
  3. The gateway attempts to merge the tool_result blocks back into the session history.
  4. If a mismatch or out-of-order injection occurs, the LLM state becomes invalid.
  5. All subsequent messages to the agent result in degraded, repeated, or hallucinated responses.

Expected Behavior

The gateway should strictly validate and pair tool_use IDs with tool_result IDs, ensuring that concurrent tool executions resolve in a format compatible with the model's strict requirements for tool call sequences, without permanently corrupting the session context.

Logs / Evidence

  • Occurred multiple times (at least 3 recorded incidents on our local instance on 2026-02-27 in a multi-agent environment).
  • Affected agents: Various specialist agents during high-concurrency tasks (e.g., simultaneous file processing and API lookups).
  • Temporary workaround: Requires manually pruning or resetting the recent session context to clear the corrupted blocks.

Environment

  • OpenClaw version: 2026.2.25 (or latest)
  • Models involved: Claude 3.5 Sonnet, Claude 3 Opus
  • Platform: macOS ARM64

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions