fix: Windows Specific Agent Quality & System Prompt (#18351)

This commit is contained in:
Tommaso Sciortino
2026-02-05 09:50:12 -08:00
committed by GitHub
parent ee2c8eef19
commit e4c80e6382
5 changed files with 232 additions and 39 deletions
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect } from 'vitest';
import { describe, it, expect, vi, afterEach } from 'vitest';
import { CodebaseInvestigatorAgent } from './codebase-investigator.js';
import {
GLOB_TOOL_NAME,
@@ -17,9 +17,24 @@ import { makeFakeConfig } from '../test-utils/config.js';
describe('CodebaseInvestigatorAgent', () => {
const config = makeFakeConfig();
const agent = CodebaseInvestigatorAgent(config);
afterEach(() => {
vi.unstubAllGlobals();
});
const mockPlatform = (platform: string) => {
vi.stubGlobal(
'process',
Object.create(process, {
platform: {
get: () => platform,
},
}),
);
};
it('should have the correct agent definition', () => {
const agent = CodebaseInvestigatorAgent(config);
expect(agent.name).toBe('codebase_investigator');
expect(agent.displayName).toBe('Codebase Investigator Agent');
expect(agent.description).toBeDefined();
@@ -39,6 +54,7 @@ describe('CodebaseInvestigatorAgent', () => {
});
it('should process output to a formatted JSON string', () => {
const agent = CodebaseInvestigatorAgent(config);
const report = {
SummaryOfFindings: 'summary',
ExplorationTrace: ['trace'],
@@ -47,4 +63,18 @@ describe('CodebaseInvestigatorAgent', () => {
const processed = agent.processOutput?.(report);
expect(processed).toBe(JSON.stringify(report, null, 2));
});
it('should include Windows-specific list command in system prompt when on Windows', () => {
mockPlatform('win32');
const agent = CodebaseInvestigatorAgent(config);
expect(agent.promptConfig.systemPrompt).toContain(
'`dir /s` (CMD) or `Get-ChildItem -Recurse` (PowerShell)',
);
});
it('should include generic list command in system prompt when on non-Windows', () => {
mockPlatform('linux');
const agent = CodebaseInvestigatorAgent(config);
expect(agent.promptConfig.systemPrompt).toContain('`ls -R`');
});
});
@@ -57,6 +57,11 @@ export const CodebaseInvestigatorAgent = (
? PREVIEW_GEMINI_FLASH_MODEL
: DEFAULT_GEMINI_MODEL;
const listCommand =
process.platform === 'win32'
? '`dir /s` (CMD) or `Get-ChildItem -Recurse` (PowerShell)'
: '`ls -R`';
return {
name: 'codebase_investigator',
kind: 'local',
@@ -164,7 +169,7 @@ When you are finished, you **MUST** call the \`complete_task\` tool. The \`repor
"ExplorationTrace": [
"Used \`grep\` to search for \`updateUser\` to locate the primary function.",
"Read the file \`src/controllers/userController.js\` to understand the function's logic.",
"Used \`ls -R\` to look for related files, such as services or database models.",
"Used ${listCommand} to look for related files, such as services or database models.",
"Read \`src/services/userService.js\` and \`src/models/User.js\` to understand the data flow and how state is managed."
],
"RelevantLocations": [