-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
Two issues with truncate_output() in interpreter/core/utils/truncate_output.py:
-
Output permanently lost: When command output exceeds
max_output_chars, the middle portion is replaced with[...]and discarded. Neither the user nor the LLM can recover the full output. For commands likels -laon a large directory orgrep -rresults, the most useful data is often in the discarded portion. -
Truncation message references non-existent method: The message tells users to use
computer.ai.summarize(result), which does not exist in the CLI context. Users follow this suggestion and get an error. -
ANSI escape codes counted as content: Raw ANSI codes are counted toward the character limit, meaning the visible content is shorter than
max_output_charssuggests.
Current code
message = (f"Output truncated ({len(data):,} characters total). "
f"Showing {chars_per_end:,} characters from start/end. "
"To handle large outputs, store result in python var first "
"`result = command()` then `computer.ai.summarize(result)` for "
"a summary, search with `result.find('text')`...")Suggested fix
- Strip ANSI escape codes before measuring length
- Save full output to a temp file (e.g.
/tmp/oi-output-latest.txt) before truncating, so users can review it - Reword the truncation message to reference practical shell commands (
head,tail,grep) instead of non-existent Python methods
Related: #1588
Environment
- open-interpreter 0.4.3
- Python 3.10, Linux