feat(coderd/x/chatd): open a chat_turn span per prompt - #28972
Draft
jscottmiller wants to merge 1 commit into
Draft
feat(coderd/x/chatd): open a chat_turn span per prompt#28972jscottmiller wants to merge 1 commit into
jscottmiller wants to merge 1 commit into
Conversation
This was referenced Sep 4, 2026
jscottmiller
force-pushed
the
scott/chatd-stages/4-provider-attempts
branch
from
September 9, 2026 23:19
ffc1233 to
cf79f38
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/5-turn-span
branch
from
September 9, 2026 23:19
02c8b6d to
a2ad5b2
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/4-provider-attempts
branch
from
September 11, 2026 02:25
cf79f38 to
8b252aa
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/5-turn-span
branch
from
September 11, 2026 02:26
a2ad5b2 to
3363b52
Compare
The runner owns a runnerTurnSpan that opens a chat_turn root span on the first generation task of a prompt, anchored at the trigger message, and hands every task a turn token so a task that outlives its turn cannot finish the turn that replaced it. A turn closes in two steps: the finishing transition calls Complete from inside the step, and Settle closes the span after the step's stage has ended, opening the next turn from a promoted queued message when there is one. The generation step, prepare, mcp_connect, commit, compaction, thinking, tool_call, retry_backoff, acquisition, and queue_wait stages hang off the turn, and inflight work is detached from it as background scope.
jscottmiller
force-pushed
the
scott/chatd-stages/4-provider-attempts
branch
from
September 11, 2026 19:17
8b252aa to
2653138
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/5-turn-span
branch
from
September 11, 2026 19:17
3363b52 to
926fabc
Compare
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.
Each chat prompt runs inside a
chat_turnroot span owned by the runner (runnerTurnSpan), with the generation step, prepare, MCP connect, commit, thinking, tool call, compaction, retry backoff, and queue wait stages parented under it. The span is anchored at the trigger message's creation time so the reconstructedacquisitionstage falls inside the turn.Turn lifecycle:
Ensureopens the span on the first generation task and returns aturnToken. Methods that take a token no-op when the turn has since been replaced, so a task that outlives its turn cannot finish the next one.Completemarks it finished from inside the last generation step;Settlecloses the span after that step's stage has ended, so the finishing step is inside the span.Settleopens the next turn anchored at the moment that message was queued and records itsqueue_waitagainst the new turn.FinishTurnResult.PromotedQueuedAtcarries that timestamp out of the transition.inflightContext) strips the span context and runs in thebackgroundscope, so title, summary, and status label generation start their own trace roots.chat_turnspans are standalone roots: the turn executes on a worker, often on another replica, and no trace context is persisted. ARCHITECTURE.md gets TODO markers for the human author.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.