Skip to content

feat(registry/coder/templates): add Agent Relay templates for Kubernetes and Docker - #1225

Draft
dluman wants to merge 4 commits into
mainfrom
feat/agent-relay-templates
Draft

dluman wants to merge 4 commits into
mainfrom
feat/agent-relay-templates

Conversation

@dluman

@dluman dluman commented Oct 30, 2026 •

Copy link
Copy Markdown

Description

Adds two minimal templates that serve Agent Relay sessions for both Claude Code and Cursor, one ephemeral workspace per session:

  • kubernetes-agent-relay: one Kubernetes Pod per session.
  • docker-agent-relay: one Docker container per session.

Each pool selects its runner through template_parameters (self_hosted_provider = claude or cursor), and only that runner's module is instantiated. Both templates use agent-relay-claude-code / agent-relay-cursor, report the required agent_relay_status metadata, declare the github external auth as optional, and add git-config. Each keeps one prebuilt workspace per provider, through a preset that pins only self_hosted_provider, so a session claims a running workspace instead of starting cold.

The READMEs carry the template-side guidance from the Agent Relay deployment guides: template settings (job cancellation, ACL, no quota, finite TTL, dormancy deletion), dedicated provisioners, image requirements, default-deny egress with the minimum hosts per provider, and log retention.

Both templates pin agent-relay-claude-code and agent-relay-cursor to 1.0.0, which receive the relay's credential as an ephemeral workspace secret. That requires Coder 2.39.0 and Agent Relay v0.14.0 or newer; the module comments and READMEs give 0.4.0 / 0.7.0 as the pins for older deployments.

Important

Draft until Coder 2.39.0 and Agent Relay v0.14.0 are released, so the templates can be exercised end to end.

Type of Change

  • New template

Template Information

Path: registry/coder/templates/kubernetes-agent-relay, registry/coder/templates/docker-agent-relay

Testing & Validation

  • Code formatted (terraform fmt -check, prettier --check)
  • README validation (go run ./cmd/readmevalidation)
  • scripts/terraform_validate.sh passes for both against the published 1.0.0 modules
  • Docker: terraform apply against a local daemon created the container (image pulled on demand), and destroy cleaned it up. No Coder deployment was involved, so no relay session ran.
  • Docker prebuild claim, simulated locally: applied as the prebuilds user, then planned with a new owner and name, CODER_WORKSPACE_IS_PREBUILD_CLAIM=true and the reused agent token. The container updates in place rather than being replaced.
  • Kubernetes prebuild claim (no cluster available here; the Pod follows the same pattern as an existing in-cluster relay template whose claims reuse the running Pod)
  • End-to-end relay session on Coder 2.39.0 and Agent Relay v0.14.0 (blocked on releases)

Related Issues

Decision log
  • One template per platform, both providers in each. Matches the registry's one-template-per-infrastructure layout. Provider-specific variants were dropped to keep the surface small; the provider is a pool-level parameter.
  • Kept self_hosted_provider as the parameter name so existing pool template_parameters work unchanged.
  • Image, CPU and memory are template variables, not parameters. The build's parameters stay the relay's contract, so the presets only need to pin self_hosted_provider.
  • Presets pin only self_hosted_provider. A build claims a prebuild only when every preset parameter is in the request with an equal value, and the relay sends only its own parameters plus the pool's template_parameters. One instance each, expired hourly so a session never starts on a stale :latest image or CLI.
  • arch = "amd64": ghcr.io/coder/agent-relay-workspace:latest is published for amd64 only.
  • No volume, restart_policy = "Never" (Kubernetes), 30s grace / stop timeout: the relay deletes the workspace when the runner exits, and the modules' stop scripts need about 30s.
  • Docker follows the docker template (socket variable, host.docker.internal rewrite) except for naming. A claim changes owner and workspace name, and Docker replaces a container whose name, hostname or labels change, so the container is named coder-<workspace id>, sets no hostname and carries only a coder.workspace_id label. The agent token is reused across a claim, so env is stable. The Kubernetes Pod is named by workspace ID and keeps owner data in labels and annotations, which patch in place.
  • agent_relay_session_attached metadata added (optional in the module READMEs) so an operator can see whether a runner holds a session.
  • install_cli left at its default, with a comment. It is a no-op when the CLI is on PATH; forcing false would break anyone who swaps in an image without the CLIs.
  • Provisioner tags documented, not set. A hard-coded coder_workspace_tags would leave builds pending on deployments without matching provisioners.
  • Deployment guides not linked. Agent Relay is in closed preview, so the READMEs link only coder.com docs and Anthropic's and Cursor's network pages.
  • Not included, documented in each README: IDEs, and repository-scoped Cursor pools. Those need a checkout and coder_agent.dir pointing at it, and the Cursor module does not expose agent_relay_cursor_repo_url to the template (no output or env), so a template cannot clone the pool's repository today.

Raised by Coder Agents on behalf of @dluman.

@dluman

dluman commented Oct 30, 2026

Copy link
Copy Markdown
Author

@matifali, @Emyrk -- are we targeting 1.0 for beta or holding that tag for GA?

@matifali

Copy link
Copy Markdown
Member

@dluman I just published them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants