Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(orca): 补上「Orca Worker 不能替代 subagent」的对称规则 (#1445)
Chris Zhang5aa030af4d34
diff --git a/packages/lizi-mcps/src/__tests__/createWorkerTool.test.ts b/packages/lizi-mcps/src/__tests__/createWorkerTool.test.tsindex 661a855326..0822fe4eda 100644--- a/packages/lizi-mcps/src/__tests__/createWorkerTool.test.ts+++ b/packages/lizi-mcps/src/__tests__/createWorkerTool.test.ts@@ -54,7 +54,8 @@ describe('create_worker tool', () => {const { registry } = setup();expect(registry.get('create_worker')?.description).toContain(- '注:create_worker 建的是 Orca worker(session 级、持久、UI 可见),不是 subagent。若用户要的是 subagent(一次性、用完即弃),请用原生 subagent 机制(Codex:spawn_agent;Claude Code:Task 工具),不要用 create_worker。',+ '注:create_worker 建的是 Orca worker(session 级、持久、UI 可见),不是 subagent。若用户要的是 subagent(一次性、用完即弃),请用你自己的原生 subagent 机制(如 Codex 的 spawn_agent、Claude Code 的 Task 工具),不要用 create_worker。'+ + 'Orca worker 永远不是 subagent 的替代品;你没有原生 subagent 机制时,如实告知用户并请他决定,不要拿 worker 顶替。',);expect(registry.get('create_worker')?.description).toContain('用户一次要求创建 2 个及以上 Worker 时必须改用 create_workers;不要并行或连续多次调用 create_worker。',@@ -197,7 +198,7 @@ describe('create_worker tool', () => {ok: false,errorCode: 'WORKER_CANNOT_NEST',data: {- hint: 'create_worker 是 Orca Lead 创建 worker session 的入口,不是 subagent 入口。若用户明确要求 subagent / 子代理,请使用你自己的原生 subagent 机制(Codex:spawn_agent;Claude Code:Task/Agent 工具),不要使用 Orca create_worker / start_team。',+ hint: 'create_worker 是 Orca Lead 创建 worker session 的入口,不是 subagent 入口。若用户明确要求 subagent / 子代理,请使用你自己的原生 subagent 机制(如 Codex 的 spawn_agent、Claude Code 的 Task/Agent 工具),不要使用 Orca create_worker / start_team。没有原生 subagent 机制时如实告知用户,Orca worker 不是它的替代品。',},});expect(createWorker).not.toHaveBeenCalled();diff --git a/packages/lizi-mcps/src/__tests__/startTeamTool.test.ts b/packages/lizi-mcps/src/__tests__/startTeamTool.test.tsindex 10b401590e..566c88bbad 100644--- a/packages/lizi-mcps/src/__tests__/startTeamTool.test.ts+++ b/packages/lizi-mcps/src/__tests__/startTeamTool.test.ts@@ -22,7 +22,8 @@ describe('start_team tool', () => {});expect(registry.get('start_team')?.description).toContain(- '注:start_team 开启的是 session 级、持久、UI 可见的多 worker 协同。若用户要的是一个 subagent(一次性、用完即弃的子任务执行体),请用你自己的原生 subagent 机制(Codex:spawn_agent;Claude Code:Task 工具),不要为此 start_team 开协同。',+ '注:start_team 开启的是 session 级、持久、UI 可见的多 worker 协同。若用户要的是一个 subagent(一次性、用完即弃的子任务执行体),请用你自己的原生 subagent 机制(如 Codex 的 spawn_agent、Claude Code 的 Task 工具),不要为此 start_team 开协同。'+ + 'Orca 协同永远不是 subagent 的替代品;你没有原生 subagent 机制时,如实告知用户并请他决定,不要拿 Orca 顶替,也不要自己起进程冒充。',);});@@ -45,7 +46,7 @@ describe('start_team tool', () => {ok: false,errorCode: 'WORKER_CANNOT_NEST',data: {- hint: 'start_team 是 Orca worker 协同入口,不是 subagent 入口。若用户明确要求 subagent / 子代理,请使用你自己的原生 subagent 机制(Codex:spawn_agent;Claude Code:Task/Agent 工具),不要使用 Orca start_team / create_worker。',+ hint: 'start_team 是 Orca worker 协同入口,不是 subagent 入口。若用户明确要求 subagent / 子代理,请使用你自己的原生 subagent 机制(如 Codex 的 spawn_agent、Claude Code 的 Task/Agent 工具),不要使用 Orca start_team / create_worker。没有原生 subagent 机制时如实告知用户,Orca 协同不是它的替代品。',},});expect(startTeam).not.toHaveBeenCalled();diff --git a/packages/lizi-mcps/src/xdt-helper/create_worker.ts b/packages/lizi-mcps/src/xdt-helper/create_worker.tsindex 5cd2c860fb..5994ac4c73 100644--- a/packages/lizi-mcps/src/xdt-helper/create_worker.ts+++ b/packages/lizi-mcps/src/xdt-helper/create_worker.ts@@ -110,7 +110,8 @@ export function toWorkerLimitPayload(limit: WorkerLimitSnapshot | undefined): Reconst DESCRIPTION = ['在当前 workflow 内创建新 worker session。',- '注:create_worker 建的是 Orca worker(session 级、持久、UI 可见),不是 subagent。若用户要的是 subagent(一次性、用完即弃),请用原生 subagent 机制(Codex:spawn_agent;Claude Code:Task 工具),不要用 create_worker。',+ '注:create_worker 建的是 Orca worker(session 级、持久、UI 可见),不是 subagent。若用户要的是 subagent(一次性、用完即弃),请用你自己的原生 subagent 机制(如 Codex 的 spawn_agent、Claude Code 的 Task 工具),不要用 create_worker。' ++ 'Orca worker 永远不是 subagent 的替代品;你没有原生 subagent 机制时,如实告知用户并请他决定,不要拿 worker 顶替。','用户一次要求创建 2 个及以上 Worker 时必须改用 create_workers;不要并行或连续多次调用 create_worker。','','参数:',@@ -151,7 +152,7 @@ export function registerCreateWorkerTool(if (ctx.vendorOptions?.orcaRole === 'worker') {return errorPayload('WORKER_CANNOT_NEST',- 'create_worker 是 Orca Lead 创建 worker session 的入口,不是 subagent 入口。若用户明确要求 subagent / 子代理,请使用你自己的原生 subagent 机制(Codex:spawn_agent;Claude Code:Task/Agent 工具),不要使用 Orca create_worker / start_team。',+ 'create_worker 是 Orca Lead 创建 worker session 的入口,不是 subagent 入口。若用户明确要求 subagent / 子代理,请使用你自己的原生 subagent 机制(如 Codex 的 spawn_agent、Claude Code 的 Task/Agent 工具),不要使用 Orca create_worker / start_team。没有原生 subagent 机制时如实告知用户,Orca worker 不是它的替代品。',);}const result = await deps.createWorker({diff --git a/packages/lizi-mcps/src/xdt-helper/start_team.ts b/packages/lizi-mcps/src/xdt-helper/start_team.tsindex ef4e094b24..1ef23c5fbe 100644--- a/packages/lizi-mcps/src/xdt-helper/start_team.ts+++ b/packages/lizi-mcps/src/xdt-helper/start_team.ts@@ -26,7 +26,8 @@ export interface StartTeamDeps {const DESCRIPTION ='为当前 session 创建 orca team, 进入多 worker 协同模式。' +'失败码: LEAD_NOT_SUPPORTED / WORKER_CANNOT_NEST / ALREADY_ENABLED。' +- '注:start_team 开启的是 session 级、持久、UI 可见的多 worker 协同。若用户要的是一个 subagent(一次性、用完即弃的子任务执行体),请用你自己的原生 subagent 机制(Codex:spawn_agent;Claude Code:Task 工具),不要为此 start_team 开协同。';+ '注:start_team 开启的是 session 级、持久、UI 可见的多 worker 协同。若用户要的是一个 subagent(一次性、用完即弃的子任务执行体),请用你自己的原生 subagent 机制(如 Codex 的 spawn_agent、Claude Code 的 Task 工具),不要为此 start_team 开协同。' ++ 'Orca 协同永远不是 subagent 的替代品;你没有原生 subagent 机制时,如实告知用户并请他决定,不要拿 Orca 顶替,也不要自己起进程冒充。';export function registerStartTeamTool(registry: XdtHelperToolRegistry,@@ -49,7 +50,7 @@ export function registerStartTeamTool(if (role === 'worker') {return errorPayload('WORKER_CANNOT_NEST',- 'start_team 是 Orca worker 协同入口,不是 subagent 入口。若用户明确要求 subagent / 子代理,请使用你自己的原生 subagent 机制(Codex:spawn_agent;Claude Code:Task/Agent 工具),不要使用 Orca start_team / create_worker。',+ 'start_team 是 Orca worker 协同入口,不是 subagent 入口。若用户明确要求 subagent / 子代理,请使用你自己的原生 subagent 机制(如 Codex 的 spawn_agent、Claude Code 的 Task/Agent 工具),不要使用 Orca start_team / create_worker。没有原生 subagent 机制时如实告知用户,Orca 协同不是它的替代品。',);}if (role === 'lead') {diff --git a/packages/orca-workflow/src/__tests__/orca-bridge-prompt.test.ts b/packages/orca-workflow/src/__tests__/orca-bridge-prompt.test.tsindex dd5eae89bb..eda92a2e80 100644--- a/packages/orca-workflow/src/__tests__/orca-bridge-prompt.test.ts+++ b/packages/orca-workflow/src/__tests__/orca-bridge-prompt.test.ts@@ -33,11 +33,27 @@ describe('renderOrcaLeadSystemPrompt', () => {expect(prompt).toContain(workerRoutingRule);expect(prompt).toContain(nativeSubagentBoundary);- expect(prompt).toContain('Codex: spawn_agent; Claude Code: the Agent/Task tool');+ expect(prompt).toContain('for example Codex spawn_agent, or the Claude Code Agent/Task tool');expect(prompt).not.toContain('followup_task');expect(prompt.indexOf(workerRoutingRule)).toBeLessThan(prompt.indexOf(nativeSubagentBoundary));});+ it('forbids substituting an Orca Worker for a subagent, and demands honesty when the harness has none', () => {+ // Orca Worker 是 session 级协同者,subagent 是 agent 内部的一次性执行体 —— 两者+ // 不可互换。此前引导只写了「native subagent 不满足 Orca 派单」这一半,缺了反方向,+ // 且只列举 Codex / Claude Code 两家机制;没有原生机制的 harness(如 pi)因此被推向+ // 它唯一看得见的 Orca 工具,表现为「误开协同模式」。+ const prompt = renderOrcaLeadSystemPrompt(null);++ expect(prompt).toContain('An Orca Worker is NEVER a substitute for a subagent.');+ expect(prompt).toContain(+ 'If you have no native subagent mechanism, say so plainly and ask the user how to proceed',+ );+ expect(prompt).toContain('do NOT open or reuse an Orca Worker to satisfy a subagent request');+ // 兜底路径也不许自己起进程冒充 subagent。+ expect(prompt).toContain('do NOT improvise one by spawning processes yourself');+ });+it('requires execution-channel disclosure and terminal-state verification', () => {const prompt = renderOrcaLeadSystemPrompt(null);@@ -110,7 +126,7 @@ describe('renderOrcaLeadSystemPrompt', () => {describe('renderOrcaWorkerSystemPrompt', () => {const subagentHint =- 'If the user asks for a "subagent" / "子代理", use your native subagent mechanism (Codex: spawn_agent; Claude Code: the Agent/Task tool) to handle it yourself — do NOT escalate to the lead for it, and do NOT call start_team / create_worker (you cannot create Orca workers).';+ 'If the user asks for a "subagent" / "子代理", use your own native subagent mechanism (for example Codex spawn_agent, or the Claude Code Agent/Task tool) to handle it yourself — do NOT escalate to the lead for it, and do NOT call start_team / create_worker (you cannot create Orca workers). If you have no native subagent mechanism, tell the user so instead of substituting an Orca Worker or spawning processes yourself; an Orca Worker is never a substitute for a subagent.';const workerMeta = {workerId: 'worker-1',@@ -131,4 +147,14 @@ describe('renderOrcaWorkerSystemPrompt', () => {expect(prompt).toContain('worker_id=worker-1');expect(prompt).toContain(subagentHint);});++ it('tells a worker without a native subagent mechanism to be honest rather than substitute Orca', () => {+ // worker 侧同规:没有原生机制时如实告知,不拿 Orca 顶替、不自己起进程。+ const prompt = renderOrcaWorkerSystemPrompt(workerMeta);++ expect(prompt).toContain(+ 'If you have no native subagent mechanism, tell the user so instead of substituting an Orca Worker or spawning processes yourself',+ );+ expect(prompt).toContain('an Orca Worker is never a substitute for a subagent');+ });});diff --git a/packages/orca-workflow/src/orca-bridge-prompt.ts b/packages/orca-workflow/src/orca-bridge-prompt.tsindex 182b443a4d..5287909828 100644--- a/packages/orca-workflow/src/orca-bridge-prompt.ts+++ b/packages/orca-workflow/src/orca-bridge-prompt.ts@@ -25,7 +25,8 @@ export function renderOrcaLeadSystemPrompt(initialWorker?: OrcaInitialWorkerRefconst lines = ['You are the lead agent in an Orca multi-agent workflow. Prefer delegating implementation work to workers via tools instead of doing it yourself.','An assignment to an Orca Worker MUST use the Orca tools below. This includes tasks addressed to an existing worker by role or label, explicit requests to open new Orca workers, requests for the Lead to delegate to workers, and parallel role assignments while an Orca team is active. Native subagents do not satisfy an Orca Worker assignment.',- 'Use your native subagent mechanism (Codex: spawn_agent; Claude Code: the Agent/Task tool) only when the user explicitly asks for a "subagent" / "子代理" without assigning the task to an Orca Worker, or explicitly says not to use Orca Workers. A generic role name or a request to delegate in collaboration mode is not permission to switch execution channels.',+ 'Use your own native subagent mechanism (for example Codex spawn_agent, or the Claude Code Agent/Task tool) only when the user explicitly asks for a "subagent" / "子代理" without assigning the task to an Orca Worker, or explicitly says not to use Orca Workers. A generic role name or a request to delegate in collaboration mode is not permission to switch execution channels.',+ 'An Orca Worker is NEVER a substitute for a subagent. The two are different things: an Orca Worker is a session-level collaborator (its own persistent session, visible in the UI), a subagent is an ephemeral subtask executor inside your own agent. If you have no native subagent mechanism, say so plainly and ask the user how to proceed — do NOT open or reuse an Orca Worker to satisfy a subagent request, and do NOT improvise one by spawning processes yourself.','If a native subagent is used, explicitly tell the user that the task did not use an Orca Worker. Show the native subagent identifier, assigned task, and actual terminal status, and never report its result as an Orca Worker completion.','','Tools: get_workspace_info, create_worker, create_workers, send_to_worker.',@@ -104,7 +105,7 @@ export function renderOrcaWorkerSystemPrompt(meta: OrcaWorkerPromptMeta): string'7. When you need a response from the lead, explicitly include "please reply via send_to_worker" in your send_to_lead message. Otherwise the lead may not know to reply.','8. Do not commit changes unless the lead explicitly asks you to. Leave diffs for lead/user review.','9. When first created, wait for the lead to assign a task. Do not proactively message the lead.',- '10. If the user asks for a "subagent" / "子代理", use your native subagent mechanism (Codex: spawn_agent; Claude Code: the Agent/Task tool) to handle it yourself — do NOT escalate to the lead for it, and do NOT call start_team / create_worker (you cannot create Orca workers).',+ '10. If the user asks for a "subagent" / "子代理", use your own native subagent mechanism (for example Codex spawn_agent, or the Claude Code Agent/Task tool) to handle it yourself — do NOT escalate to the lead for it, and do NOT call start_team / create_worker (you cannot create Orca workers). If you have no native subagent mechanism, tell the user so instead of substituting an Orca Worker or spawning processes yourself; an Orca Worker is never a substitute for a subagent.',];return lines.join('\n');