Description
Issue Description
When executing code that produces large amounts of output (e.g., directory listings, file contents, system information), all output is sent to the LLM in its entirety before being truncated in the final response. This raises both security and performance concerns:
-
Security Risk:
- Sensitive information in large outputs (logs, system info, file contents) is sent to the LLM
- Even if truncated in the final response, the LLM has already processed the complete output
- This could lead to unintended data exposure
-
Performance Impact:
- Unnecessary token consumption when sending large outputs to the LLM
- Increased API costs
- Potential context window overflow
Example
# Simple code that generates large output
import os
for root, dirs, files in os.walk("/"):
print(f"Directory: {root}")
for file in files:
print(f" File: {file}")
Current behavior:
- Code executes and generates complete output
- Complete output is sent to LLM
- LLM processes all output
- Response is truncated for display
Proposed Solution
Add output limiting at the source (code execution) level:
- Add a configurable
max_output_lines
ormax_output_bytes
parameter - Implement truncation during code execution, before sending to LLM
- Add clear indicators when output is truncated
This aligns with the project's philosophy of simplicity and security while maintaining core functionality.
Questions
- Would this feature align with the project's scope?
- Should this be configurable per execution or as a global setting?
- What would be a reasonable default limit?
Additional Context
This issue was discovered while building a service using Open Interpreter's API. The complete output being sent to the LLM was noticed through debug logs and token usage metrics.
Describe the solution you'd like
Add output limiting at the source (code execution) level:
- Add a configurable
max_output_lines
ormax_output_bytes
parameter - Implement truncation during code execution, before sending to LLM
- Add clear indicators when output is truncated
This aligns with the project's philosophy of simplicity and security while maintaining core functionality.
Describe alternatives you've considered
No response
Additional context
No response