fix(coding-agent): bound and retain final tool result text - #199
Merged
Merged
Conversation
A tool result with images is sent in block form, and whitespace-only text blocks were forwarded unchanged. The API rejects them, and the result stays in history, so every later request in the session fails. Drop them as the user and assistant paths already do; the image placeholder still applies when no text remains.
Native bash keeps the last 2,000 lines / 50 KiB, then appends its notice and exit status, which puts the result just over the final bound. The head-only pass then cut exactly that tail: the last lines, the full-log path and "Command exited with code N" of a failed build. Allow 8 lines and 1 KiB of trailer before bounding; larger results are still bounded as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Large MCP/extension results, validation errors, and denied-call messages could bypass built-in output limits. Add a content-only final result boundary and let coding-agent retain complete text privately before publishing a 2,000-line/50-KiB preview with a readable artifact path. This also covers calls that never reach
afterToolCalland latermessage_endreplacements, while preserving execution-hook semantics and tool termination, usage, metadata, and images.Retention failures describe potentially completed effects rather than encouraging a blind repeat. Tests cover UTF-8, empty text blocks, JSON-quoted paths containing newlines, denied/invalid calls, images, cleanup, and storage failures. Arbitrary typed details and streaming progress are outside this text-retention policy. Related to the closed #175 proposal.
Validation:
npm run checkpnpm run build:offline./test.shwith isolated credentials