Skip to content

Bug: truncated command output permanently lost, message references non-existent method #1695

@thehighnotes

Description

@thehighnotes

Description

Two issues with truncate_output() in interpreter/core/utils/truncate_output.py:

  1. 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 like ls -la on a large directory or grep -r results, the most useful data is often in the discarded portion.

  2. 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.

  3. ANSI escape codes counted as content: Raw ANSI codes are counted toward the character limit, meaning the visible content is shorter than max_output_chars suggests.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions