fix(openai): add omitempty to chatFunction description/parameters#5020
Merged
Conversation
…fix strict gateway rejection
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.
问题
opencode.ai 等网关对工具定义有严格的 JSON schema 校验。Reasonix 发送的
chatFunction始终包含description: ""和parameters: null,在某些网关上导致:修复
给
chatFunction的Description和Parameters字段加上json:",omitempty"。空值不再序列化,减少 JSON 体积同时兼容严格网关。正常工具 schema 会继续通过
CanonicalizeSchema发送,不会牺牲 DeepSeek、MiniMax、MiMo 等 OpenAI-compatible 主供应商的工具调用。文件
internal/provider/openai/openai.go (+2/-2)
internal/provider/openai/openai_test.go (+32)
Cache-impact: low - OpenAI-compatible tool schema bytes change only when a tool has empty description or nil parameters; normal canonicalized tool schemas remain present.
Cache-guard: TestBuildRequestOmitsEmptyToolDescriptionAndParameters plus
go test ./internal/provider/openai ./internal/provider