From 2ae5e1ae20e401a018354ab867f894e09eef8ff3 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 10 Feb 2026 00:25:42 -0800 Subject: [PATCH] feat(core): optimize sub-agents system prompt intro (#18608) --- .../core/__snapshots__/prompts.test.ts.snap | 56 ++++--------------- packages/core/src/core/prompts.test.ts | 2 +- packages/core/src/prompts/promptProvider.ts | 2 +- packages/core/src/prompts/snippets.ts | 6 +- packages/core/src/prompts/utils.ts | 2 +- 5 files changed, 14 insertions(+), 54 deletions(-) diff --git a/packages/core/src/core/__snapshots__/prompts.test.ts.snap b/packages/core/src/core/__snapshots__/prompts.test.ts.snap index 713f87328c..08f426c5da 100644 --- a/packages/core/src/core/__snapshots__/prompts.test.ts.snap +++ b/packages/core/src/core/__snapshots__/prompts.test.ts.snap @@ -531,11 +531,7 @@ exports[`Core System Prompt (prompts.ts) > should append userMemory with separat # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. @@ -1312,11 +1308,7 @@ exports[`Core System Prompt (prompts.ts) > should include correct sandbox instru # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. @@ -1429,11 +1421,7 @@ exports[`Core System Prompt (prompts.ts) > should include correct sandbox instru # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. @@ -1546,11 +1534,7 @@ exports[`Core System Prompt (prompts.ts) > should include correct sandbox instru # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. @@ -1771,15 +1755,11 @@ exports[`Core System Prompt (prompts.ts) > should include sub-agents in XML for # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. - Test Agent + test-agent A test agent description @@ -2123,11 +2103,7 @@ exports[`Core System Prompt (prompts.ts) > should return the base prompt when us # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. @@ -2236,11 +2212,7 @@ exports[`Core System Prompt (prompts.ts) > should return the base prompt when us # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. @@ -2460,11 +2432,7 @@ exports[`Core System Prompt (prompts.ts) > should use chatty system prompt for p # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. @@ -2573,11 +2541,7 @@ exports[`Core System Prompt (prompts.ts) > should use chatty system prompt for p # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. diff --git a/packages/core/src/core/prompts.test.ts b/packages/core/src/core/prompts.test.ts index 6543d5c353..e3cfa92697 100644 --- a/packages/core/src/core/prompts.test.ts +++ b/packages/core/src/core/prompts.test.ts @@ -178,7 +178,7 @@ describe('Core System Prompt (prompts.ts)', () => { expect(prompt).toContain('# Available Sub-Agents'); expect(prompt).toContain(''); expect(prompt).toContain(''); - expect(prompt).toContain('Test Agent'); + expect(prompt).toContain('test-agent'); expect(prompt).toContain( 'A test agent description', ); diff --git a/packages/core/src/prompts/promptProvider.ts b/packages/core/src/prompts/promptProvider.ts index bb07795c84..8da1a7ed7d 100644 --- a/packages/core/src/prompts/promptProvider.ts +++ b/packages/core/src/prompts/promptProvider.ts @@ -132,7 +132,7 @@ export class PromptProvider { .getAgentRegistry() .getAllDefinitions() .map((d) => ({ - name: d.displayName || d.name, + name: d.name, description: d.description, })), ), diff --git a/packages/core/src/prompts/snippets.ts b/packages/core/src/prompts/snippets.ts index 3336d64d41..6e64a22085 100644 --- a/packages/core/src/prompts/snippets.ts +++ b/packages/core/src/prompts/snippets.ts @@ -187,11 +187,7 @@ export function renderSubAgents(subAgents?: SubAgentOptions[]): string { return ` # Available Sub-Agents -Sub-agents are specialized expert agents that you can use to assist you in the completion of all or part of a task. - -Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. - -The following tools can be used to start sub-agents: +Sub-agents are specialized expert agents. Each sub-agent is available as a tool of the same name. You MUST delegate tasks to the sub-agent with the most relevant expertise. ${subAgentsXml} diff --git a/packages/core/src/prompts/utils.ts b/packages/core/src/prompts/utils.ts index edb95c5080..768aaf1720 100644 --- a/packages/core/src/prompts/utils.ts +++ b/packages/core/src/prompts/utils.ts @@ -77,7 +77,7 @@ export function applySubstitutions( .getAgentRegistry() .getAllDefinitions() .map((d) => ({ - name: d.displayName || d.name, + name: d.name, description: d.description, })), );