mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
lint passes and failing test passes
This commit is contained in:
@@ -403,31 +403,10 @@ export class ToolExecutor {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (typeof content === 'string' && toolName === SHELL_TOOL_NAME) {
|
} else {
|
||||||
const threshold = this.config.getTruncateToolOutputThreshold();
|
const truncated = await this.truncateOutputIfNeeded(call, content);
|
||||||
|
content = truncated.truncatedContent;
|
||||||
if (threshold > 0 && content.length > threshold) {
|
outputFile = truncated.outputFile;
|
||||||
const originalContentLength = content.length;
|
|
||||||
const { outputFile: savedPath } = await saveTruncatedToolOutput(
|
|
||||||
content,
|
|
||||||
toolName,
|
|
||||||
callId,
|
|
||||||
this.config.storage.getProjectTempDir(),
|
|
||||||
this.config.getSessionId(),
|
|
||||||
);
|
|
||||||
outputFile = savedPath;
|
|
||||||
content = formatTruncatedToolOutput(content, outputFile, threshold);
|
|
||||||
|
|
||||||
logToolOutputTruncated(
|
|
||||||
this.config,
|
|
||||||
new ToolOutputTruncatedEvent(call.request.prompt_id, {
|
|
||||||
toolName,
|
|
||||||
originalContentLength,
|
|
||||||
truncatedContentLength: content.length,
|
|
||||||
threshold,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = convertToFunctionResponse(
|
const response = convertToFunctionResponse(
|
||||||
|
|||||||
@@ -48,6 +48,18 @@ export interface MaskingResult {
|
|||||||
tokensSaved: number;
|
tokensSaved: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface HasOutputFile {
|
||||||
|
outputFile: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasOutputFile(obj: unknown): obj is HasOutputFile {
|
||||||
|
if (typeof obj !== 'object' || obj === null || !('outputFile' in obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const val = (obj as Record<string, unknown>)['outputFile'];
|
||||||
|
return typeof val === 'string';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to manage context window efficiency by masking bulky tool outputs (Tool Output Masking).
|
* Service to manage context window efficiency by masking bulky tool outputs (Tool Output Masking).
|
||||||
*
|
*
|
||||||
@@ -188,11 +200,8 @@ export class ToolOutputMaskingService {
|
|||||||
let fileSizeMB = '0.00';
|
let fileSizeMB = '0.00';
|
||||||
let totalLines = 0;
|
let totalLines = 0;
|
||||||
|
|
||||||
if (
|
if (hasOutputFile(originalResponse) && originalResponse.outputFile) {
|
||||||
typeof originalResponse['outputFile'] === 'string' &&
|
filePath = originalResponse.outputFile;
|
||||||
originalResponse['outputFile']
|
|
||||||
) {
|
|
||||||
filePath = originalResponse['outputFile'];
|
|
||||||
try {
|
try {
|
||||||
const stats = await fsPromises.stat(filePath);
|
const stats = await fsPromises.stat(filePath);
|
||||||
fileSizeMB = (stats.size / 1024 / 1024).toFixed(2);
|
fileSizeMB = (stats.size / 1024 / 1024).toFixed(2);
|
||||||
|
|||||||
Reference in New Issue
Block a user