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
feat: account chatd turn time by stage and category
Each chat_turn carries a TurnAccumulator that turn-scoped stages report
to as they end. Stages that partition the turn form an attribution tree
so a step's own time is split into disjoint categories, with tool
execution separated from chatd overhead by the step's generation
action. When a turn that Complete marked finished settles, its per-stage
totals, counts, shares, and category partition are observed once on the
turn histograms; Invalidate drops the accounting of a turn that stopped
partway through on an error or interruption. Turns whose duration is
not positive or whose categories overrun it are counted as anomalies.
Copy file name to clipboardExpand all lines: coderd/x/chatd/ARCHITECTURE.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -869,6 +869,8 @@ It inspects the chat's message history, and decides what's the next step to take
869
869
870
870
<!-- TODO: document the generation goroutine's lifecycle stages (`generation_step`, `prepare`, `mcp_connect`, `provider_attempt`, `stream`, `time_to_first_token`, `thinking`, `tool_call`, `commit`, `compaction`, `queue_wait`) and the `coderd_chatd_stage_duration_seconds` histogram they feed. -->
871
871
872
+
<!-- TODO: document the `retry_backoff` stage and the per-turn accounting emitted when a turn that finished normally ends: `coderd_chatd_turn_stage_seconds`, `coderd_chatd_stage_share_of_turn`, `coderd_chatd_turn_time_seconds`, and `coderd_chatd_turn_time_share`, including which stage each turn time category is built from. -->
873
+
872
874
-`CommitStep`: applied when an LLM API call returns a response.
873
875
-`FinishTurn`: applied when the chat processing logic determines that there's no more work to do for the current message history (no pending tool calls, user message is not the last message in the history, etc.).
874
876
-`FinishError`: applied when the LLM API call fails and the retry limit is reached, determined by the `generation_attempt` value.
Help: "Wall time spent in each chat lifecycle stage. Stages overlap in wall time; this is a stage-time profile, not a partition of the turn. The scope label separates stages that run inside a chat turn from detached background work. The chat_kind label is empty for stages recorded without a known chat, and the model and effort labels are empty for stages that run before a model is resolved.",
Help: "Total wall time one chat turn spent in a stage, observed once per turn when the turn ends. Stages overlap, so these do not partition the turn. Only turns that finished normally are counted.",
Help: "Number of times a stage occurred within one chat turn, observed once per turn per stage that occurred. Only turns that finished normally are counted.",
Help: "Fraction of a chat turn's wall time spent in a stage, observed once per turn when the turn ends. Stages overlap, so shares can exceed 1 and do not sum to 1. Only turns that finished normally are counted.",
Help: "Wall time of one chat turn split into disjoint categories that sum to the turn duration, observed once per turn per category when the turn ends. Every category is observed, including the ones with no time. Only turns that finished normally are counted.",
Help: "Fraction of a chat turn's wall time in each disjoint category, observed once per turn per category when the turn ends. The shares of one turn sum to 1. Only turns that finished normally are counted.",
Help: "Chat lifecycle stage observations that were dropped, by reason. A steady rate means the stage timings are missing samples: negative_elapsed and inverted_window are stages whose clocks disagreed.",
168
+
Help: "Chat lifecycle stage observations that were dropped or emitted with a known inconsistency, by reason. A steady rate means the stage timings are missing or skewing samples: negative_elapsed and inverted_window are stages whose clocks disagreed, nonpositive_turn is a finished turn whose accounting was not emitted, and overattributed is a turn whose categories summed to more than its duration.",
0 commit comments