xiaozhi-esp32-server/main/xiaozhi-server
Brad Shannon 31cc365fcd fix(core): guard orphan tool messages in dialogue serialization
The intent REQLLM path (core/handle/intentHandler.py) records a tool result via
`Message(role="tool", content=text)` with no tool_call_id and no preceding
assistant tool_calls. `Dialogue.getMessages` serializes it as a function_response
anyway. When that history is later replayed to an OpenAI-compatible endpoint,
the endpoint derives `function_response.name` by matching the tool_call_id back
to a function_call; with no match the name is empty.

gemini-2.5-flash tolerated the empty name, but gemini-3.5-flash rejects the whole
request with HTTP 400 "GenerateContentRequest.contents[N].parts[0]
.function_response.name: Name cannot be empty", so every affected turn falls back
to "Sorry, the system is busy now." Only tool-using sessions and only the chat
turns that replay the accumulated tool results were affected.

Guard at the serialization boundary in `getMessages`: emit a role="tool" message
as a function_response only when a preceding assistant message carries a matching
tool_call id; otherwise demote it to a plain assistant context line so the turn
survives. Valid tool-call pairs — including empty-string ids that still match —
are unchanged. This defends against any orphan source, not just the intent path.

Adds self-contained regression tests (no conftest required).
2026-07-14 16:09:00 -04:00
..
config Merge pull request #3271 from xinnan-tech/py-fix-bug 2026-07-09 15:36:59 +08:00
core fix(core): guard orphan tool messages in dialogue serialization 2026-07-14 16:09:00 -04:00
models 重新划分目录 (#214) 2025-03-05 23:13:24 +08:00
music 重新划分目录 (#214) 2025-03-05 23:13:24 +08:00
performance_tester update:解决base类修改后测速工具兼容性问题 2026-04-27 15:06:40 +08:00
plugins_func 同步工具异步化处理 2026-07-07 14:45:50 +08:00
test fix(core): guard orphan tool messages in dialogue serialization 2026-07-14 16:09:00 -04:00
agent-base-prompt.txt fix: 2026-07-08 16:14:10 +08:00
app.py fix: 消除死锁隐患 2026-07-09 10:29:41 +08:00
config.yaml fix: allow configuring FunASR recognition language 2026-06-29 20:58:51 +00:00
config_from_api.yaml fix:修复全模块时缺少prompt_template配置的问题 2025-10-31 20:36:55 +08:00
docker-compose.yml fix: 设备最后连接时间返回 UTC 时间戳,修复时区显示问题 2026-05-27 17:35:10 +08:00
docker-compose_all.yml update:增加ragflow部署教程 2025-11-11 18:47:25 +08:00
mcp_server_settings.json update:服务端MCP新增支持Streamable HTTP传输协议 2025-10-29 23:14:42 +08:00
performance_tester.py update:优化测试工具目录结构 2025-08-16 10:09:36 +08:00
requirements.txt update:更新sherpa_onnx依赖至1.12.29版本 2026-03-16 11:43:07 +08:00