fix(coderd/x/chatd): normalize nil MCP tool properties to empty object#27438
Open
rodmk wants to merge 1 commit into
Open
fix(coderd/x/chatd): normalize nil MCP tool properties to empty object#27438rodmk wants to merge 1 commit into
rodmk wants to merge 1 commit into
Conversation
Zero-argument MCP tools whose input schema omits "properties" reach the OpenAI function schema as "properties": null, which OpenAI rejects with "None is not of type 'object'" (HTTP 400). Anthropic-backed chats are unaffected because they do not strict-validate the schema. Coerce a nil parameter map to an explicit empty object at the provider boundary in buildToolDefinitions and at the source in the MCP tool wrapper's Info, covering both the plain and model_intent-wrapped schema paths. This mirrors the guard already merged for the sibling "required" field. Refs coder#27252 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rodmk
marked this pull request as ready for review
July 22, 2026 22:01
1 task
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.
Zero-argument MCP tools whose input schema omits
propertiesreach the OpenAI function schema as"properties": null, which OpenAI rejects withInvalid schema for function '<tool>': None is not of type 'object'(HTTP 400) before the tool executes. Anthropic-backed chats are unaffected because they do not strict-validate the schema, so the same tool works on Sonnet but fails on GPT.This is the object-valued counterpart of the already-merged
requiredfix (#23538): an absent or nil parameter map is passed straight through and serializes tonullinstead of{}.Fix
Coerce a nil parameter map to an explicit empty object in two places:
buildToolDefinitions(coderd/x/chatd/chatloop/chatloop.go) — the provider boundary that everyAgentTool(MCP, built-in, and dynamic tools) passes through.mcpToolWrapper.Info(coderd/x/chatd/mcpclient/mcpclient.go) — normalizes at the source and additionally covers the nested schema built whenmodel_intentwrapping is enabled, which the boundary fix cannot reach.This mirrors the guard already merged for the sibling
requiredfield.Refs #27252
Verification
Added regression tests in both packages using a zero-argument tool whose schema omits
properties(plain andmodel_intentvariants). Each test fails without the guard (parameters come backnil, serializing tonull) and passes with it.Confirmed the same two tests fail on the unpatched tree (
Parameters should never be nil/properties should never be nil).golangci-lint run,paralleltestctx, andgo vetare clean on both packages; fullmcpclientandchatlooppackage suites pass, including under-race.AI disclosure
This change was authored with AI assistance (Claude Code) per the repository's AI contribution guidelines. The diff, test design, and verification above were reviewed manually by the submitter.
🤖 Generated with Claude Code