feat(coderd/x/chatd): record capacity wait as a lifecycle stage - #28973
Draft
jscottmiller wants to merge 1 commit into
Draft
feat(coderd/x/chatd): record capacity wait as a lifecycle stage#28973jscottmiller 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/5-turn-span
branch
from
September 9, 2026 23:19
02c8b6d to
a2ad5b2
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 9, 2026 23:19
773324f to
b901eb5
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 11, 2026 02:25
b901eb5 to
09ef319
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/5-turn-span
branch
from
September 11, 2026 02:26
a2ad5b2 to
3363b52
Compare
The acquisition loop remembers when each chat was first refused a capacity slot and, on the acquisition that follows, emits a capacity_wait stage measured from that first refusal. Chats admitted on their first attempt record nothing. Wait starts are dropped when a chat is skipped for a reason other than capacity, and pruned when a batch short enough to hold every candidate no longer lists the chat.
jscottmiller
force-pushed
the
scott/chatd-stages/5-turn-span
branch
from
September 11, 2026 19:17
3363b52 to
926fabc
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 11, 2026 19:17
09ef319 to
388e95d
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.
The acquisition loop remembers when each chat was first refused a concurrent-agent capacity slot and, when the chat is eventually acquired, records a
capacity_waitstage from that first refusal. Chats admitted on their first attempt record nothing.Bookkeeping: the wait start is dropped when a candidate is skipped for a reason other than capacity (owned by a live runner, archived, not runnable), and stale entries are pruned only when the candidate batch is shorter than its limit, since a chat missing from a truncated batch is still waiting. Timestamps come from the worker clock. The map is only touched by the acquisition goroutine.
capacity_waitis a per-occurrence stage only: it is measured before the turn exists and its window lies insideacquisition.Multi-replica caveat. The refusal history is in-memory and per worker, while the capacity limit is deployment-wide. The recorded wait is therefore a lower bound: a chat refused on one replica and acquired by another is measured from the acquiring replica's own first refusal, and is not recorded at all if that replica admitted it on its first attempt. A replica restart discards its history. Because all replicas are woken together by the
chat:ownershiphint when a chat becomes acquirable, and the refusal rollback suppresses the hint so retries fall back to each replica's own 30s acquisition timer, the undercount is bounded by roughly one acquisition interval rather than growing with replica count. An accurate deployment-wide measurement would need the first refusal persisted on the chat row.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.