fix(coderd): add role param to agent RPC to prevent false connectivity#22052
Merged
fix(coderd): add role param to agent RPC to prevent false connectivity#22052
Conversation
…connectivity updates coder-logstream-kube and other tools that use the agent token to connect to the RPC endpoint were incorrectly triggering connection monitoring, causing false connected/disconnected timestamps on the agent. This led to VSCode/JetBrains disconnections and incorrect dashboard status. Add a 'role' query parameter to /api/v2/workspaceagents/me/rpc: - role=agent: triggers connection monitoring (default for the agent SDK) - any other value: skips connection monitoring (for logstream-kube, etc.) - omitted: triggers monitoring for backward compatibility with older agents The agent SDK now sends role=agent by default. A new Role field on the agentsdk.Client allows non-agent callers to specify a different role. Fixes #21625
spikecurtis
reviewed
Feb 17, 2026
Address review feedback: - Remove exported Role field from agentsdk.Client (race condition risk) - Add role parameter to internal connectRPCVersion() - Add ConnectRPCWithRole() and ConnectRPC28WithRole() public methods - SDK defaults to not sending role (new callers don't trigger monitoring) - Workspace agent explicitly sends role=agent via ConnectRPC28WithRole - Update agent Client interface and agenttest mock
spikecurtis
approved these changes
Feb 18, 2026
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.
Summary
coder-logstream-kube and other tools that use the agent token to connect to the RPC endpoint were incorrectly triggering connection monitoring, causing false connected/disconnected timestamps on the agent. This led to VSCode/JetBrains disconnections and incorrect dashboard status.
Changes
Add a
rolequery parameter to/api/v2/workspaceagents/me/rpc:role=agent: triggers connection monitoring (default for the agent SDK)logstream-kube): skips connection monitoringThe agent SDK now sends
role=agentby default. A newRolefield on theagentsdk.Clientallows non-agent callers to specify a different role.Required follow-up
coder-logstream-kube needs to set
client.Role = "logstream-kube"before callingConnectRPC20(). Without that change, it will still sendrole=agentand trigger monitoring.Fixes #21625