Skip to content

fix(openai): add omitempty to chatFunction description/parameters#5020

Merged
SivanCola merged 2 commits into
esengine:main-v2from
eghrhegpe:pr-fix-openai-omitempty
Jun 22, 2026
Merged

fix(openai): add omitempty to chatFunction description/parameters#5020
SivanCola merged 2 commits into
esengine:main-v2from
eghrhegpe:pr-fix-openai-omitempty

Conversation

@eghrhegpe

@eghrhegpe eghrhegpe commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

问题

opencode.ai 等网关对工具定义有严格的 JSON schema 校验。Reasonix 发送的 chatFunction 始终包含 description: ""parameters: null,在某些网关上导致:

Failed to deserialize the JSON body into the target type: tools[0].function: missing field `name`

修复

chatFunctionDescriptionParameters 字段加上 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

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development provider Model providers & selection (internal/provider) labels Jun 22, 2026
@SivanCola SivanCola merged commit b535111 into esengine:main-v2 Jun 22, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

provider Model providers & selection (internal/provider) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants