You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Chat bridge answer over 2 MiB is cut by readline and the reply is lost #1021
A chat turn read a PDF from the thread. The reply never arrived. The web log shows the step that collects the reply retried five times and then:
ERROR druks.chat.service Chat delivery failed for conversation <id>
File "/app/backend/druks/chat/bridge.py", line 41, in request
response = json.loads(line)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 1465630 (char 1465629)
Why
Bridge.request in backend/druks/chat/bridge.py reads the bridge's one-line JSON answer with reader.readline() on an asyncssh channel. asyncssh's readuntil keeps the line in the channel's receive buffer, and when that buffer reaches the channel's receive window (2 MiB, _DEFAULT_WINDOW) it stops reading and raises IncompleteReadError with the partial line; readline catches that and returns the partial as if the line had ended. No error, no newline.
The turn's event log held two events of 1.4 MB each, the tool result carrying the PDF's text. The events answer was 2.1 MB, so the line was cut mid-string, and every retry got the same cut.
Proof
Replaying the events request against the live bridge of that conversation:
The forward itself carries 16 MB intact when read in chunks.
Fix
Read the answer in chunks until the newline instead of readline. The protocol is one JSON line per answer, so the newline is the only end that matters. Do not read to end-of-stream: the drukbox gateway's forward does not signal it (filed separately).
Reading the answer this way removes the cap. Whether a tool result of 1.4 MB belongs in a chat event at all is a separate question, filed separately.
Activity
czpython commentedon Oct 27, 2026
Related: czpython/drukbox#88 (the forward never signals end-of-stream, so the fix must stop at the newline) and #1022 (why the answer was 2 MB).
czpython commentedon Nov 11, 2026
Fixed by #1119.