mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-26 14:01:14 -07:00
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
@@ -323,7 +323,7 @@ export class LocalAgentExecutor<TOutput extends z.ZodTypeAny> {
|
||||
): Promise<AgentTurnResult> {
|
||||
const promptId = `${this.agentId}#${turnCounter}`;
|
||||
|
||||
await this.tryCompressChat(chat, promptId);
|
||||
await this.tryCompressChat(chat, promptId, combinedSignal);
|
||||
|
||||
const { functionCalls } = await promptIdContext.run(promptId, async () =>
|
||||
this.callModel(chat, currentMessage, combinedSignal, promptId),
|
||||
@@ -810,6 +810,7 @@ export class LocalAgentExecutor<TOutput extends z.ZodTypeAny> {
|
||||
private async tryCompressChat(
|
||||
chat: GeminiChat,
|
||||
prompt_id: string,
|
||||
abortSignal?: AbortSignal,
|
||||
): Promise<void> {
|
||||
const model = this.definition.modelConfig.model ?? DEFAULT_GEMINI_MODEL;
|
||||
|
||||
@@ -820,6 +821,7 @@ export class LocalAgentExecutor<TOutput extends z.ZodTypeAny> {
|
||||
model,
|
||||
this.context.config,
|
||||
this.hasFailedCompressionAttempt,
|
||||
abortSignal,
|
||||
);
|
||||
|
||||
if (
|
||||
|
||||
@@ -608,7 +608,7 @@ export class GeminiClient {
|
||||
// Check for context window overflow
|
||||
const modelForLimitCheck = this._getActiveModelForCurrentTurn();
|
||||
|
||||
const compressed = await this.tryCompressChat(prompt_id, false);
|
||||
const compressed = await this.tryCompressChat(prompt_id, false, signal);
|
||||
|
||||
if (compressed.compressionStatus === CompressionStatus.COMPRESSED) {
|
||||
yield { type: GeminiEventType.ChatCompressed, value: compressed };
|
||||
@@ -1158,6 +1158,7 @@ export class GeminiClient {
|
||||
async tryCompressChat(
|
||||
prompt_id: string,
|
||||
force: boolean = false,
|
||||
abortSignal?: AbortSignal,
|
||||
): Promise<ChatCompressionInfo> {
|
||||
// If the model is 'auto', we will use a placeholder model to check.
|
||||
// Compression occurs before we choose a model, so calling `count_tokens`
|
||||
@@ -1171,6 +1172,7 @@ export class GeminiClient {
|
||||
model,
|
||||
this.config,
|
||||
this.hasFailedCompressionAttempt,
|
||||
abortSignal,
|
||||
);
|
||||
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user