fix: filter empty tool names in responses API path#87
Open
Danielybw wants to merge 1 commit into
Open
Conversation
Add filterEmptyCoreToolNames() to filter tools with empty names after ToCoreRequest conversion in handleWithAdapters. Root cause: Codex desktop sometimes sends tools with empty names that upstream APIs (DeepSeek, Qwen) reject with a 400 error. The existing filterEmptyToolNames() only worked for chat completions path (ChatTool type). This fix adds a parallel filter for CoreTool type used in the responses API path.
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.
问题
Codex desktop 有时会发送包含空名称工具的工具列表,上游 API(DeepSeek、Qwen)严格校验会拒绝,导致 502 错误:
根因
现有的
filterEmptyToolNames()只在 chat completions 路径(处理ChatTool类型)生效,但 responses API 路径(handleWithAdapters)使用CoreTool类型,没有过滤空名称工具。修复
filterEmptyCoreToolNames()函数,在ToCoreRequest转换后过滤CoreTool列表中的空名称工具变更文件
internal/service/server/adapter_dispatch.go: 在 responses API 路径调用过滤函数internal/service/server/filter_empty_tools.go: 新增过滤函数实现internal/service/server/filter_empty_tools_test.go: 新增单元测试测试
go test ./internal/service/server -run TestFilterEmptyCoreToolNames -v所有测试用例通过: