Tool output can exceed context limit
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Describe the bug
The grep tool has no limit on line length. This can cause a problem when searching files with long lines (bundled JS).
To Reproduce
Steps to reproduce the behavior:
- Create a file with a very long sequence of characters without a newline (include
matching sequence) - Prompt an agent to search the file for
matching sequence - See error
Expected behavior
- Grep should have a reasonable limit to line length of matches (200)
- read tool also?
@treydavis are you sure you are using latest eca server? check it via /doctor, because we do have some ways to avoid that should work for your case: https://eca.dev/config/context-management/
I will close this unless confirmed with a repro there is a bug or room for improvement in this term, LMK otherwise
I'm now using ECA version: 0.110.1.
I was either mistaken about this being the fault of the grep tool or had an old version that was recently fixed. However, I can still reproduce this issue with the read-file tool:
(spit "/path/to/long-line.txt" (apply str (repeat (* 128 1024) "x")))
(count
(get-in
(read-file { "path" "/path/to/long-line.txt"
"line_offset" 0
"limit" 100
} {:toolCall {:readFile {:maxLines 1}}})
[:contents 0 :text])) ; 131072
If the agent attempts to read a file with very long lines, the result can exceed the context window. I have encountered this dealing with minified/bundled JS files.
I see that the higher-level output truncation should catch this. I am able to reproduce in from the client. I will look into it more to be sure.
Yeah I think outputTruncation is supposed to help with that, but maybe the default of kb is too high? suggestions are welcome on this part
The issue was that the truncation was not truncating by max size, only by lines.
https://github.com/editor-code-assistant/eca/pull/346
Nice catch, I did some small changes for performance, LMK if works, thank you!