Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
docs(pi): 子代理 provider 的优先级说明与既有行为对齐
Zhang Yunjin33bdeef49b3d
diff --git a/packages/maker-core/src/agents/pi/__tests__/cindySubagentDelegation.test.ts b/packages/maker-core/src/agents/pi/__tests__/cindySubagentDelegation.test.tsindex 529198a6b6..f0a32030ec 100644--- a/packages/maker-core/src/agents/pi/__tests__/cindySubagentDelegation.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/cindySubagentDelegation.test.ts@@ -324,6 +324,11 @@ describe('Pi subagent provider selection', () => {{ provider: 'openai-codex', model: 'gpt-5.4', sourceProviderId: 'openai', proxySessionAuth: true },{ provider: 'cindy-byom-openai-codex', model: 'chatgpt/gpt-5.4', sourceProviderId: 'openai-codex' },],+ // 父会话 provider 与前缀隐含来源各命中一条不同连接。+ 'claude-5-sonnet': [+ { provider: 'anthropic', model: 'claude-5-sonnet', sourceProviderId: 'anthropic', proxySessionAuth: true },+ { provider: 'parent', model: 'claude-5-sonnet', sourceProviderId: 'parent' },+ ],},};const route = (task: { model?: string; provider?: string }) => {@@ -392,6 +397,19 @@ describe('Pi subagent provider selection', () => {.toEqual(['openai', 'cindy-byom-openai-codex']);});+ it('keeps the pre-existing prefix-before-parent order when no provider is given', () => {+ // 本 PR 不调整未传 provider 时的优先级:前缀隐含来源仍然压过父会话 provider。+ expect(route({ model: 'claude-5-sonnet' })).toMatchObject({+ routeProvider: 'anthropic',+ routeSourceProviderId: 'anthropic',+ });+ // 显式 provider 则可以越过这条顺序,直接选父会话那个连接。+ expect(route({ model: 'claude-5-sonnet', provider: 'parent' })).toMatchObject({+ routeProvider: 'parent',+ routeSourceProviderId: 'parent',+ });+ });+it('accepts provider at call level and per task, and exposes it in the tool schema', async () => {const callLevel = extension.normalizeInvocation({ agent: 'worker', task: 'x', provider: 'glm-coding-plan' });expect(callLevel.tasks[0].provider).toBe('glm-coding-plan');diff --git a/packages/maker-core/src/agents/pi/cindy-subagent-source.ts b/packages/maker-core/src/agents/pi/cindy-subagent-source.tsindex 33f443c352..6de562e330 100644--- a/packages/maker-core/src/agents/pi/cindy-subagent-source.ts+++ b/packages/maker-core/src/agents/pi/cindy-subagent-source.ts@@ -456,6 +456,8 @@ function resolveTaskModelRoutes(tasks, runtime) {: candidates.length === 1? candidates[0]: null;+ // 未传 provider 时的**既有**顺序:模型 id 前缀隐含的来源 > 父会话 provider > 唯一候选。+ // 本 PR 只给显式 provider 加分支,不调整它(review: 正文曾把这段误写成“父来源优先”)。if (!route) {if (candidates.length > 1) {throw new Error(@@ -1520,7 +1522,7 @@ export default async function cindySubagent(pi: any) {model: { type: 'string', description: 'Optional exact child model id.' },provider: {type: 'string',- description: 'Optional provider id for the child (from capabilities modelProviders). Must serve the chosen model; defaults to the parent provider.',+ description: 'Optional provider id for the child (from capabilities modelProviders). Must serve the chosen model and match exactly one connection. Without it, resolution keeps its existing order: a source implied by a xai/, chatgpt/ or claude- model id, then the parent provider.',},thinking: { type: 'string', description: 'Optional thinking level: ' + THINKING_LEVELS },async: { type: 'boolean', description: 'Run in Cindy durable background mode.' },