fix: handle nested function tool names#73
Open
bigwolftime wants to merge 1 commit into
Open
Conversation
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 -> sub2api -> Moon Bridge -> DeepSeek 的调用链路中,DeepSeek 返回 400:
排查发现,Moon Bridge 在处理 OpenAI Responses 请求里的 tools 时,只读取了 Responses 风格的顶层字段:
{ "type": "function", "name": "get_weather", "parameters": {} }但实际链路里可能会收到 Chat Completions 风格的嵌套 function 工具定义:
{ "type": "function", "function": { "name": "get_weather", "description": "Get the weather", "parameters": {} } }由于原 DTO 没有 function 字段,转换到 CoreTool 时 Name 会变成空字符串,随后 Anthropic adapter 会把这个空工具名继续转发给 DeepSeek,最终触发上游 400。
修改内容
影响范围
该修改主要提升 OpenAI Responses 入站兼容性,允许 Moon Bridge 接收 Chat Completions 风格的嵌套 function tool 定义。
对原有顶层 name / description / parameters 的 Responses 风格工具定义保持兼容;如果工具名称为空,会被过滤,不再传递给 Anthropic/DeepSeek 上游。