[Bug] Task resume fails with 400 error after subagent uses tools (tool_use_id mismatch)

Resolved 💬 3 comments Opened Dec 10, 2025 by leiha Closed Dec 14, 2025

Description

When using Task(resume="agentId") to continue a conversation with a subagent, the API returns a 400 error if the subagent's previous response included tool usage (Read, Bash, etc.).

Steps to Reproduce

  1. Call a subagent with tools enabled:
Task(subagent_type="my-agent", prompt="Test")
// Returns agentId: "abc123"
  1. Resume without the agent using tools - works:
Task(resume="abc123", prompt="Reply with text only")
// Works fine
  1. Ask the agent to use a tool:
Task(resume="abc123", prompt="Use Read to check a file")
// Agent uses Read tool, returns result
  1. Resume again - fails:
Task(resume="abc123", prompt="What did you find?")
// ERROR 400

Error Message

API Error: 400 
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "messages.0.content.0: unexpected `tool_use_id` found in `tool_result` blocks: toolu_01MoydgNWBsodohnE3rWiKvG. Each `tool_result` block must have a corresponding `tool_use` block in the previous message."
  }
}

Expected Behavior

Resume should work regardless of whether the subagent used tools in previous turns. The conversation history should be correctly serialized/deserialized.

Actual Behavior

After a subagent uses any tool (Read, Bash, Glob, etc.), all subsequent resume calls fail with a 400 error about mismatched tool_use_id / tool_result blocks.

Environment

  • Claude Code version: Latest (December 2025)
  • OS: Linux
  • Model: claude-opus-4-5-20250514

Workaround

Currently, the only workaround is to:

  1. Not use resume with agents that have tools
  2. Pass context manually in each prompt instead of relying on resume

Related Issues

  • #8763 (tool use concurrency) - similar but different root cause
  • #265 (hook denial causes 400) - related to tool_use/tool_result handling

Impact

This prevents building stateful multi-turn agent workflows where the orchestrating agent needs to use tools to verify work.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗