Skip to content

[BUG][ANALYSIS] Missing Tool Result Blocks Interrupting Workflow Execution #5374

@almirsarajcic

Description

@almirsarajcic

Bug Description
The workflow stops for no reason. When I try to write a follow-up prompt, it reveals the "tool_use ids were found without tool_result blocks" error message. It prevents me from creating a truly autonomous workflow.

Environment Info

  • Platform: darwin
  • Terminal: cursor
  • Version: 1.0.71
  • Feedback ID: de619269-71e4-4a2d-8057-3df7bf61893e

Errors

[
  {
    "error": "Error: Request was aborted.\n    at new sW (unknown:1:28)\n    at new qY (/$bunfs/root/claude:876:1853)\n    at new sJ (/$bunfs/root/claude:876:2641)\n    at _createMessage (/$bunfs/root/claude:884:7955)\n    at processTicksAndRejections (native:7:39)",
    "timestamp": "2025-08-08T05:16:28.686Z"
  },
  {
    "error": "Error: Request was aborted.\n    at new sW (unknown:1:28)\n    at new qY (/$bunfs/root/claude:876:1853)\n    at new sJ (/$bunfs/root/claude:876:2641)\n    at makeRequest (/$bunfs/root/claude:893:3652)\n    at processTicksAndRejections (native:7:39)",
    "timestamp": "2025-08-08T05:23:21.851Z"
  },
  {
    "error": "Error: Error POSTing to endpoint (HTTP 404): Session not found\n    at send (/$bunfs/root/claude:903:25507)\n    at processTicksAndRejections (native:7:39)",
    "timestamp": "2025-08-08T05:24:27.196Z"
  },
  {
    "error": "Error: Error POSTing to endpoint (HTTP 404): Session not found\n    at send (/$bunfs/root/claude:903:25507)\n    at processTicksAndRejections (native:7:39)",
    "timestamp": "2025-08-08T05:24:33.294Z"
  },
  {
    "error": "Error: Error POSTing to endpoint (HTTP 404): Session not found\n    at send (/$bunfs/root/claude:903:25507)\n    at processTicksAndRejections (native:7:39)",
    "timestamp": "2025-08-08T05:24:38.025Z"
  },
  {
    "error": "Error: Error POSTing to endpoint (HTTP 404): Session not found\n    at send (/$bunfs/root/claude:903:25507)\n    at processTicksAndRejections (native:7:39)",
    "timestamp": "2025-08-08T05:24:42.410Z"
  },
  {
    "error": "Error: Error POSTing to endpoint (HTTP 404): Session not found\n    at send (/$bunfs/root/claude:903:25507)\n    at processTicksAndRejections (native:7:39)",
    "timestamp": "2025-08-08T05:25:21.031Z"
  },
  {
    "error": "Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.28: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_018Ynj1mexLmRjfnRN5A3LHY. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"}}\n    at new sW (unknown:1:28)\n    at new qY (/$bunfs/root/claude:876:1853)\n    at new ZW0 (unknown:1:28)\n    at generate (/$bunfs/root/claude:876:2310)\n    at makeRequest (/$bunfs/root/claude:893:5330)\n    at processTicksAndRejections (native:7:39)",
    "timestamp": "2025-08-08T05:31:57.165Z"
  }
]

Analysis

Environment Coverage

Platform/Terminal/Version combinations affected:

  • macOS: Apple Terminal (v1.0.62-64), Cursor (v1.0.67), iTerm.app (v1.0.51-59), VSCode
    (v1.0.35-61), IntelliJ (v1.0.62), Warp (v1.0.53-55), ghostty (v1.0.53)
  • Linux: GNOME terminal (v1.0.62-70), Konsole (v1.0.61), VSCode (v1.0.35-53), WSL-Archlinux
    (v1.0.64)
  • Windows: WSL Ubuntu + ZSH (v1.0.55), VSCode Integrated Terminal via WSL

Trigger Scenarios

When the error occurs:

  • During API request timeouts (6/10 retry attempts)
  • After workflow interruptions or unexpected CLI termination
  • When processing files (PDF, markdown, large files >25,000 tokens)
  • During tool use operations that get interrupted
  • After auto-upgrading to newer versions (specifically v1.0.55)
  • When sessions exceed ~2,400 tokens during compaction
  • During endpoint testing with Swagger
  • After git push operations with long request URLs

Key Insights

  • Core Issue: API validation error requiring each tool_use block to have immediate corresponding
    tool_result block
  • Version Range: Affects versions from 0.2.14 through 1.0.71+ (widespread across all recent versions)
  • Root Cause: Recent API changes made tool_use/tool_result block ordering requirements stricter
  • Session Recovery: Error makes conversations unrecoverable, requiring complete restart
  • Pattern: Consistently results in 400 Bad Request with identical error message
  • Platform Impact: Primarily affects macOS users but occurs across all platforms
  • Keychain Issues: Frequently accompanied by macOS keychain access failures
  • Token Limits: Related to MaxFileReadTokenExceededError (41,425 tokens vs 25,000 limit)
  • Timing Sensitivity: Often occurs when messages are sent at critical moments during tool execution
  • Message Ordering: Issue stems from non-standard ordering of tool_use and tool_result blocks in API messages

Workarounds

For Users:

  • Session Recovery: Edit ~/.claude/projects/[PROJECT]/[LATEST-SESSION-STORE].json and remove problematic message lines
  • Export/Restart: Export chat → clear conversation → restart CLI → reload exported file
  • Use offset/limit parameters for large files
  • Use GrepTool instead of reading entire files
  • VPN if ISP blocking suspected

For Developers:

Reference Issues

Most Comprehensive Issues:

Duplicate Issues (46):

Related Issues (9):

Metadata

Metadata

Assignees

No one assigned

    Labels

    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