Repository navigation
feat: add Agent Team experimental feature for parallel sub-agent coordination #2886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 29 commits
16ea312
fa9efe9
3e21a1d
bb32211
0468e20
9c1199a
011b250
ce321de
638a739
f4582d6
53883cd
4188d5d
8ea7549
4a86ae9
34f7831
99177ac
c663b83
48ed14a
4820da6
0df90cf
52444cd
ebec078
7c0d151
9cfbd16
a874777
49a76cb
340b3cf
50f58bf
921cda7
5ad0b92
832e64a
bb92b83
a9d6246
bb32865
73b9877
edade76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ import type { | |
| ToolExecuteConfirmationDetails, | ||
| ToolMcpConfirmationDetails, | ||
| ApprovalMode, | ||
| TeammateApprovalRequestEvent, | ||
| ToolConfirmationPayload, | ||
| } from '@qwen-code/qwen-code-core'; | ||
| import { | ||
| InputFormat, | ||
|
|
@@ -378,6 +380,79 @@ export class PermissionController extends BaseController { | |
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Handle a teammate tool approval request routed via the | ||
| * TEAMMATE_APPROVAL_REQUEST team event. Stream-json only — | ||
| * non-stream-json sessions handle teammate approvals directly | ||
| * in `nonInteractiveCli.ts` (mode-aware fallback that warns on | ||
| * stderr and cancels). The caller in nonInteractiveCli only | ||
| * forwards events here when `options.controlService` is set, | ||
| * which is itself stream-json-only. Defensive guard remains | ||
| * in case that contract is ever broken. | ||
| */ | ||
| async handleTeammateApproval( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Critical] 整个 这是 teammate 唯一的 interactive 审批入口,回归一旦发生就是「所有 teammate 的工具调用都拿不到批准」,影响面巨大。建议在合并前补一组用 fake
— Opus 4.7 via Claude Code /review |
||
| event: TeammateApprovalRequestEvent, | ||
| ): Promise<void> { | ||
| try { | ||
| if (this.context.abortSignal?.aborted) { | ||
| await event.respond(ToolConfirmationOutcome.Cancel); | ||
| return; | ||
| } | ||
|
|
||
| const inputFormat = this.context.config.getInputFormat?.(); | ||
| if (inputFormat !== InputFormat.STREAM_JSON) { | ||
| // Should not happen under the current wiring; cancel | ||
| // safely rather than silently auto-proceeding. | ||
| await event.respond(ToolConfirmationOutcome.Cancel); | ||
| return; | ||
| } | ||
|
|
||
| // Stream-json mode: ask SDK for permission. | ||
| const callId = `teammate-${event.teammateName}-${event.timestamp}`; | ||
| const response = await this.sendControlRequest( | ||
| { | ||
| subtype: 'can_use_tool', | ||
| tool_name: event.toolName, | ||
| tool_use_id: callId, | ||
| input: event.toolInput, | ||
| permission_suggestions: [], | ||
| blocked_path: null, | ||
| } as CLIControlPermissionRequest, | ||
| undefined, | ||
| this.context.abortSignal, | ||
| ); | ||
|
|
||
| if (response.subtype !== 'success') { | ||
| await event.respond(ToolConfirmationOutcome.Cancel); | ||
| return; | ||
| } | ||
|
|
||
| const payload = (response.response || {}) as Record<string, unknown>; | ||
| const behavior = String(payload['behavior'] || '').toLowerCase(); | ||
|
|
||
| if (behavior === 'allow') { | ||
| await event.respond(ToolConfirmationOutcome.ProceedOnce); | ||
| } else { | ||
| const cancelMessage = | ||
| typeof payload['message'] === 'string' | ||
| ? payload['message'] | ||
| : undefined; | ||
| await event.respond( | ||
| ToolConfirmationOutcome.Cancel, | ||
| cancelMessage | ||
| ? ({ cancelMessage } as ToolConfirmationPayload) | ||
| : undefined, | ||
| ); | ||
| } | ||
| } catch (error) { | ||
| this.debugLogger.error( | ||
| '[PermissionController] Teammate approval failed:', | ||
| error, | ||
| ); | ||
| await event.respond(ToolConfirmationOutcome.Cancel); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Handle outgoing permission request | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Critical]
handleTeammateApproval完全未测试。新增 94 行方法无一测试。所有分支未被覆盖:abort 信号、非 stream-json 降级、SDK
allow的updatedInput转发(安全关键——host 清洗后的参数可能静默被原始参数替换)、cancel的 cancelMessage、catch 路径。— DeepSeek/deepseek-v4-pro via Qwen Code /review