refactor: simplify tool output truncation to single config (#18446)

This commit is contained in:
Sandy Tao
2026-02-06 13:41:19 -08:00
committed by GitHub
parent fd72a8c40f
commit 28805a4b2d
22 changed files with 56 additions and 189 deletions

View File

@@ -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',
);
});