fix(cli): ag run streaming output hangs β wrong response field names (#3368)#3389
Merged
Conversation
β¦3368) The read endpoint (/v1/sessions/:id/read) returns { messages, status }, not { lines/transcript, status }. The CLI was looking for non-existent fields, so it never received any entries and the stream appeared to hang. Also: - Skip non-text content types (thinking, tool_use, tool_result) in output - Added 'crashed' to terminal status detection - Show statusText when available for better end-of-session messages Fixes: #3368
Contributor
There was a problem hiding this comment.
β Approved.
Classic field name mismatch bug β one wrong key = terminal hangs forever.
data.lines || data.transcriptβdata.messagesβ matches actual API response shape.- Filters non-text content types (thinking, tool_use, tool_result) β no more noise in stream output.
- Added
crashedto terminal states + showsstatusTextfor better UX.
CI green. All gates pass.
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.
Summary
Fixes #3368 β ag run streaming output never displays the answer.
Root Cause
The
streamOutput()function inag runwas looking fordata.linesordata.transcriptin the response from/v1/sessions/:id/read. But the endpoint actually returnsdata.messages. Since neither field existed, the CLI never received any entries and the stream appeared to hang indefinitely.Fix
lines/transcripttomessages(matching the actual API response)crashedto terminal status detectionstatusTextwhen available for better end-of-session messagesVerification
readMessagesFromSession()return type:{ messages: ParsedEntry[], status: UIState, statusText, interactiveContent }