refactor(core): extract ChatCompressionService from GeminiClient (#12001)

This commit is contained in:
Sandy Tao
2025-10-27 14:29:39 -07:00
committed by GitHub
parent 6db64aab2b
commit 2a87d663d2
5 changed files with 656 additions and 702 deletions
+25 -1
View File
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Part } from '@google/genai';
import type { Part, Content } from '@google/genai';
import type { Config } from '../config/config.js';
import { getFolderStructure } from './getFolderStructure.js';
@@ -71,3 +71,27 @@ ${directoryContext}
return initialParts;
}
export async function getInitialChatHistory(
config: Config,
extraHistory?: Content[],
): Promise<Content[]> {
const envParts = await getEnvironmentContext(config);
const envContextString = envParts.map((part) => part.text || '').join('\n\n');
const allSetupText = `
${envContextString}
Reminder: Do not return an empty response when a tool call is required.
My setup is complete. I will provide my first command in the next turn.
`.trim();
return [
{
role: 'user',
parts: [{ text: allSetupText }],
},
...(extraHistory ?? []),
];
}