mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 19:44:30 -07:00
refactor: simplify tool output truncation to single config (#18446)
This commit is contained in:
@@ -183,6 +183,7 @@ describe('ChatCompressionService', () => {
|
||||
getMessageBus: vi.fn().mockReturnValue(undefined),
|
||||
getHookSystem: () => undefined,
|
||||
getNextCompressionTruncationId: vi.fn().mockReturnValue(1),
|
||||
getTruncateToolOutputThreshold: vi.fn().mockReturnValue(40000),
|
||||
storage: {
|
||||
getProjectTempDir: vi.fn().mockReturnValue(testTempDir),
|
||||
},
|
||||
@@ -581,10 +582,10 @@ describe('ChatCompressionService', () => {
|
||||
const truncatedPart = shellResponse!.parts![0].functionResponse;
|
||||
const content = truncatedPart?.response?.['output'] as string;
|
||||
|
||||
// DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD = 40000 -> head=8000 (20%), tail=32000 (80%)
|
||||
expect(content).toContain(
|
||||
'Output too large. Showing the last 4,000 characters of the output.',
|
||||
'Showing first 8,000 and last 32,000 characters',
|
||||
);
|
||||
// It's a single line, so NO [LINE WIDTH TRUNCATED]
|
||||
});
|
||||
|
||||
it('should use character-based truncation for massive single-line raw strings', async () => {
|
||||
@@ -645,8 +646,9 @@ describe('ChatCompressionService', () => {
|
||||
const truncatedPart = rawResponse!.parts![0].functionResponse;
|
||||
const content = truncatedPart?.response?.['output'] as string;
|
||||
|
||||
// DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD = 40000 -> head=8000 (20%), tail=32000 (80%)
|
||||
expect(content).toContain(
|
||||
'Output too large. Showing the last 4,000 characters of the output.',
|
||||
'Showing first 8,000 and last 32,000 characters',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -49,11 +49,6 @@ export const COMPRESSION_PRESERVE_THRESHOLD = 0.3;
|
||||
*/
|
||||
export const COMPRESSION_FUNCTION_RESPONSE_TOKEN_BUDGET = 50_000;
|
||||
|
||||
/**
|
||||
* The number of lines to keep when truncating a function response during compression.
|
||||
*/
|
||||
export const COMPRESSION_TRUNCATE_LINES = 30;
|
||||
|
||||
/**
|
||||
* Returns the index of the oldest item to keep when compressing. May return
|
||||
* contents.length which indicates that everything should be compressed.
|
||||
@@ -189,11 +184,10 @@ async function truncateHistoryToBudget(
|
||||
config.storage.getProjectTempDir(),
|
||||
);
|
||||
|
||||
// Prepare a honest, readable snippet of the tail.
|
||||
const truncatedMessage = formatTruncatedToolOutput(
|
||||
contentStr,
|
||||
outputFile,
|
||||
COMPRESSION_TRUNCATE_LINES,
|
||||
config.getTruncateToolOutputThreshold(),
|
||||
);
|
||||
|
||||
newParts.unshift({
|
||||
|
||||
Reference in New Issue
Block a user