feat: add workspace agent session count protocol - #28125
Draft
EhabY wants to merge 1 commit into
Draft
Conversation
EhabY
force-pushed
the
feat/agent-session-counts-protocol
branch
from
August 13, 2026 16:29
11e05b6 to
f2663f1
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.
Defines Agent API 2.11: a session count per app instead of four fixed counters.
Stats.session_counts, amap<string, int64>, as field 13, and marks fields 8 through 11 deprecated without removing them.DRPCAgentClient211,ConnectRPC211, andConnectRPC211WithRolealongside the existing 2.9 and 2.10 constructors, and bumpsCurrentMinorso coderd accepts 2.11.normalizedSessionCountsreads 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.capSessionCountsbounds a report at 64 names, keeping the known families and then the busiest, and sums the remainder intounknownso no count is lost.HasSessionCountsandClearSessionCountsreplace 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.goalready gates workspace activity onHasSessionCounts, 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.
Validaterejects 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.
agent/proto/agent.pb.gois generated fromagent.protobymake genand is nearly all of the line count; the.gitattributesentry marksagent/proto/*.pb.gogenerated so GitHub collapses it. Worth a close read:agent/proto/agent.protoandcoderd/workspacestats/sessioncounts.go.