Skip to content

AI_APICallError (400 Bad Request) with GitHub Copilot when MCP tool has empty description, affects claude-sonnet-4.6 / claude-opus-4.6 only #14488

@PauloDevelo

Description

@PauloDevelo

Description

Summary

When an MCP server registers a tool with an empty string description ("description": ""), OpenCode forwards that empty description to the GitHub Copilot API as-is. GitHub Copilot's API accepts this for claude-sonnet-4.5 and older models, but rejects it with 400 Bad Request for claude-sonnet-4.6 and claude-opus-4.6.

Steps to Reproduce

  1. Configure an MCP server that exposes at least one tool with "description": "" (e.g. mcp-seq — npx -y mcp-seq — whose seq_get-alertstate and seq_get-signals tools have empty descriptions)
  2. Enable the MCP server in opencode.jsonc
  3. Select github-copilot/claude-sonnet-4.6 or github-copilot/claude-opus-4.6
  4. Send any message — the call fails immediately with AI_APICallError: Bad Request

Root Cause (confirmed via curl)

GitHub Copilot's API returns 400 Bad Request when the request body contains a tool with "description": "" and the model is claude-sonnet-4.6 or claude-opus-4.6. The same request with claude-sonnet-4.5 returns 200 OK.

Minimal reproduction:

Returns 400 ❌ — empty description + claude-sonnet-4.6

curl -X POST https://api.githubcopilot.com/chat/completions
-H "Authorization: Bearer $TOKEN"
-H "Content-Type: application/json"
-d '{
"model": "claude-sonnet-4.6",
"messages": [{"role": "user", "content": "hi"}],
"tools": [{"type":"function","function":{"name":"t","description":"","parameters":{"type":"object","properties":{"x":{"type":"string"}}}}}],
"tool_choice": "auto",
"stream": true
}'

Returns 200 ✅ — non-empty description, same model

Change "description": "" to "description": "Get something"

Returns 200 ✅ — empty description, older model

Change model to "claude-sonnet-4.5"

Proposed Fix

Before sending tool definitions to any provider, OpenCode should sanitize tool descriptions: replace empty string "" with a fallback such as "No description provided" or the tool name. MCP servers are not guaranteed to provide non-empty descriptions, so this defensive normalization is necessary.

Environment

  • OpenCode version: 1.2.10
  • Provider: github-copilot
  • Failing models: claude-sonnet-4.6, claude-opus-4.6
  • Working models: claude-sonnet-4.5, GPT-4o, o3, Gemini models
  • Platform: Windows native CLI (win32), Linux (confirmed in a Podman container)
  • MCP server trigger: mcp-seq (npx -y mcp-seq)

Plugins

MCP server mcp-seq was causing me the issue

OpenCode version

1.2.10

Steps to reproduce

  1. Configure an MCP server that exposes at least one tool with "description": "" (e.g. mcp-seq — npx -y mcp-seq — whose seq_get-alertstate and seq_get-signals tools have empty descriptions)
  2. Enable the MCP server in opencode.jsonc
  3. Select github-copilot/claude-sonnet-4.6 or github-copilot/claude-opus-4.6
  4. Send any message — the call fails immediately with AI_APICallError: Bad Request

Screenshot and/or share link

No response

Operating System

Windows native CLI (win32), Linux (confirmed in a Podman container)

Terminal

Powershell

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions