Repository navigation
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.
变更摘要
修复非流式
/v1/chat/completions经 Responses 兼容转换时丢失函数调用的问题。v0.6.4 的上游即使返回function_call,客户端仍会收到空的 assistant 文本、没有tool_calls,且finish_reason为stop,导致工具执行循环提前结束。转换现在保留全部函数调用的 ID、名称和参数,并使用
finish_reason: "tool_calls"。仅有工具调用时,message.content为null;同时存在文本时保留文本。沿用现有工具名称还原映射。复现方式
在启用了 Responses-to-Chat 兼容转换的网关上,发送非流式 Chat 请求;模型名称替换为网关中可用的模型:
{ "model": "<available-model>", "stream": false, "messages": [{"role": "user", "content": "Call echo_probe with value ok."}], "tools": [{ "type": "function", "function": { "name": "echo_probe", "description": "Echo a harmless test value.", "parameters": { "type": "object", "properties": {"value": {"type": "string"}}, "required": ["value"], "additionalProperties": false } } }], "tool_choice": {"type": "function", "function": {"name": "echo_probe"}} }当上游 Responses 输出包含如下条目时:
{"type":"function_call","call_id":"call_echo","name":"echo_probe","arguments":"{\"value\":\"ok\"}"}修复前没有
message.tool_calls,且结束原因为stop;修复后返回对应的tool_calls[0],id为call_echo,结束原因为tool_calls。本补丁也覆盖上游 SSE 汇总为非流式 JSON 的路径。改动范围
主要文件
crates/service/src/gateway/observability/http_bridge/body_conversion.rs:传递工具名称还原映射,将 Responsesfunction_call转为 Chattool_calls。crates/service/src/gateway/observability/http_bridge/delivery_tests.rs:新增并行工具调用、名称还原、文本与工具共存、SSE 汇总后纯工具调用的回归测试;调整现有调用点。验证
pnpm -C apps run testpnpm -C apps run buildpnpm -C apps run test:uicargo test --workspace已执行的实际验证(Windows x86_64 GNU,v0.6.4 + 本补丁):
已用编译后的服务完成无业务副作用的 echo 工具往返验证:非流式 Chat 返回工具调用,提交对应工具结果后模型正常完成回答。
未执行前端和完整 workspace 测试:改动仅涉及 HTTP bridge 的两个 Rust 文件,已运行相关回归集和服务 release 构建。
风险与影响面
call_id,缺失时兼容id;参数保留原始字符串。f14bd735dca9203d7430958480b82ba7713641a9,这两个文件仍与 v0.6.4 相同。备注
复现数据为合成测试数据,不包含部署凭据或业务数据。