Repository navigation
feat: stream LLM replies over SSE and show progress while verbs wait - #55
Merged
Merged
Conversation
Complete reports call phases (start, connected, request-sent, first-byte, done) to an Observer carried in the context, via net/http/httptrace. With no observer, the code path is unchanged. wip: llm-streaming/step-01
Reporter draws one spinner line on stderr with a label, the llm call phase, and elapsed time. It is nil (a no-op) when --json is set, TERM=dumb, or stderr is not a character device. wip: llm-progress/step-01
While Summarize runs, stderr shows 'summarizing <done>/<total>', plus the cache-hit count once it is non-zero. The line clears before any output or error. wip: llm-progress/step-02
wake builds a progress reporter before the mode branch and puts it in the context. RunAuto shows 'drafting <i>/<n> · <project>' with the llm call phase, and clears the line before any stderr output. wip: llm-progress/step-03
After the session header, stderr shows 'drafting · <project>' with the llm call phase. An Edit regeneration shows 'redrafting · <project>'. The line clears before the draft and menu reprint, which are unchanged. wip: llm-progress/step-04
While Synthesize waits on the LLM, stderr shows 'synthesizing brief · <project>' with the call phase. The line clears before the brief text or an error prints. wip: llm-progress/step-05
The stub records whether a request asked for stream:true and can answer with SSE chunks (SetStream), verbatim SSE lines (SetStreamRaw), and configurable delays (SetDelay). Default replies are unchanged. wip: llm-streaming/step-02
Complete sends stream:true by default and parses the SSE reply, emitting PhaseThinking for reasoning deltas and PhaseDelta for content. A reply that is not text/event-stream uses the existing JSON path. llm.stream: false turns streaming off. wip: llm-streaming/step-03
…nd total limits A long stream is no longer cut at 30s. Complete now fails when no response headers arrive within FirstByteTimeout, when the body stalls for IdleTimeout, or when the call runs past MaxDuration. A parent context cancel still returns the parent's error. wip: llm-streaming/step-04
docs/llm-streaming/decisions.md records the observer seam, streaming by default with a JSON fallback, the parser rules, and the three timeouts. The package doc no longer says the client does not stream. wip: llm-streaming/step-05
docs/llm-progress/decisions.md records the reporter design, the TTY gate, the per-verb status labels, the two defaults Beau has not confirmed, and the live pty smoke results, including the narrow-terminal wrap risk. wip: llm-progress/step-06
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.
The LLM verbs (retro, wake, brief) used to sit on an empty line for minutes. This PR adds a one-line status on stderr while they wait, and streams replies over SSE. It carries two wip Matters,
llm-streamingandllm-progress, with one commit per verified step.Streaming (
internal/llm)llm.WithObserver(ctx, o)reports call phases: start, connected, request-sent, first-byte, thinking, delta, done. Done comes only on success. With no observer, the code path does not change.Completekeeps its signature.stream: trueand parses the SSE reply. Reasoning deltas emitPhaseThinkingand stay out of the result. Content deltas emitPhaseDelta. When the reply is nottext/event-stream, the client uses the existing JSON reader.llm.stream: falsein config turns streaming off.FirstByteTimeout(30 s) bounds the wait for headers,IdleTimeout(30 s) bounds silence between body reads, andMaxDuration(5 min) caps the call. A long stream is no longer cut at 30 s. A parent cancel still satisfieserrors.Is(err, context.Canceled).llmteststub: newSetStream,SetStreamRawandSetDelay. Default replies are byte-identical to before.Progress (
internal/progressand the verbs)<spinner> <label> · <phase> · <N>son stderr and clears it before any other output. It is a no-op when--jsonis set, whenTERM=dumb, or when stderr is not a character device. It travels in the context, so no verb function signature changes.summarizing 7/15 · 3 cached.--auto:drafting 3/15 · <project>with the call phase.drafting · <project>, andredrafting · <project>for an Edit. The full draft and menu still print as before.synthesizing brief · <project>with the call phase.Decisions to confirm
Two defaults were set at planning time and are not confirmed yet:
--verbose.Known limits
COLUMNS, which shells usually do not export, so it assumes 80. At 40 columns the line wraps and the clear leaves the first row on screen. A fix needs the real window size (x/termorTIOCGWINSZ).Status,Clearor observer in a verb. Live pty runs are the evidence.clast: brief: brief: …. This predates the PR.llm.stream. Those amendments belong in clast-reboot.docs/llm-streaming/decisions.mdanddocs/llm-progress/decisions.mdrecord every decision and follow-up.Testing
make checkpasses. The e2e suite needed no expected-output changes.[DONE], a held-open connection after[DONE], a raw-body check thatstreamis absent when off), and each timeout on both the SSE and JSON paths. Mutation checks confirmed that these tests fail when the behavior breaks.clast briefagainst the configured LiteLLM endpoint succeeds with streaming on and withllm.stream: false.script, with a scratch cache) ofretro --since -7d --refreshandbriefdraw the status line and leave no residue at 80 columns. The pyte terminal emulator confirmed the final screens. Pty runs of wake, against a stub and a scratch journal, covered--auto, Edit, a failed redraft, and the EOF paths.