AI_APICallError: messages.1.content.2: tool_use ids must be unique #899

Open
opened 2026-02-16 17:28:42 -05:00 by yindo · 4 comments
Owner

Originally created by @esafak on GitHub (Jul 24, 2025).

Originally assigned to: @thdxr on GitHub.

I got this error after switching from one failed provider (openrouter kimi k2) to another (claude sonnet 4)

Originally created by @esafak on GitHub (Jul 24, 2025). Originally assigned to: @thdxr on GitHub. I got this error after switching from one failed provider (openrouter kimi k2) to another (claude sonnet 4)
Author
Owner

@kehanzhang commented on GitHub (Jul 24, 2025):

bump on this, I also received a similar error when switching from groq kimik2 to claude sonnet 4:

AI_APICallError: messages.1.content.1.tool_use.id: String should match pattern '^[a-zA-Z0-9_-]+$'

Was using opencode serve.

@kehanzhang commented on GitHub (Jul 24, 2025): bump on this, I also received a similar error when switching from groq kimik2 to claude sonnet 4: AI_APICallError: messages.1.content.1.tool_use.id: String should match pattern '^[a-zA-Z0-9_-]+$' Was using opencode serve.
Author
Owner

@learningbizz commented on GitHub (Oct 20, 2025):

Hey everyone, any update on this?

@learningbizz commented on GitHub (Oct 20, 2025): Hey everyone, any update on this?
Author
Owner

@rekram1-node commented on GitHub (Oct 20, 2025):

@learningbizz which one are you getting? The two comments on this issue are 2 different issues

@rekram1-node commented on GitHub (Oct 20, 2025): @learningbizz which one are you getting? The two comments on this issue are 2 different issues
Author
Owner

@9j commented on GitHub (Nov 21, 2025):

@thdxr The files at ~/.local/share/opencode/storage/part/msg**/*.json are storing callId as an empty string (""). When converting to message, content.id also becomes an empty string (""), causing an error with the Anthropic message API’s ID validation regex.

{
  "id": "prt_aa6401d920022OBPy2ay549OqK",
  "sessionID": "ses_559c2afb2ffeJiqEaco1mWqQNf",
  "messageID": "msg_aa63f58d30021OXFnXy86X99rh",
  "type": "tool",
  "callID": "",
  "tool": "invalid",
  "state": {
    "status": "completed",
    "input": {
      "tool": "edit",
@9j commented on GitHub (Nov 21, 2025): @thdxr The files at `~/.local/share/opencode/storage/part/msg**/*.json` are storing callId as an empty string (""). When converting to message, content.id also becomes an empty string (""), causing an error with the Anthropic message API’s ID validation regex. ``` { "id": "prt_aa6401d920022OBPy2ay549OqK", "sessionID": "ses_559c2afb2ffeJiqEaco1mWqQNf", "messageID": "msg_aa63f58d30021OXFnXy86X99rh", "type": "tool", "callID": "", "tool": "invalid", "state": { "status": "completed", "input": { "tool": "edit", ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#899