Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(coderd/x/chatd): record capacity wait as a lifecycle stage - #28973

Draft
jscottmiller wants to merge 1 commit into
scott/chatd-stages/5-turn-spanfrom
scott/chatd-stages/6-capacity-wait
Draft

feat(coderd/x/chatd): record capacity wait as a lifecycle stage#28973
jscottmiller wants to merge 1 commit into
scott/chatd-stages/5-turn-spanfrom
scott/chatd-stages/6-capacity-wait

Conversation

@jscottmiller

@jscottmiller jscottmiller commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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_wait stage 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_wait is a per-occurrence stage only: it is measured before the turn exists and its window lies inside acquisition.

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:ownership hint 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.

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
jscottmiller force-pushed the scott/chatd-stages/5-turn-span branch from 3363b52 to 926fabc Compare September 11, 2026 19:17
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 09ef319 to 388e95d Compare September 11, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Changes that might not necessarily be merged, until its approved to proceed with.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant