Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cli/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ export async function loadCliConfig(
enablePromptCompletion: settings.general?.enablePromptCompletion ?? false,
truncateToolOutputThreshold: settings.tools?.truncateToolOutputThreshold,
truncateToolOutputLines: settings.tools?.truncateToolOutputLines,
enableToolOutputTruncation: settings.tools?.enableToolOutputTruncation,
eventEmitter: appEvents,
useSmartEdit: argv.useSmartEdit ?? settings.useSmartEdit,
});
Expand Down
13 changes: 11 additions & 2 deletions packages/cli/src/config/settingsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,20 @@ const SETTINGS_SCHEMA = {
'Use ripgrep for file content search instead of the fallback implementation. Provides faster search performance.',
showInDialog: true,
},
enableToolOutputTruncation: {
type: 'boolean',
label: 'Enable Tool Output Truncation',
category: 'General',
requiresRestart: true,
default: false,
description: 'Enable truncation of large tool outputs.',
showInDialog: true,
},
truncateToolOutputThreshold: {
type: 'number',
label: 'Tool Output Truncation Threshold',
category: 'General',
requiresRestart: false,
requiresRestart: true,
default: DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
description:
'Truncate tool output if it is larger than this many characters. Set to -1 to disable.',
Expand All @@ -705,7 +714,7 @@ const SETTINGS_SCHEMA = {
type: 'number',
label: 'Tool Output Truncation Lines',
category: 'General',
requiresRestart: false,
requiresRestart: true,
default: DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
description: 'The number of lines to keep when truncating tool output.',
showInDialog: true,
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export interface ConfigParameters {
enablePromptCompletion?: boolean;
truncateToolOutputThreshold?: number;
truncateToolOutputLines?: number;
enableToolOutputTruncation?: boolean;
eventEmitter?: EventEmitter;
useSmartEdit?: boolean;
}
Expand Down Expand Up @@ -301,6 +302,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;
Expand Down Expand Up @@ -381,6 +383,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);
Expand Down Expand Up @@ -835,6 +839,10 @@ export class Config {
return this.enablePromptCompletion;
}

getEnableToolOutputTruncation(): boolean {
return this.enableToolOutputTruncation;
}

getTruncateToolOutputThreshold(): number {
return this.truncateToolOutputThreshold;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/core/coreToolScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
Loading