Skip to content

fix(assistant): deduplicate and sort submit_assistant_reply tool enum - #1755

Open
newexploreor wants to merge 1 commit into
mainfrom
fix/submit-assistant-reply-enum-dedup
Open

newexploreor wants to merge 1 commit into
mainfrom
fix/submit-assistant-reply-enum-dedup

Conversation

@newexploreor

Copy link
Copy Markdown
Collaborator

背景

关联: #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.go
    • 构造 drafts[].tool.enum 时进行去重,仅在缺失时补充 assistant_tasks_save;
    • 对 assistantWriteToolNameList() 与最终 enum 按字典序排序,确保 JSON Schema 输出确定。
  • internal/httpapi/agent_tool_native_terminal_test.go
    • 新增 TestSubmitAssistantReplySchemaEnumUniqueAndSorted,递归校验全部终态工具(AgentToolReport / AgentToolClarify / AgentToolAssistant)所有执行模式下 Schema 中每个 enum 无重复项,并校验 drafts[].tool.enum 仅包含一次 assistant_tasks_save 且有序。

验证

  • go vet ./internal/httpapi
  • go test ./internal/httpapi -run 'TestSubmitAssistantReply|TestAgentTool|TestAssistantProposal|TestAssistantTaskDraft' -count=1

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant