CLIProxyAPI icon indicating copy to clipboard operation
CLIProxyAPI copied to clipboard

devin/swe-2 with claude code: tool_use IDs incompatible with Anthropic models ("400 messages.2.content.1.tool_use.id: String should match pattern")

Open intelligentpotato opened this issue 1 month ago • 0 comments

Describe the bug API Error: 400 messages.2.content.1.tool_use.id: String should match pattern '^[a-zA-Z0-9_-]+$'

When a Claude Code session runs on devin/swe-2, the connector assigns tool_use / tool_result IDs of the form <ToolName>:<counter>#<32-hex>, e.g. PowerShell:66#cd50350578c34275a26a09a477a81ffb. The : and # are not allowed by the Anthropic Messages API, whose tool-call IDs must match ^[a-zA-Z0-9_-]+$. The IDs are accepted while the session runs on the Devin provider, but Claude Code persists them into the session transcript. As soon as the session is resumed on an Anthropic model — e.g. devin/swe-2 is no longer available and Claude Code falls back to Opus, or the user switches model — Claude Code replays the stored history to the Anthropic API and every request fails.

It fails on every prompt, including "hello", because the rejection is of the replayed history, not the new input. The session becomes permanently unresumable on any Anthropic model.

Environment

  • Claude Code 2.1.294 (session originally created on 2.1.292)
  • OS: Windows 11
  • Model id: devin/swe-2

Steps to reproduce

  1. Run a Claude Code session on devin/swe-2 and let it make several tool calls.
  2. Switch the session to an Anthropic model.
  3. Send any prompt → the 400 above.

Root cause (observed)

The tool-call IDs minted on the devin/swe-2 path are <ToolName>:<N>#<32-hex>:

  • Write:1#e1f0da81143649f3a378d24af6fc3ec9
  • PowerShell:66#cd50350578c34275a26a09a477a81ffb
  • Bash:21#6bd25748994e4ff7b8e79c69ec9f8b88

The : and # violate ^[a-zA-Z0-9_-]+$. In one real session this produced 10,421 non-conforming IDs across the transcript (both the id on tool_use blocks and the tool_use_id on tool_result blocks).

Other models routed through the same connector produce VALID IDs and resume fine, so only the devin/swe-2 id construction is affected:

  • devin/gpt-5-5, devin/gpt-6-1-sol: call_8jAZYBK5veMdr1DD2DqObARK
  • devin/glm-5-3: chatcmpl-tool-8fae1891215eca24

Suggested fix

Emit tool_use IDs that match ^[a-zA-Z0-9_-]+$. Simplest options:

  • replace : and # with _ (PowerShell:66#... → PowerShell_66_...), or
  • reuse the call_<id> scheme the other dev

Either keeps IDs portable across providers and lets sessions resume on Anthropic models.

intelligentpotato avatar Oct 09 '26 02:10 intelligentpotato