Repository navigation
Conversation
…d or malformed tool call
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.
问题
模型把工具调用块写坏、或者写出了官网内置工具的调用(例如
google:search)时,ToolBridge.Parse直接返回错误,stream.go把它转成 502,整条已经产出正文的请求被判失败,before正文被丢弃。实测(v0.2.0):
影响:
改动
把「解析失败」从致命错误降级为「丢弃该调用块、按正文结束」,但只在请求没有强制工具调用时:
tool_choiceauto/ 未设置before正文(新增 WARN 日志)required/anyfunction:<name>(指定函数)nonebefore为空测试
新增
TestToolBridgeToleratesInvalidCalls(internal/adapter/tool_protocol_test.go)。先在未打补丁的代码上确认它会失败:打补丁后通过,且原有 6 个工具协议用例、
go test ./...全绿。覆盖场景:auto 下未声明/写坏均按正文返回;
required与指定工具仍报错;调用块前无正文仍报错;合法调用照常解析。兼容性
required/指定函数语义;