Skip to content
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
16ea312
feat: add Agent Team experimental feature for parallel sub-agent coor…
tanzhenxin Apr 4, 2026
fa9efe9
fix(cli): handle TeamResultDisplay in TUI renderer
tanzhenxin Apr 5, 2026
3e21a1d
fix(cli): add missing team manager mocks to useGeminiStream tests
tanzhenxin Apr 5, 2026
bb32211
Merge remote-tracking branch 'origin/main' into feat/agent-team
tanzhenxin Apr 9, 2026
0468e20
fix(core): add missing getTeamManager mock to agent tests
tanzhenxin Apr 9, 2026
9c1199a
Merge remote-tracking branch 'origin/main' into feat/agent-team
tanzhenxin Apr 15, 2026
011b250
Merge remote-tracking branch 'origin/main' into feat/agent-team
tanzhenxin Apr 16, 2026
ce321de
Merge remote-tracking branch 'origin/main' into feat/agent-team
tanzhenxin Apr 29, 2026
638a739
fix(core): await async convertToRuntimeConfig in TeamManager
tanzhenxin Apr 29, 2026
f4582d6
fix(team): detach leader callback and approval listener on TeamManage…
tanzhenxin Apr 29, 2026
53883cd
fix(team): correct teammate communication and dependency-graph bugs
tanzhenxin Apr 30, 2026
4188d5d
fix(team): close teammate message gaps and align workflow docs
tanzhenxin Apr 30, 2026
8ea7549
Merge remote-tracking branch 'origin/main' into feat/agent-team
tanzhenxin Apr 30, 2026
4a86ae9
refactor(team): tighten team module hot paths and remove dead code
tanzhenxin Apr 30, 2026
34f7831
fix(team): harden task ID validation and teammate-turn invariants
tanzhenxin Apr 30, 2026
99177ac
Merge remote-tracking branch 'origin/main' into feat/agent-team
tanzhenxin May 6, 2026
c663b83
fix(core): scope team shutdown to leader and pending teammates
tanzhenxin May 6, 2026
48ed14a
fix(core): harden leader inbox against races and envelope spoofing
tanzhenxin May 6, 2026
4820da6
fix(core): close MAX_TEAMMATES race and propagate disallowedTools strip
tanzhenxin May 6, 2026
0df90cf
fix(core): surface corrupt task and inbox files instead of silently s…
tanzhenxin May 6, 2026
52444cd
fix(core): make Agent-tool team routing opt-in via explicit name
tanzhenxin May 6, 2026
ebec078
fix(cli): wire teammate approvals and waitForTeammateActivity timeouts
tanzhenxin May 6, 2026
7c0d151
fix(cli): drop dead non-stream-json branch in handleTeammateApproval
tanzhenxin May 6, 2026
9cfbd16
fix(core): batch of agent-team review nits
tanzhenxin May 6, 2026
a874777
fix(core): release registry and content-generator on spawn failure
tanzhenxin May 6, 2026
49a76cb
fix(core): preserve externally-set leader callback across waitForTeam…
tanzhenxin May 6, 2026
340b3cf
fix(core): refuse to clobber a team owned by another qwen-code session
tanzhenxin May 6, 2026
50f58bf
fix(core): release per-agent event-bridge listeners on terminal status
tanzhenxin May 6, 2026
921cda7
test(core): stub getTeamManager in task-list test config
tanzhenxin May 6, 2026
5ad0b92
fix(core): address agent-team review feedback batch
tanzhenxin May 7, 2026
832e64a
fix(core): address second /qreview round for agent-team
tanzhenxin May 7, 2026
bb92b83
fix(core): address codex review for agent-team
tanzhenxin May 7, 2026
a9d6246
fix(cli): satisfy required `args` in SubAgentTracker test mock
tanzhenxin May 7, 2026
bb32865
Merge remote-tracking branch 'origin/main' into feat/agent-team
tanzhenxin May 8, 2026
73b9877
fix(core): tighten agent-team privilege boundaries and task coordination
tanzhenxin May 8, 2026
edade76
refactor(core): reuse atomicWriteJSON across agent-team file writes
tanzhenxin May 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"@types/mime-types": "^3.0.1",
"@types/minimatch": "^5.1.2",
"@types/mock-fs": "^4.13.4",
"@types/proper-lockfile": "^4.1.4",
"@types/shell-quote": "^1.7.5",
"@types/uuid": "^10.0.0",
"@vitest/coverage-v8": "^3.1.1",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@ export async function loadCliConfig(
argv.maxSessionTurns ?? settings.model?.maxSessionTurns ?? -1,
experimentalZedIntegration: argv.acp || argv.experimentalAcp || false,
cronEnabled: settings.experimental?.cron ?? false,
agentTeamEnabled: settings.experimental?.agentTeam ?? false,
emitToolUseSummaries: settings.experimental?.emitToolUseSummaries ?? true,
listExtensions: argv.listExtensions || false,
overrideExtensions: overrideExtensions || argv.extensions,
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/config/settingsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,16 @@ const SETTINGS_SCHEMA = {
'Enable in-session cron/loop tools (experimental). When enabled, the model can create recurring prompts using cron_create, cron_list, and cron_delete tools. Can also be enabled via QWEN_CODE_ENABLE_CRON=1 environment variable.',
showInDialog: true,
},
agentTeam: {
type: 'boolean',
label: 'Enable Agent Team',
category: 'Experimental',
requiresRestart: true,
default: false,
description:
'Enable agent team collaboration tools (experimental). When enabled, the model can create agent teams and coordinate work using team_create, team_delete, send_message, task_create, task_update, and task_list tools. Can also be enabled via QWEN_CODE_ENABLE_AGENT_TEAM=1 environment variable.',
showInDialog: true,
},
emitToolUseSummaries: {
type: 'boolean',
label: 'Tool Use Summaries',
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/nonInteractive/control/ControlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export class ControlService {
*/
getToolCallUpdateCallback:
controller.getToolCallUpdateCallback.bind(controller),

handleTeammateApproval:
controller.handleTeammateApproval.bind(controller),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import type {
ToolExecuteConfirmationDetails,
ToolMcpConfirmationDetails,
ApprovalMode,
TeammateApprovalRequestEvent,
ToolConfirmationPayload,
} from '@qwen-code/qwen-code-core';
import {
InputFormat,
Expand Down Expand Up @@ -378,6 +380,79 @@ export class PermissionController extends BaseController {
};
}

Copy link
Copy Markdown
Collaborator

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


/**
* 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(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Critical] handleTeammateApproval ~80 行新代码完全没有单元测试。

整个 packages/cli/src/nonInteractive/control/controllers/ 目录下没有 *permissionController*.test.* 文件。未覆盖的分支包括:abort signal 取消、updatedInput 通过 Record<string,unknown> 强转(line 448 的 cast——干净 rebuild 之前是真的 TS2322 报错)、cancelMessage 字符串/缺省分支、SDK side allow/deny 路径、最外层 catch 的日志路径。

这是 teammate 唯一的 interactive 审批入口,回归一旦发生就是「所有 teammate 的工具调用都拿不到批准」,影响面巨大。建议在合并前补一组用 fake event / fake sendControlRequest 的单测,至少覆盖:

  • abort 路径
  • allow + updatedInput pass-through(验证 cast 安全)
  • allow + 空 payload
  • cancel + message 串
  • cancel + 无 message
  • 异常 catch 路径(debugLogger.error 被调用)

— 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
*
Expand Down
13 changes: 12 additions & 1 deletion packages/cli/src/nonInteractive/control/types/serviceAPIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
*/

import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
import type { MCPServerConfig } from '@qwen-code/qwen-code-core';
import type {
MCPServerConfig,
TeammateApprovalRequestEvent,
} from '@qwen-code/qwen-code-core';
import type { PermissionSuggestion } from '../../types.js';

/**
Expand Down Expand Up @@ -46,6 +49,14 @@ export interface PermissionServiceAPI {
* @returns Callback function that processes tool call updates
*/
getToolCallUpdateCallback(): (toolCalls: unknown[]) => void;

/**
* Handle a teammate tool approval request.
*
* Routes the approval through the session's permission channel
* (stream-json control request or local approval mode check).
*/
handleTeammateApproval(event: TeammateApprovalRequestEvent): Promise<void>;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/nonInteractiveCli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ describe('runNonInteractive', () => {
isInteractive: vi.fn().mockReturnValue(false),
isCronEnabled: vi.fn().mockReturnValue(false),
getCronScheduler: vi.fn().mockReturnValue(null),
getTeamManager: vi.fn().mockReturnValue(null),
onTeamManagerChange: vi.fn(),
setModelInvocableCommandsProvider: vi.fn(),
setModelInvocableCommandsExecutor: vi.fn(),
getDisabledSlashCommands: vi.fn().mockReturnValue([]),
Expand Down
Loading
Loading