From 9b06e70f4afb09aed0e756fd8d1a0c2a5941980e Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Sun, 8 Feb 2026 23:17:41 -0800 Subject: [PATCH 1/2] feat(core): optimize sub-agents system prompt intro - Shorten introductory paragraph for sub-agents to be more concise. - Retain essential 'same name' verbiage and mandatory delegation guidance. - Maintain existing 'Remember' line and example suffix for context. Fixes https://github.com/google-gemini/gemini-cli/issues/shorten-subagents-prompt --- .../core/__snapshots__/prompts.test.ts.snap | 54 ++++--------------- packages/core/src/prompts/snippets.ts | 6 +-- 2 files changed, 10 insertions(+), 50 deletions(-) diff --git a/packages/core/src/core/__snapshots__/prompts.test.ts.snap b/packages/core/src/core/__snapshots__/prompts.test.ts.snap index 4e66e3403c4..f92346ba0ca 100644 --- a/packages/core/src/core/__snapshots__/prompts.test.ts.snap +++ b/packages/core/src/core/__snapshots__/prompts.test.ts.snap @@ -532,11 +532,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. @@ -1331,11 +1327,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. @@ -1454,11 +1446,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. @@ -1577,11 +1565,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. @@ -1808,11 +1792,7 @@ 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. @@ -2039,11 +2019,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. @@ -2158,11 +2134,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. @@ -2388,11 +2360,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. @@ -2507,11 +2475,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/prompts/snippets.ts b/packages/core/src/prompts/snippets.ts index 2a713afbed1..76b7363c869 100644 --- a/packages/core/src/prompts/snippets.ts +++ b/packages/core/src/prompts/snippets.ts @@ -175,11 +175,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} From dd22d27e176ed2c093f0a65f0ea5e3a806879339 Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Sun, 8 Feb 2026 23:51:40 -0800 Subject: [PATCH 2/2] fix(core): ensure sub-agent names reflect tool names - Update promptProvider and utils to use the internal tool name for sub-agents. - Update test expectations and snapshots to match correct tool naming. --- packages/core/src/core/__snapshots__/prompts.test.ts.snap | 2 +- packages/core/src/core/prompts.test.ts | 2 +- packages/core/src/prompts/promptProvider.ts | 2 +- packages/core/src/prompts/utils.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/core/__snapshots__/prompts.test.ts.snap b/packages/core/src/core/__snapshots__/prompts.test.ts.snap index f92346ba0ca..099a3ffb3e3 100644 --- a/packages/core/src/core/__snapshots__/prompts.test.ts.snap +++ b/packages/core/src/core/__snapshots__/prompts.test.ts.snap @@ -1796,7 +1796,7 @@ Sub-agents are specialized expert agents. Each sub-agent is available as a tool - Test Agent + test-agent A test agent description diff --git a/packages/core/src/core/prompts.test.ts b/packages/core/src/core/prompts.test.ts index 5307c3235a7..67042dfc0f1 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 1e6ee4206f6..37ca51bcc46 100644 --- a/packages/core/src/prompts/promptProvider.ts +++ b/packages/core/src/prompts/promptProvider.ts @@ -120,7 +120,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/utils.ts b/packages/core/src/prompts/utils.ts index edb95c5080b..768aaf1720a 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, })), );