open-interpreter icon indicating copy to clipboard operation
open-interpreter copied to clipboard

Improve truncation

Open endolith opened this issue 1 year ago • 1 comments

Describe the changes you have made:

When truncating long outputs, remove the middle and show the head and tail to the assistant, instead of showing only the tail. This provides more useful context.

Also improve the suggestions given to the assistant for how to deal with long output, since it tends to do the wrong thing here.

Reference any relevant issues (e.g. "Fixes #000"):

I don't see any.

Pre-Submission Checklist (optional but appreciated):

  • [ ] I have included relevant documentation updates (stored in /docs)
  • [x] I have read docs/CONTRIBUTING.md [but running black and isort on the code caused many unrelated changes, so I didn't commit that.]
  • [ ] I have read docs/ROADMAP.md

OS Tests (optional but appreciated):

  • [x] Tested on Windows
  • [ ] Tested on MacOS
  • [x] Tested on Linux

endolith avatar Jan 26 '25 06:01 endolith

Also prints the total length now, with typical output like this:

…
      print(content)


  Output truncated (2,659,274 characters total). Showing 1,400 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')`, repeat shell commands with wc/grep/sed, etc. or break it down into smaller steps.

  <?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
…

endolith avatar Jan 26 '25 15:01 endolith