Repository navigation
fix(assistant): deduplicate and sort submit_assistant_reply tool enum - #1755
Open
newexploreor wants to merge 1 commit into
Open
newexploreor wants to merge 1 commit into
newexploreor wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
背景
关联: #1578 #1349
assistant_tasks_save已在application.PublicOperations()中注册为非只读操作,因此assistantWriteOperations已包含该工具名。submitAssistantReplySchema在遍历assistantWriteToolNameList()后又无条件append(enum, "assistant_tasks_save"),导致submit_assistant_reply的 JSON Schema 中drafts[].tool.enum出现重复项,严格校验 JSON Schema 的客户端(如 Kimi CLI)会拒绝整个工具定义。此外,assistantWriteToolNameList()遍历 map 未排序,枚举顺序也不稳定。改动
internal/httpapi/agent_tool_terminal.godrafts[].tool.enum时进行去重,仅在缺失时补充assistant_tasks_save;assistantWriteToolNameList()与最终enum按字典序排序,确保 JSON Schema 输出确定。internal/httpapi/agent_tool_native_terminal_test.goTestSubmitAssistantReplySchemaEnumUniqueAndSorted,递归校验全部终态工具(AgentToolReport/AgentToolClarify/AgentToolAssistant)所有执行模式下 Schema 中每个enum无重复项,并校验drafts[].tool.enum仅包含一次assistant_tasks_save且有序。验证
go vet ./internal/httpapigo test ./internal/httpapi -run 'TestSubmitAssistantReply|TestAgentTool|TestAssistantProposal|TestAssistantTaskDraft' -count=1