Skip to content

feat(agents): execute 工具调用单独带命令行 command - #246

Merged
xiaoyumuxi merged 3 commits into
mainfrom
feat/agent-tool-command
Dec 1, 2026
Merged

xiaoyumuxi merged 3 commits into
mainfrom
feat/agent-tool-command

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

背景

桌面端 Agent 对话照 Antigravity 重做工具调用(Lithe-IDEA Issue #2599、Draft #2600):命令步骤的标题显示“已运行 <这条命令要做什么>”,展开后的命令卡片里才显示命令本身。现在 toolCall 只有一个 title,Claude Code 插件只能把它写成 Bash(ls -la),宿主拿不到“描述”和“命令”两样东西。这个 PR 给 execute 调用加一个可选的 command 字段。

改动

  • toolCall 事件新增可选 command:execute 调用实际运行的命令行(1 字节到 1 MiB,不能为空)。这时 title 写这条命令要做什么,例如 CLI 给的描述。没有 command 时宿主照旧只用标题。
  • didStart 新增 toolCommands: true:旧 Core 的 ToolCallEvent 用 deny_unknown_fields 严格解码,收到 command 会以 -32602 拒绝整批报告。所以 Core 在 didStart 里声明自己接受这个字段,后端只在看到它时才发送。
  • 记录读取:会话来源 read 函数新增可选请求参数 toolCommands,agentSessions.page 和 toolCalls 一起发送。只有这时 tool 消息才可以带 command,否则(包括旧的 agentSessions.read)以 agentSessions.invalidRead 拒绝。
  • 四语 SDK:AgentSessionStart 都新增 toolCommands(Rust tool_commands、Go ToolCommands、Java toolCommands()、Node toolCommands),类型、README 和测试同步。记录读取仍是普通 JSON 函数,不需要改 SDK。
  • 契约 README(native sessions 的通知表与 toolCall 行、记录读取一节)、fixtures/agents/native-session.json(agent-2 的 didStart 带 toolCommands,所有 start 记录都写明取值)、fixtures/agents/record-read.json(withIDs 请求带 toolCommands,结果多一条带 command 的 execute 调用)、协议更新记录同步更新。

都是 agents 0 内的补充,不升能力版本,没有新增宿主方法、通知或错误码。

原计划编号 方法 用途
API-45 agents/report(toolCall 新增 command) execute 调用单独带命令行,title 写它要做什么
API-45 agents/didStart(通知,新增 toolCommands) Core 声明接受 command,后端据此决定是否发送

验证

  • cargo test -p lithe-agent-runtime(48 个):didStart 带 toolCommands;实时 toolCall 带 command 原样到达事件,空 command 被拒绝;记录分页请求带 toolCommands,带 command 的调用原样返回,空 command、非 tool 角色上的 command 被拒绝;旧 agentSessions.read 遇到 command 被拒绝;契约样例与运行时一致。
  • cargo fmt --all -- --check、cargo clippy -p lithe-agent-runtime --all-targets -- -D warnings
  • SDK:Rust cargo test --test agents、Go go test ./lithe/、Node npm test + npm run test:types、Java mvn -pl plugin-sdk test -Dtest=AgentsTest
  • node shared/plugins/scripts/verify-docs.mjs、node shared/plugins/scripts/sdk-e2e.mjs

后续

  • AI 插件(lithe-ai-plugins)的 Claude Code、Codex 后端在看到 toolCommands 时发送 command,另开 PR。
  • 桌面端 #2600 临时固定这个 PR 的 head 提交;合入后换成 main 提交。

toolCall 事件新增可选 command(1 字节到 1 MiB),title 写命令要做什么;
Core 在 didStart 和记录分页读取里发 toolCommands: true,后端看到才发送,
旧 Core 严格解码不受影响。四语 SDK 的 AgentSessionStart 新增 toolCommands,
契约 README、样例和协议更新记录同步。
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review December 1, 2026 14:02
@xiaoyumuxi
xiaoyumuxi merged commit dab7841 into main Dec 1, 2026
9 of 11 checks passed

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

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