Skip to content

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

Closed

Description

@esafak

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

Activity

  1. kehanzhang commented on Jul 24, 2025

    @kehanzhang
    Contributor

    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.

  2. self-assigned this
    on Jul 25, 2025
  3. learningbizz commented on Oct 20, 2025

    @learningbizz

    Hey everyone, any update on this?

  4. rekram1-node commented on Oct 20, 2025

    @rekram1-node
    Contributor

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

  5. 9j commented on Nov 21, 2025

    @9j

    @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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions