Repository navigation
DRU-1009 -- Read a chat bridge answer in chunks until its newline - #1119
Open
p-r-a-v-i-n wants to merge 1 commit into
Open
p-r-a-v-i-n wants to merge 1 commit into
p-r-a-v-i-n wants to merge 1 commit into
Conversation
p-r-a-v-i-n
marked this pull request as draft
November 6, 2026 15:52
p-r-a-v-i-n
marked this pull request as ready for review
November 7, 2026 07:06
This branch has not been deployed
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.
Bridge.requestreads the bridge's answer in chunks until its newline, so a chat answer over 2 MiB arrives whole and the reply is no longer lost.The bridge sends one JSON line per answer. Druks read it with
readline()on the asyncssh channel. When the receive buffer reaches the channel's window (2 MiB by default), asyncssh pauses reading, andreaduntilreturns what it holds as a partial line. Theeventsanswer of a turn that read a large file was cut mid-string,json.loadsfailed, and each retry of the step got the same cut.read(64 * 1024)empties the buffer and resumes reading, so the loop collects chunks until one holds the newline and parses the joined bytes once. It stops at the newline, not at the end of the stream, because the drukbox gateway's forward does not signal the end. The bridge escapes newlines inside the JSON and ends the socket after the line, so the newline is the end of the answer. An empty answer still raisesChatBridgeUnavailable, and an answer that is not JSON still raisesChatBridgeError.The test sends a 3 MB answer with no end of stream through a loopback reader.
The 2 MiB cut was also the only limit on the answer's size. DRU-1010 tracks keeping large tool output out of the chat events.