#1638·jcode

Orphaned web_search server_tool_use in history causes permanent 400 (session unrecoverable)

Author: timorungeCreated Oct 1, 2026Updated Oct 1, 2026

Summary

A session's history ends up with a server-side web_search tool use that has no matching web_search_tool_result. From then on, every request to Anthropic fails with 400, and the session cannot continue. It happened early in the session (messages.5), so there was nothing to compact, and clearing the session was the only way out.

Error

Anthropic API error (400 Bad Request): {"type":"error","error":{"type":"invalid_request_error","message":"messages.5: `web_search` tool use with id `srvtoolu_017Bq7tKmKKZJbMjWQucjurZ` was found without a corresponding `web_search_tool_result` block"}}

Context

  • Long-running swarm session on the Anthropic provider, with provider-native web search (likely related to #1620).
  • Probably caused by an interrupted turn, or one cut mid-stream, that contained a server_tool_use.

Expected

When history is saved, loaded or compacted, an orphaned server_tool_use is either dropped or paired with an error result, so the session recovers on its own.

Environment

  • jcode v0.90.0 (a7f005e8c), installed from the stable channel (~/.jcode/builds/versions/0.90.0)
  • macOS 26.6.2, arm64
  • Provider: Anthropic, with provider-native web_search enabled
  • Session: a swarm lane in a multi-session swarm (several sessions on one shared jcode server); agents.swarm_model = "claude-sonnet-5"