fix(core): improve shell tool truncation, simplify tool output handling, and remove summarization#2388
Conversation
Remove the enableToolOutputTruncation boolean setting. Users can now disable truncation by setting truncateToolOutputThreshold to 0 or a negative value instead of using a separate toggle. This simplifies the configuration and prevents users from accidentally disabling truncation which could cause memory issues with large tool outputs. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
📋 Review SummaryThis PR removes the 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
- Remove deprecated fields: embedding_model, api_key_enabled, vertex_ai_enabled, log_prompts_enabled - Add new fields: truncate_tool_output_threshold, truncate_tool_output_lines, hooks, ide_enabled, interactive_shell_enabled This aligns telemetry data with the current CLI configuration options. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> - Extract truncateAndSaveToFile to utils/truncation.ts with tests - Move truncation handling from CoreToolScheduler to ShellTool - Remove outputFile field from ToolCallResponseInfo and display types - Add line limit constraint alongside character threshold for truncation This improves separation of concerns by handling output truncation at the tool level where the output is generated, rather than centrally in the scheduler.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> Remove the summarizeToolOutput setting and related functionality. This feature allowed LLM-based summarization of shell tool output but is no longer needed. This simplifies the codebase by removing unused summarization logic and configuration options.
Replace average-line-length estimation with explicit head/tail budgets. Remove line wrapping; save original content to file. Handle very long lines by truncating with ellipsis. Add tests for edge cases with variable line lengths. This ensures truncated output stays predictably near the character threshold, avoiding cases where long lines in the tail would blow past the budget. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
…r tests StartSessionEvent requires getTruncateToolOutputThreshold, getTruncateToolOutputLines, getIdeMode, getShouldUseNodePtyShell, and getHookSystem from the config object. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
TLDR
Truncation now uses a character-budget algorithm for more predictable output sizes. Also in this pr, simplifies tool output handling by removing the LLM-based summarization feature and the redundant
enableToolOutputTruncationtoggle.Before (The context filled up too quickly by shell tool call with many text outputs)


After (The context is protected by global truncation rule)


Changes
1. Improve truncation with character-budget algorithm
The new
truncateAndSaveToFilefunction uses a character budget instead of simple line counting. This ensures truncated output stays within predictable size limits even when lines vary widely in length.packages/core/src/utils/truncation.tswith comprehensive testscoreToolScheduler.ts2. Move truncation logic from scheduler to shell tool
Truncation is now handled directly in the shell tool rather than in the tool scheduler. This keeps the logic closer to where it's used and simplifies the scheduler.
3. Remove
enableToolOutputTruncationsettingUsers can disable truncation by setting
truncateToolOutputThresholdto0or a negative value instead of using a separate toggle. This simplifies the configuration and makes disabling truncation more intentional.4. Remove
summarizeToolOutputfeatureThe LLM-based tool output summarization feature has been removed entirely. This feature added complexity and API calls without sufficient benefit. The truncation mechanism is sufficient for managing large outputs.
packages/core/src/utils/summarizer.tsand its testssummarizeToolOutputfrom config, settings schema, and migration maps5. Update telemetry session event fields
Updated
qwen-code.configevent attributes to match current config:embedding_model,api_key_enabled,vertex_ai_enabled,code_assist_enabled,log_prompts_enabledtruncate_tool_output_threshold,truncate_tool_output_lines,hooks,ide_enabled,interactive_shell_enabled6. Fix tests
Added missing config methods to
makeFakeConfigin qwen-logger tests.Files Changed
packages/core/src/utils/truncation.ts(new)packages/core/src/utils/summarizer.ts(deleted)packages/core/src/tools/shell.ts(truncation moved here)packages/core/src/core/coreToolScheduler.ts(simplified)packages/core/src/config/config.ts(removed settings)packages/cli/src/config/settingsSchema.ts(removed schema entries)Reviewer Test Plan
cd packages/core && npx vitest run src/utils/truncation.test.tscd packages/core && npx vitest run src/config/config.test.tstruncateToolOutputThreshold: 0Linked Issues
Resolves #2384