X Tutup
Skip to content

fix(coderd): add role param to agent RPC to prevent false connectivity#22052

Merged
kacpersaw merged 4 commits intomainfrom
kacpersaw/add-role-to-agent-rpc
Feb 18, 2026
Merged

fix(coderd): add role param to agent RPC to prevent false connectivity#22052
kacpersaw merged 4 commits intomainfrom
kacpersaw/add-role-to-agent-rpc

Conversation

@kacpersaw
Copy link
Contributor

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 role query parameter to /api/v2/workspaceagents/me/rpc:

  • role=agent: triggers connection monitoring (default for the agent SDK)
  • any other value (e.g. logstream-kube): skips connection monitoring
  • 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.

Required follow-up

coder-logstream-kube needs to set client.Role = "logstream-kube" before calling ConnectRPC20(). Without that change, it will still send role=agent and trigger monitoring.

Fixes #21625

…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
@kacpersaw kacpersaw changed the title fix: add role query parameter to agent RPC endpoint to prevent false connectivity updates fix(codcerd): add role query parameter to agent RPC endpoint to prevent false connectivity updates Feb 12, 2026
@kacpersaw kacpersaw changed the title fix(codcerd): add role query parameter to agent RPC endpoint to prevent false connectivity updates fix(coderd): add role query parameter to agent RPC endpoint to prevent false connectivity updates Feb 13, 2026
@kacpersaw kacpersaw changed the title fix(coderd): add role query parameter to agent RPC endpoint to prevent false connectivity updates fix(coderd): add role param to agent RPC to prevent false connectivity Feb 13, 2026
@kacpersaw kacpersaw marked this pull request as ready for review February 13, 2026 15:53
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
@kacpersaw kacpersaw merged commit f016d9e into main Feb 18, 2026
27 checks passed
@kacpersaw kacpersaw deleted the kacpersaw/add-role-to-agent-rpc branch February 18, 2026 08:44
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 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.

bug: coder-logstream-kube connections interfere with agent connectivity status

2 participants

X Tutup