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

Skip to content

feat: add workspace agent session count protocol - #28125

Merged
EhabY merged 1 commit into
mainfrom
feat/agent-session-counts-protocol
Aug 21, 2026
Merged

feat: add workspace agent session count protocol#28125
EhabY merged 1 commit into
mainfrom
feat/agent-session-counts-protocol

Conversation

@EhabY

@EhabY EhabY commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Defines Agent API 2.11: a session count per app instead of four fixed counters.

  • Adds Stats.session_counts, a map<string, int64>, as field 13, and marks fields 8 through 11 deprecated without removing them.
  • Adds DRPCAgentClient211, ConnectRPC211, and ConnectRPC211WithRole alongside the existing 2.9 and 2.10 constructors, and bumps CurrentMinor so coderd accepts 2.11.
  • normalizedSessionCounts reads the map, normalizes names, drops non-positive counts, and falls back to the deprecated fields only when the map yields nothing, so one ingestion path serves old and new agents.
  • capSessionCounts bounds a report at 64 names, keeping the known families and then the busiest, and sums the remainder into unknown so no count is lost.
  • HasSessionCounts and ClearSessionCounts replace the two places that spelled the four fields out by hand.

The agent still connects on 2.10 and the helpers are not on the write path yet, so a 2.11 report would be accepted here but its map not stored. That only matters if coderd is rolled back to this commit while a newer agent is running, and it costs the per-app counts and nothing else: reporter.go already gates workspace activity on HasSessionCounts, which reads the map, so such a report still bumps activity and the workspace is not treated as idle.

The bump belongs ahead of the agent rather than alongside it. Validate rejects a requested minor above the server's, and the agent does not negotiate down, so a coderd advertising 2.10 refuses a 2.11 agent outright. Advertising first keeps the skew in the safe direction.

The version bump lives here so the whole version story, the field, the client constructors, and the advertised version, reads in one diff.

Depends on #28124. Phase 2 of #27410.

@EhabY
EhabY force-pushed the feat/agent-session-counts-protocol branch from 11e05b6 to f2663f1 Compare August 13, 2026 16:29
@EhabY
EhabY force-pushed the feat/agent-session-counts-protocol branch from f2663f1 to c86cdf4 Compare August 18, 2026 13:05
@EhabY
EhabY force-pushed the feat/agent-session-counts-protocol branch 2 times, most recently from 7994907 to de7f84c Compare August 19, 2026 14:14
@EhabY
EhabY force-pushed the feat/agent-session-counts-protocol branch from de7f84c to 4f7fba6 Compare August 19, 2026 23:25
@EhabY
EhabY force-pushed the feat/agent-session-counts-protocol branch 2 times, most recently from 8f503a2 to 32f11a1 Compare August 20, 2026 12:28
@EhabY
EhabY marked this pull request as ready for review August 20, 2026 12:38
@EhabY
EhabY requested a review from code-asher August 20, 2026 12:38

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on who gets in first, you may need to rebase on another PR that adds proto version 2,11.

Comment thread tailnet/proto/version.go
Comment thread .gitattributes
Comment thread coderd/workspacestats/sessioncounts.go Outdated
Comment thread coderd/workspacestats/sessioncounts.go Outdated
Base automatically changed from refactor/normalize-agent-session-metadata to main August 20, 2026 23:22
@EhabY
EhabY force-pushed the feat/agent-session-counts-protocol branch 3 times, most recently from 9709052 to 037ebc7 Compare August 20, 2026 23:54
@EhabY
EhabY force-pushed the feat/agent-session-counts-protocol branch from 037ebc7 to 5f2b3ab Compare August 21, 2026 00:04
@EhabY
EhabY merged commit 903d7b7 into main Aug 21, 2026
24 checks passed
@EhabY
EhabY deleted the feat/agent-session-counts-protocol branch August 21, 2026 00:14
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants