fix(opencode): prevent Copilot 400 when tool description is empty#14647
Open
amsminn wants to merge 1 commit intoanomalyco:devfrom
Open
fix(opencode): prevent Copilot 400 when tool description is empty#14647amsminn wants to merge 1 commit intoanomalyco:devfrom
amsminn wants to merge 1 commit intoanomalyco:devfrom
Conversation
c3cafe6 to
4582f5a
Compare
c5725f1 to
6e34c95
Compare
d885156 to
b5a48a8
Compare
This was referenced Mar 2, 2026
Closed
bfb9011 to
f90ffb2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #14488
Type of change
What does this PR do?
Fixes Copilot request validation failure when an MCP/OpenAI-compatible tool has an empty description.
Sending
tools[].function.description: ""to Copilot Chat Completions returnsHTTP 400 Bad Request(reproduced on 2026-02-22), while omittingfunction.descriptionreturnsHTTP 200. Because the field is optional in Copilot SDK types, this PR normalizes empty/whitespace descriptions toundefined(field omission) instead of injecting synthetic text likeNo description. This keeps the original tool meaning and removes the 400 failure:Tool.description?: stringhttps://github.com/github/copilot-sdk/blob/main/nodejs/src/types.ts#L144
defineTool(..., { description?: string, ... })https://github.com/github/copilot-sdk/blob/main/nodejs/src/types.ts#L158
This PR omits empty/whitespace
function.descriptionvalues and adds two tests.Changed code:
packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts:53packages/opencode/test/provider/copilot/copilot-chat-model.test.ts:591packages/opencode/test/provider/copilot/copilot-chat-model.test.ts:596How did you verify your code works?
Verification date: 2026-02-22
claude-sonnet-4.6,stream=true):function.description=""->HTTP 400(Bad Request)function.descriptionomitted ->HTTP 200(SSE stream starts)bun test test/provider/copilot/copilot-chat-model.test.ts(run frompackages/opencode)13 pass, 0 failScreenshots / recordings
N/A - no UI change.
Checklist