OpenHands / OpenHands/software-agent-sdk
[Bug]: Large command output consumed over 20k tokens / [Feat]: on-demand loading of more output
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 539
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 137
Description
Is there an existing issue for the same bug?
- I have searched existing issues and this is not a duplicate.
Bug Description
Description
Currently, the full output of a command is injected into the conversation context. In one case, a command produced more than 20,000 tokens, consuming a significant portion of the context window and negatively affecting subsequent reasoning.
Instead of injecting the entire output, the system should:
- Trim the command output to a configurable maximum size before adding it to the context.
- Preserve the complete output in the conversation log.
- Inform the LLM that the output has been truncated.
- Allow the LLM to request additional portions of the output on demand, loading them from the conversation log only when needed.
This approach reduces unnecessary context usage while preserving access to the full command output when required.
Benefits
- Prevents large outputs from exhausting the context window.
- Improves overall reasoning quality and performance.
Expected Behavior
- Large command outputs are truncated before being added to the context.
- The full output remains available in the conversation log.
- The LLM is aware that the output is truncated.
- The LLM can request additional chunks (or the full output) from the conversation log as needed.
Actual Behavior
Inefficient.
Steps to Reproduce
Dear AI, check the output of a html page containing an embeded image coded as base64
Example output
<!DOCTYPE html><html><body style="margin:0;background:#000;"><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7....
Installation Method
No response
If you selected "Other", please specify
No response
SDK Version
No response
Version Confirmation
- I have confirmed this bug exists on the LATEST version of OpenHands SDK
Python Version
No response
Model Name (if applicable)
No response
Operating System
None
Logs and Error Messages
No response
Minimal Code Sample
No response
Screenshots and Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how command output is added to the conversation context and how the complete output is retained in the conversation log. Define the truncation limit, the indication that output was truncated, and the mechanism for requesting additional chunks; done means large outputs no longer consume the full context while the model can still retrieve needed content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100