Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(coderd/x/chatd/chatloop): emit stream and time_to_first_token stages - #28970

Draft
jscottmiller wants to merge 1 commit into
scott/chatd-stages/2-stage-tracerfrom
scott/chatd-stages/3-stream-stages
Draft

feat(coderd/x/chatd/chatloop): emit stream and time_to_first_token stages#28970
jscottmiller wants to merge 1 commit into
scott/chatd-stages/2-stage-tracerfrom
scott/chatd-stages/3-stream-stages

Conversation

@jscottmiller

@jscottmiller jscottmiller commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

GenerateAssistant records a stream stage from stream open to close and a nested time_to_first_token stage that closes on the first streamed part. The TTFT window is closed exactly once through finishTTFT; a window released without a part ends with errNoFirstToken and no histogram observation, which is the same population the pre-existing coderd_chatd_ttft_seconds histogram already recorded. The attempt is released before the stream span ends so the TTFT window is never counted outside the stream that contains it.

Callers pass a Stages tracer and a StageModel through GenerateAssistantOptions; a nil tracer discards.


Part of the chatd lifecycle observability stack: 1 extract step · 2 stage tracer · 3 stream stages · 4 provider attempts · 5 turn span · 6 capacity wait · 7 turn accounting · 8 dashboard. Supersedes the experimental branch in #28741.

🤖 This PR was generated by Coder Agents on behalf of @jscottmiller.

…ages

GenerateAssistant takes a StageTracer and StageModel and opens a stream
stage around the guarded model stream. guardedStream opens a
time_to_first_token stage that finishTTFT closes exactly once, on the
first streamed part or when the attempt is released without one; only
windows a part closed feed the TTFT and stage histograms. The attempt
is released before the stream stage ends so the TTFT window always
falls inside the stream that contains it.
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/2-stage-tracer branch from f5bfc09 to 0643175 Compare September 11, 2026 19:17
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/3-stream-stages branch from 3e6c03c to bf4b80a Compare September 11, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Changes that might not necessarily be merged, until its approved to proceed with.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant