fix(runtime): don't truncate the SSE stream on tool results >64 KiB - #3883
Open
EronWright wants to merge 1 commit into
Open
fix(runtime): don't truncate the SSE stream on tool results >64 KiB#3883EronWright wants to merge 1 commit into
EronWright wants to merge 1 commit into
Conversation
The client SSE reader used bufio.Scanner with the default 64KiB token cap
(bufio.MaxScanTokenSize). Each agent event is delivered as one `data: {json}`
line, and a large tool result (e.g. a big tool_call_response) exceeds that,
so scanner.Scan() trips bufio.ErrTooLong, the loop ends, and the run appears
to stop silently after the preceding event. The scanner error was also
swallowed, leaving no trace.
Raise the reader's buffer ceiling and surface any read error as an Error
event instead of closing the stream without a word.
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.
fix(runtime): don't truncate the SSE stream on tool results >64 KiB
Problem
The remote-runtime SSE reader (
pkg/runtime/client.go) usesbufio.NewScannerwith the default 64 KiB token cap (
bufio.MaxScanTokenSize). Each server event isdelivered as one
data: {json}line, so a large tool result — e.g. a bigtool_call_response— overflows it:scanner.Scan()tripsbufio.ErrTooLong, theloop ends, and the run appears to stop silently right after the last event that
fit. The scanner error was discarded, leaving no trace.
Fix
In both SSE readers: raise the buffer ceiling (
maxSSELineBytes, added topkg/runtime/defaults.go) and emit anErrorevent onscanner.Err()instead ofclosing the channel without a word.
Impact
Any agent that returns a tool response larger than 64 KiB over a remote runtime —
today that run vanishes with no error.
Test
go build ./pkg/runtime/ && go test ./pkg/runtime/. Reproduced with a ~78 KBtool_call_responsethat previously cut the stream mid-run; it now streams tocompletion.