mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-08 20:30:53 -07:00
feat(core): Only summarize long tool output for shell command (#8039)
This commit is contained in:
@@ -225,6 +225,7 @@ export interface ConfigParameters {
|
||||
enablePromptCompletion?: boolean;
|
||||
truncateToolOutputThreshold?: number;
|
||||
truncateToolOutputLines?: number;
|
||||
enableToolOutputTruncation?: boolean;
|
||||
eventEmitter?: EventEmitter;
|
||||
useSmartEdit?: boolean;
|
||||
}
|
||||
@@ -303,6 +304,7 @@ export class Config {
|
||||
private readonly enablePromptCompletion: boolean = false;
|
||||
private readonly truncateToolOutputThreshold: number;
|
||||
private readonly truncateToolOutputLines: number;
|
||||
private readonly enableToolOutputTruncation: boolean;
|
||||
private initialized: boolean = false;
|
||||
readonly storage: Storage;
|
||||
private readonly fileExclusions: FileExclusions;
|
||||
@@ -383,6 +385,8 @@ export class Config {
|
||||
DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD;
|
||||
this.truncateToolOutputLines =
|
||||
params.truncateToolOutputLines ?? DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES;
|
||||
this.enableToolOutputTruncation =
|
||||
params.enableToolOutputTruncation ?? false;
|
||||
this.useSmartEdit = params.useSmartEdit ?? true;
|
||||
this.extensionManagement = params.extensionManagement ?? true;
|
||||
this.storage = new Storage(this.targetDir);
|
||||
@@ -860,6 +864,10 @@ export class Config {
|
||||
return this.enablePromptCompletion;
|
||||
}
|
||||
|
||||
getEnableToolOutputTruncation(): boolean {
|
||||
return this.enableToolOutputTruncation;
|
||||
}
|
||||
|
||||
getTruncateToolOutputThreshold(): number {
|
||||
return this.truncateToolOutputThreshold;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
ReadFileTool,
|
||||
ToolErrorType,
|
||||
ToolCallEvent,
|
||||
ShellTool,
|
||||
} from '../index.js';
|
||||
import type { Part, PartListUnion } from '@google/genai';
|
||||
import { getResponseTextFromParts } from '../utils/generateContentResponseUtilities.js';
|
||||
@@ -976,7 +977,10 @@ export class CoreToolScheduler {
|
||||
let outputFile: string | undefined = undefined;
|
||||
if (
|
||||
typeof content === 'string' &&
|
||||
this.config.getTruncateToolOutputThreshold() > 0
|
||||
toolName === ShellTool.Name &&
|
||||
this.config.getEnableToolOutputTruncation() &&
|
||||
this.config.getTruncateToolOutputThreshold() > 0 &&
|
||||
this.config.getTruncateToolOutputLines() > 0
|
||||
) {
|
||||
({ content, outputFile } = await truncateAndSaveToFile(
|
||||
content,
|
||||
|
||||
Reference in New Issue
Block a user