Skip to content

fix(openai): restore API-key custom tool calls - #5661

Merged
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
wucm667:fix/issue-5659-openai-custom-tools
Aug 18, 2026
Merged

fix(openai): restore API-key custom tool calls#5661
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
wucm667:fix/issue-5659-openai-custom-tools

Conversation

@wucm667

@wucm667 wucm667 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

问题

OpenAI 平台 API-key 原生 /v1/responses 路径未适配 Codex 的 custom/freeform 工具,上游返回对象参数后会导致 apply_patchinvoked with incompatible payload

根因

该路径未复用已有 Responses 客户端工具适配器,既没有在请求侧把 custom 工具降级为 function,也没有在流式/非流式响应侧恢复为 custom_tool_call 的字符串 input

改动

  • 仅在 OpenAI API-key 非 compact 请求确实包含客户端专用工具时启用适配
  • 请求侧复用共享适配器降低 custom 工具;响应侧恢复流式和非流式工具调用
  • 每次账号尝试清理映射状态,避免 failover 污染;保留 namespace-only 透传;拒绝尾随 JSON 数据
  • 增加 custom 工具、namespace 保持、状态清理和非法 JSON 回归测试

测试

  • go test -tags=unit ./internal/service -run 'Test(OpenAIPassthroughAPIKeyRestoresClientTools|AdaptOpenAIResponsesClientTools|ClearOpenAIResponsesClientToolMapping|OpenAIGatewayServiceForward_AccountPolicyStripsImageNamespaceTools)' -count=1
  • go test -json -tags=unit ./internal/service -count=1
  • go vet -tags=unit ./internal/service
  • git diff --check

Fixes #5659

@Wei-Shaw
Wei-Shaw merged commit 58ea46e into Wei-Shaw:main Aug 18, 2026
8 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 18, 2026
@wucm667
wucm667 deleted the fix/issue-5659-openai-custom-tools branch August 18, 2026 12:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants