Repository navigation
fix(chat): normalize tool call arguments in assistant history - #1777
Merged
Merged
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.
历史工具调用里的
function.arguments可能是截断的 JSON。GLM 等模型的聊天模板会对它调用.items(),一条坏记录就能让后续每轮对话都构建 prompt 失败。参考 vLLM 的消息处理,在所有模型共用的模板入口逐个处理 assistant 的工具调用。对象直接传给模板,JSON 对象字符串先解析。缺失、空、截断或非对象参数按
{}渲染。异常日志只记录长度或类型。请求历史可以接收对象,OpenAI 普通响应和流式增量仍使用字符串。用官方 GLM-5.3-Flash 模板重放了 5 条原始失败请求,每条生成的完整 prompt 都与只把损坏参数替换为
{}的对照一致。工具调用、Anthropic 请求、推理参数和 DeepSeek V4 tokenizer 相关的 113 项测试通过。