Repository navigation
feat(coderd/x/chatd): record capacity wait as a lifecycle stage - #28973
Closed
jscottmiller wants to merge 1 commit into
Closed
jscottmiller 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/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/6-capacity-wait
branch
from
September 11, 2026 19:17
09ef319 to
388e95d
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 14, 2026 20:16
388e95d to
8a9b2b9
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 14, 2026 22:06
8a9b2b9 to
e088fd5
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 15, 2026 21:39
e088fd5 to
374d503
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 16, 2026 03:12
374d503 to
86f721b
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 17, 2026 16:55
86f721b to
6021e64
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 17, 2026 20:31
6021e64 to
d5a1357
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 17, 2026 21:26
d5a1357 to
2e4f1de
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 21, 2026 00:09
2e4f1de to
68dc259
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 21, 2026 22:52
68dc259 to
2e9bde2
Compare
jscottmiller
force-pushed
the
scott/chatd-stages/6-capacity-wait
branch
from
September 23, 2026 01:37
2e9bde2 to
09bc9cf
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/6-capacity-wait
branch
from
September 23, 2026 02:15
09bc9cf to
e697290
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 #29771. Closed in favor of the reduced stack #29773.
The acquisition loop remembers when each chat was first refused a concurrent-agent capacity slot and, when the chat is acquired, records a
capacity_waitstage from that refusal. Chats admitted on their first attempt record nothing. The stage is recorded before the runner is spawned, so a failed spawn still records the wait.Bookkeeping: the wait start is dropped when a candidate is skipped for a non-capacity reason (live runner, archived, not runnable) and pruned only when the candidate batch is shorter than its limit, since a chat missing from a truncated batch is still waiting. The map is touched only by the acquisition goroutine.
capacity_waitis a per-occurrence stage only: it is measured before the turn exists and its window lies insideacquisition, so the turn accounting in PR 7 does not categorize it. ARCHITECTURE.md gains a "Capacity wait" section.Multi-replica caveat. The refusal history is per worker and in memory while the limit is deployment-wide, so the value is a lower bound: a chat refused on one replica and acquired by another is measured from the acquiring replica's first refusal, or not at all if it was admitted first try, and a restart discards history. All replicas wake together on the
chat:ownershiphint and refusal suppresses it, so retries fall back to each replica's 30s acquisition timer and the undercount is bounded by about one interval rather than growing with replica count. An exact measurement would need the first refusal persisted on the chat row.🤖 This PR was generated by Coder Agents on behalf of @jscottmiller.