Repository navigation
feat: account chatd turn time by stage and category - #28974
Closed
jscottmiller wants to merge 1 commit into
Closed
jscottmiller wants to merge 1 commit into
jscottmiller wants to merge 1 commit into
Conversation
Contributor
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
This was referenced Sep 4, 2026
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 9, 2026 23:19
422889e to
fbf8b65
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 11, 2026 02:25
fbf8b65 to
2eec66e
Compare
ibetitsmike
approved these changes
Sep 11, 2026
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 11, 2026 19:17
2eec66e to
948b3e7
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
2 times, most recently
from
September 14, 2026 20:34
186d94e to
4bb7e06
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 14, 2026 22:06
4bb7e06 to
52c1757
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 15, 2026 21:39
52c1757 to
323511d
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 16, 2026 03:12
323511d to
7cbf824
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 17, 2026 16:55
7cbf824 to
6957249
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
2 times, most recently
from
September 17, 2026 21:26
b9ee64c to
d9a6dac
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
2 times, most recently
from
September 21, 2026 22:52
ea98e23 to
d49be1a
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 23, 2026 01:37
d49be1a to
c3dceec
Compare
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 and category partition are observed once on the turn histograms; a turn closed interrupted, in error, or abandoned drops its accounting and is counted under that outcome, so every closed turn has exactly one outcome. Turns whose duration is not positive or whose categories overrun it are counted as anomalies. The per-turn families are labelled by chat kind only; a turn is not a model-scoped unit, and per-model time is on coderd_chatd_model_stage_duration_seconds. The organization name and reasoning effort stay span attributes. coderd_chatd_turn_time_seconds_total, turns_total, and turn_outcomes_total are registered at the basic and full stage metrics levels; the per-turn distributions (turn_stage_seconds, turn_time_seconds, turn_time_share) are registered only at full. The per-turn histograms use an 11-bucket ladder from 1s to 1h, since sub-second resolution carries nothing for a value summed over a turn.
jscottmiller
force-pushed
the
scott/chatd-stages/7-turn-accounting
branch
from
September 23, 2026 02:15
c3dceec to
22937d0
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Superseded by #29772. Closed in favor of the reduced stack #29773.
When a turn finishes normally, its stages are rolled up and emitted once, labelled by
chat_kindplusstage,category, oroutcomewhere the family has one. The turn families carry nomodelor organization label: a turn is not a model-scoped unit (subagents, compaction summaries, and model switches can run inside one), and per-model time is oncoderd_chatd_model_stage_duration_seconds. The first model a turn resolves is stamped on thechat_turnspan. Interrupted, errored, and abandoned turns emit no accounting.turn_outcomes_total{outcome, chat_kind}completed,interrupted,error,abandonedturn_time_seconds_total{category, chat_kind},turns_total{chat_kind}rate(a)/rate(b)is mean seconds per turn by categoryturn_time_seconds,turn_time_share{category, chat_kind}turn_stage_seconds{stage, chat_kind}completedequalsturns_totalexcept for non-positive-duration turns (stage_anomalies_total{reason="nonpositive_turn"}). Keeping the partition atbasicas counters costs 16 series per chat kind instead of the 418 the two histograms would. The accumulator runs at every level, so the partition is complete atbasiceven for stages the level leaves span-only. Per-turn histograms use an 11-edge ladder from 1s to 1h;turn_time_shareuses twentieths. Occurrence counts and per-stage shares per turn are left to traces.How the partition is built
Nested stages share wall time with their parents, so summing durations over-counts. The partition assigns each stage's own time (duration minus its attributing children) to one category: a
TurnAccumulatorrides on the turn context, each attributing stage reports its full duration to its parent when it ends, and the parent's category receives what is left.provider_attempt,thinking,tool_call, andcapacity_waitappear in the per-stage totals but never claim time from a parent: each lies inside a stage that is already categorized. Only turn-scoped stages report to the accumulator, live or reconstructed, so background work never lands in a turn;EndWithoutObservationreports too, so a stream that never produced a token still counts. Categories that sum to more than the turn are emitted as measured and counted asoverattributed.Also:
SetGenerationActionreplaces the raw attribute call at the step site; ARCHITECTURE.md gains a "Turn accounting" section.🤖 This PR was generated by Coder Agents on behalf of @jscottmiller.