fix(core): ensure sub-agent schema and prompt refresh during runtime (#16409)

Co-authored-by: Sehoon Shon <sshon@google.com>
This commit is contained in:
Adam Weidman
2026-01-12 12:11:24 -05:00
committed by GitHub
parent 950244f6b0
commit 465ec9759d
7 changed files with 101 additions and 16 deletions
@@ -14,6 +14,7 @@ import type { Config } from '../config/config.js';
describe('CliHelpAgent', () => {
const fakeConfig = {
getMessageBus: () => ({}),
isAgentsEnabled: () => false,
} as unknown as Config;
const localAgent = CliHelpAgent(fakeConfig) as LocalAgentDefinition;
@@ -52,6 +53,22 @@ describe('CliHelpAgent', () => {
expect(query).toContain('${question}');
});
it('should include sub-agent information when agents are enabled', () => {
const enabledConfig = {
getMessageBus: () => ({}),
isAgentsEnabled: () => true,
getAgentRegistry: () => ({
getDirectoryContext: () => 'Mock Agent Directory',
}),
} as unknown as Config;
const agent = CliHelpAgent(enabledConfig) as LocalAgentDefinition;
const systemPrompt = agent.promptConfig.systemPrompt || '';
expect(systemPrompt).toContain('### Sub-Agents (Local & Remote)');
expect(systemPrompt).toContain('Remote Agent (A2A)');
expect(systemPrompt).toContain('Agent2Agent functionality');
});
it('should process output to a formatted JSON string', () => {
const mockOutput = {
answer: 'This is the answer.',