Fix and rename introspection agent -> cli help agent (#16097)

This commit is contained in:
Tommaso Sciortino
2026-01-07 15:01:57 -08:00
committed by GitHub
parent bd77515fd9
commit d4b418ba01
11 changed files with 71 additions and 72 deletions
@@ -5,18 +5,22 @@
*/
import { describe, it, expect } from 'vitest';
import { IntrospectionAgent } from './introspection-agent.js';
import { CliHelpAgent } from './cli-help-agent.js';
import { GET_INTERNAL_DOCS_TOOL_NAME } from '../tools/tool-names.js';
import { GEMINI_MODEL_ALIAS_FLASH } from '../config/models.js';
import type { LocalAgentDefinition } from './types.js';
import type { Config } from '../config/config.js';
describe('IntrospectionAgent', () => {
const localAgent = IntrospectionAgent as LocalAgentDefinition;
describe('CliHelpAgent', () => {
const fakeConfig = {
getMessageBus: () => ({}),
} as unknown as Config;
const localAgent = CliHelpAgent(fakeConfig) as LocalAgentDefinition;
it('should have the correct agent definition metadata', () => {
expect(localAgent.name).toBe('introspection_agent');
expect(localAgent.name).toBe('cli_help');
expect(localAgent.kind).toBe('local');
expect(localAgent.displayName).toBe('Introspection Agent');
expect(localAgent.displayName).toBe('CLI Help Agent');
expect(localAgent.description).toContain('Gemini CLI');
});
@@ -32,7 +36,9 @@ describe('IntrospectionAgent', () => {
expect(localAgent.modelConfig?.model).toBe(GEMINI_MODEL_ALIAS_FLASH);
const tools = localAgent.toolConfig?.tools || [];
const hasInternalDocsTool = tools.includes(GET_INTERNAL_DOCS_TOOL_NAME);
const hasInternalDocsTool = tools.some(
(t) => typeof t !== 'string' && t.name === GET_INTERNAL_DOCS_TOOL_NAME,
);
expect(hasInternalDocsTool).toBe(true);
});
@@ -5,11 +5,12 @@
*/
import type { AgentDefinition } from './types.js';
import { GET_INTERNAL_DOCS_TOOL_NAME } from '../tools/tool-names.js';
import { GEMINI_MODEL_ALIAS_FLASH } from '../config/models.js';
import { z } from 'zod';
import type { Config } from '../config/config.js';
import { GetInternalDocsTool } from '../tools/get-internal-docs.js';
const IntrospectionReportSchema = z.object({
const CliHelpReportSchema = z.object({
answer: z
.string()
.describe('The detailed answer to the user question about Gemini CLI.'),
@@ -22,14 +23,14 @@ const IntrospectionReportSchema = z.object({
* An agent specialized in answering questions about Gemini CLI itself,
* using its own documentation and runtime state.
*/
export const IntrospectionAgent: AgentDefinition<
typeof IntrospectionReportSchema
> = {
name: 'introspection_agent',
export const CliHelpAgent = (
config: Config,
): AgentDefinition<typeof CliHelpReportSchema> => ({
name: 'cli_help',
kind: 'local',
displayName: 'Introspection Agent',
displayName: 'CLI Help Agent',
description:
'Specialized in answering questions about yourself (Gemini CLI): features, documentation, and current runtime configuration.',
'Specialized in answering questions about how users use you, (Gemini CLI): features, documentation, and current runtime configuration.',
inputConfig: {
inputs: {
question: {
@@ -42,7 +43,7 @@ export const IntrospectionAgent: AgentDefinition<
outputConfig: {
outputName: 'report',
description: 'The final answer and sources as a JSON object.',
schema: IntrospectionReportSchema,
schema: CliHelpReportSchema,
},
processOutput: (output) => JSON.stringify(output, null, 2),
@@ -60,7 +61,7 @@ export const IntrospectionAgent: AgentDefinition<
},
toolConfig: {
tools: [GET_INTERNAL_DOCS_TOOL_NAME],
tools: [new GetInternalDocsTool(config.getMessageBus())],
},
promptConfig: {
@@ -70,7 +71,7 @@ export const IntrospectionAgent: AgentDefinition<
'${question}\n' +
'</question>',
systemPrompt:
"You are **Introspection Agent**, an expert on Gemini CLI. Your purpose is to provide accurate information about Gemini CLI's features, configuration, and current state.\n\n" +
"You are **CLI Help Agent**, an expert on Gemini CLI. Your purpose is to provide accurate information about Gemini CLI's features, configuration, and current state.\n\n" +
'### Runtime Context\n' +
'- **CLI Version:** ${cliVersion}\n' +
'- **Active Model:** ${activeModel}\n' +
@@ -82,4 +83,4 @@ export const IntrospectionAgent: AgentDefinition<
'4. **Non-Interactive**: You operate in a loop and cannot ask the user for more info. If the question is ambiguous, answer as best as you can with the information available.\n\n' +
'You MUST call `complete_task` with a JSON report containing your `answer` and the `sources` you used.',
},
};
});
+6 -6
View File
@@ -220,26 +220,26 @@ describe('AgentRegistry', () => {
).not.toHaveBeenCalled();
});
it('should register introspection agent if enabled', async () => {
it('should register CLI help agent if enabled', async () => {
const config = makeFakeConfig({
introspectionAgentSettings: { enabled: true },
cliHelpAgentSettings: { enabled: true },
});
const registry = new TestableAgentRegistry(config);
await registry.initialize();
expect(registry.getDefinition('introspection_agent')).toBeDefined();
expect(registry.getDefinition('cli_help')).toBeDefined();
});
it('should NOT register introspection agent if disabled', async () => {
it('should NOT register CLI help agent if disabled', async () => {
const config = makeFakeConfig({
introspectionAgentSettings: { enabled: false },
cliHelpAgentSettings: { enabled: false },
});
const registry = new TestableAgentRegistry(config);
await registry.initialize();
expect(registry.getDefinition('introspection_agent')).toBeUndefined();
expect(registry.getDefinition('cli_help')).toBeUndefined();
});
});
+5 -5
View File
@@ -10,7 +10,7 @@ import type { Config } from '../config/config.js';
import type { AgentDefinition } from './types.js';
import { loadAgentsFromDirectory } from './toml-loader.js';
import { CodebaseInvestigatorAgent } from './codebase-investigator.js';
import { IntrospectionAgent } from './introspection-agent.js';
import { CliHelpAgent } from './cli-help-agent.js';
import { A2AClientManager } from './a2a-client-manager.js';
import { ADCHandler } from './remote-invocation.js';
import { type z } from 'zod';
@@ -106,7 +106,7 @@ export class AgentRegistry {
private loadBuiltInAgents(): void {
const investigatorSettings = this.config.getCodebaseInvestigatorSettings();
const introspectionSettings = this.config.getIntrospectionAgentSettings();
const cliHelpSettings = this.config.getCliHelpAgentSettings();
// Only register the agent if it's enabled in the settings.
if (investigatorSettings?.enabled) {
@@ -145,9 +145,9 @@ export class AgentRegistry {
this.registerLocalAgent(agentDef);
}
// Register the introspection agent if it's explicitly enabled.
if (introspectionSettings.enabled) {
this.registerLocalAgent(IntrospectionAgent);
// Register the CLI help agent if it's explicitly enabled.
if (cliHelpSettings.enabled) {
this.registerLocalAgent(CliHelpAgent(this.config));
}
}