Skip to content

AI_APICallError: tool_use ids must be unique #1150

Closed

Description

@fstau

I am repeatedly running into the following error in conversations.

Image

This usually happens in longer conversations after many rounds and I can "recover" from it by trying the compact command which then also fails with seemingly the same error, breaking the UI as well. When I then restart opencode and open the session again I can continue, but I guess technically the context is gone.

My config looks like this:

{
  "mcp": {
    "context7": {
      "type": "local",
      "command": ["npx", "-y", "@upstash/context7-mcp"],
      "enabled": true
    },
    "playwright": {
      "type": "local",
      "command": ["npx", "@playwright/mcp@latest"]
    },
    "atlassian": {
      "type": "local",
      "command": ["npx", "-y", "mcp-remote", "https://mcp.atlassian.com/v1/sse"]
    }
  },
  "$schema": "https://opencode.ai/config.json"
}

Has anyone run into this issue before as well? I am struggling to understand what I may be doing wrong.

Activity

  1. self-assigned this
    on Jul 20, 2025
  2. audibleblink commented on Jul 23, 2025

    @audibleblink

    happens to me when switching modes (that use differing models)

    1. /new
    2. run tool in a custom mode - copilot/gemini
    3. tab over to plan mode
    4. run any query, get tool_use uniqueness error
    opencode.json
    {
      "$schema": "https://opencode.ai/config.json",
      "mode": {
        "build": {
          "model": "anthropic/claude-sonnet-4-20250514"
        },
        "plan": {
          "model": "anthropic/claude-opus-4-20250514"
        },
        "serena": {
          "model": "github-copilot/gemini-2.5-pro",
          "prompt": "serena, read initial instructions when I say go, ready?"
        }
      },
      "mcp": {
        "serena": {
          "type": "local",
          "command": [
            "uvx",
            "--from",
            "git+https://github.com/oraios/serena",
            "serena-mcp-server",
            "--context",
            "ide-assistant",
            "--project",
            "."
          ],
          "enabled": true
        }
      }
    }
  3. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Contributor

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

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