Adds organization-scoped Coder Agents instructions. Organization admins
set them in **Admin settings** > **AI** > **Coder Agents** >
**Organization settings**, or with `GET`/`PUT
/api/v2/organizations/{organization}/chats/config/system-prompt`.
Implements [CODAGT-984](https://linear.app/codercom/issue/CODAGT-984).
The instructions add to the deployment system prompt and never replace
it. When a chat is created, chatd stores the organization prompt as its
own system row right after the deployment row, only for chats in that
organization. Subagents resolve their parent organization's current
prompt when they spawn, and existing chats keep their stored rows.
Access reuses the organization `chat_model_config` permission: owners
and organization admins edit, auditors read, members get 404 on read and
403 on write. Writes reuse the deployment prompt's sanitization, size
limit (128 KiB by default), and audit behavior, with a new
`chat_organization_system_prompt` audit resource type. Migration
`000613` (the next number after `000612` on `main`) adds the
`chat_organization_system_prompts` table.
## Testing
- Go: enterprise authorization (including an update-only custom role),
validation, and audit tests; chatd row order and subagent tests.
- Frontend: Vitest interaction tests and stories for the card (loading,
load error, refetch error over the cached value, save error, read-only).
- Remote dogfood UAT, [evidence
chat](https://dogfood.cdr.dev/agents/b595a709-0709-44e6-9535-96a922974d61):
round 1 **PASS** on `b027cb5ca67` (permission matrix, validation, UI,
row order, cross-organization isolation, audit, subagents, regression).
Round 2 **PASS** on `618bff67c75` (loading and load-error states,
refetch error over the cached value with unsaved edits kept, update-only
custom role saves over the API, row order, the documented size limit,
rapid organization switching, double-click save).
- CI: rebased onto `main` (`98332c739b0`) as `3850fbaa922`; other commit
SHAs in this description are from before the rebase. Every check passed
on `3850fbaa922`, with `test-go-pg` green on the first attempt. After
the review fixes in item 7, `main` was merged in as `006c4951749` to
resolve new conflicts in generated files and renumber the migration to
`000613`. Every check passes on `006c4951749`. Before the rebase, every
check passed on `b4e76543df2`. `test-go-pg (ubuntu-latest)` passed on
its fourth attempt; the first three failed only the `cli` package
goroutine leak check, with every test passing. Two of those leaked a
coderd instance, which also happens intermittently on `main`:
`TestServer/Logging` cancels `coder server` during startup, and an early
return in `cli/server.go` skips closing coderd. That fix is in #30280.
The first attempt leaked an idle HTTP connection instead (not
investigated).
## Screenshots
From remote UAT on a test deployment (test data only).
| Organization admin saves instructions (`b027cb5ca67`) | Auditor sees
read-only instructions, no save actions (`b027cb5ca67`) |
|---|---|
| 
| 
|
| **Loading state while the first fetch is pending (`618bff67c75`)** |
**Refetch error shown above the field; the unsaved edit is kept and Save
stays enabled (`618bff67c75`)** |
| 
| 
|
## Review record
1. Codex,
[review](https://github.com/coder/coder/pull/30272#pullrequestreview-5387245297)
on `c42b5f9e05c`: 6 findings. Fixed the missing loading state, refetch
failures hiding cached instructions, and two docs style issues
(`58eab5603a4`, `cc73b714630`). Two were first declined in error, then
corrected: the read-only test now checks that typing leaves the value
unchanged (`cc73b714630`), and update-only custom roles no longer get a
500 on save (`618bff67c75`).
2. Independent security review by a clean-context agent,
[comment](https://github.com/coder/coder/pull/30272#issuecomment-5943505041)
on `c42b5f9e05c`: no P0 to P2 findings. A stale P3 comment was fixed in
`34c17aadb7f`; returning `err.Error()` in 500 details was kept to match
the deployment prompt handlers.
3. Codex,
[review](https://github.com/coder/coder/pull/30272#pullrequestreview-5387323380)
on `58eab5603a4`: 2 findings (refetch errors not surfaced, docs line
breaks), both fixed in `cc73b714630`.
4. Codex, blockers only,
[review](https://github.com/coder/coder/pull/30272#pullrequestreview-5387462070)
on `618bff67c75`: 1 P2 (a failed refresh right after a successful save
shows the previous value). Not a blocker, deferred.
5. Final fresh advisory by a clean-context agent,
[comment](https://github.com/coder/coder/pull/30272#issuecomment-5944285083)
on `618bff67c75`: **READY**, no blockers and nothing to cut. It
independently checked authorization, audit, the migration, chatd row
insertion and subagent inheritance, the tests, and soft-deleted
organization handling, and agreed with every deferral. No code changes
followed: the snapshot behavior it suggested documenting is already
documented, and its docs wording note joins the deferred docs item.
6. Codex,
[comment](https://github.com/coder/coder/pull/30272#issuecomment-5952100918)
on `b4e76543df2` (the docs-only follow-up below): no major issues. Mike
asked for a passing Codex review loop after item 5, so this review goes
past the planned stop at the final advisory. No code changes followed.
7. ethanndickson,
[review](https://github.com/coder/coder/pull/30272#pullrequestreview-5409332502)
on `3850fbaa922`: approved with 4 comments. Fixed 3: the audit target is
now empty (`91e77d3fa8c`), the docs no longer re-explain audit logs
(`a0fb6891af5`), and the organization instructions stories went from 9
to 5 (`e836097f93f`). Not fixed: the organization prompt read fails open
on a database error, like the deployment prompt, and ethanndickson is
changing both after merge
([thread](https://github.com/coder/coder/pull/30272#discussion_r4180191267)).
UAT did not rerun for these changes.
Not counted as reviews: the pre-PR frontend self-review, simplify pass,
and test audit (`de8377e94e1`), and a second test audit of
`de8377e94e1..cc73b714630` (pass with nits; the update-only test case
was added after it).
Docs-only follow-up after the advisory, requested by Mike: `b4e76543df2`
adds audit log guidance for prompt changes to the platform controls page
and an update-only custom role note to the organizations page. Codex
reviewed it (item 6). No UAT covers it, and the code is unchanged since
`618bff67c75`. The deferred claim that the Instructions page path is
outdated was wrong, so it's dropped. Item 7 removed the audit log
guidance again; the custom role note stays.
## Soft-deleted organizations
UAT found that a soft-deleted organization's prompt stays readable and
writable by UUID. This is inherited behavior, not new exposure:
`ExtractOrganizationParam` resolves UUIDs without a deleted filter, so
the sibling organization chat routes (MCP servers, model overrides,
models) behave the same. The same `chat_model_config` RBAC still
applies, nobody gains access to another organization, and writes are
audited.
## Deferred (owner: Mike)
- A failed refresh right after a successful save shows the previous
value with an error alert, so a further edit from that view starts from
the old text (Codex round 4, UAT round 2). Trigger: reports of stale
values after saving on unreliable networks.
- Update-only custom roles can save over the API, but the card stays
hidden without read access. Trigger: a customer uses such a role.
- Soft-deleted organization access by UUID, above. Trigger: the platform
starts rejecting deleted organizations in `ExtractOrganizationParam` or
purging their configuration.
- A contrived "code word" instruction was refused as possible prompt
injection; neutral instructions work. Trigger: reports of ignored
organization instructions.
- UX polish: there is no retry action after a failed first load, the
save toast can cover Cancel, there is no unsaved-changes guard, the
oversize error omits the limit, and whitespace-only text clears the
prompt without notice. Trigger: the next settings UX pass.
- Docs: the 413 response and organization name paths are undocumented.
Trigger: the next Coder Agents docs pass.
- Test audit nits: a redundant `waitFor` and an optional read-only plus
refetch story. Trigger: the next change to these tests.
> Xum, an AI coding agent, implemented, tested, and opened this PR on
behalf of @ibetitsmike.
16 KiB
title
| title |
|---|
| Getting started |
This guide walks platform teams and administrators through setting up Coder Agents, preparing your deployment, and running your first Coder Agent.
Prerequisites
Before you begin, confirm the following:
- Coder deployment running the latest release.
- LLM provider credentials — an API key for at least one supported provider (Anthropic, OpenAI, Google, Azure OpenAI, AWS Bedrock, OpenAI Compatible, OpenRouter, or Vercel AI Gateway).
- Network access from the control plane to your LLM provider. Workspaces do not need LLM access — only the control plane does.
- At least one template with a descriptive name and description for the agent to select when provisioning workspaces.
- Admin access to the Coder deployment for configuring providers.
- Access to configure models in each organization where you configure models. The Organization Admin role and the Owner role include this access. A custom role with model configuration access also works.
- Organization membership for each user who uses Coder Agents. Every organization member can use Coder Agents by default. To restrict access, see Control who can use Coder Agents. Users also need read access to at least one model in the organization. New models are shared with the whole organization by default. See Manage model permissions.
Step 1: Configure an LLM provider and model
Important
Deployment administrators configure providers and deployment settings. Users with model configuration access in an organization configure that organization's models. Coder enables the edit controls for the organization that you select. Coder shows the deployment settings only to deployment administrators. Users with model access can view the relevant Models and Coder Agents pages. Users with MCP server access can open the MCP servers page.
To configure Coder Agents:
- Navigate to Admin settings > AI and select Providers.
- Add or update a provider with its credentials and upstream endpoint, then save it.
- Navigate to Admin settings > AI > Models.
- Select the correct organization. Coder shows the organization picker when you can access more than 1 organization.
- Select Add model and configure at least one model with its identifier, display name, and context limit.
Coder makes the first model of an organization the default model. To change the default later, open a model and select Set as Coder Agents default model, or pick a model in the Default model row under Admin settings > AI > Coder Agents > Organization settings.
Each organization has its own model list and its own default model. Repeat the model steps in every organization that uses Coder Agents. Refer to Organization scope for the settings that stay deployment-wide.
Detailed instructions for each provider and model option are in the Models documentation.
Tip
Start with a single frontier model to validate your setup before adding additional providers.
Step 2: Start your first Coder Agent
- Go to the Agents page in the Coder dashboard.
- Select a model from the dropdown (your default will be pre-selected).
- Type a prompt and send it.
The agent processes the prompt in the control plane. When the conversation and available tools are sufficient, it works without provisioning a workspace. If missing tools, skills, MCP integrations, or context block progress, the agent selects a template and provisions a workspace to continue. It also provisions a workspace for tasks that need file access, command execution, or code changes.
Control who can use Coder Agents
Organization members can use Coder Agents by default.
Access comes from the Coder Agents User (agents-access) organization role, which each organization grants to members through its default member roles.
Members who don't hold the role directly lose Coder Agents access when you remove Coder Agents User from the default roles. Role sync assigns roles at sign-in and doesn't store default roles, so members who get the role through role sync regain access at their next sign-in, and mapping the role in advance doesn't shorten the gap.
To limit Coder Agents to a subset of members in an organization (requires a Premium license):
- Remove Coder Agents User from the organization's default roles.
In the dashboard, go to Admin settings > Organizations > Roles > Default Roles.
From the CLI, run
coder organizations edit --org <organization> --default-org-member-roles organization-workspace-access, keeping any other default roles in the list. - Grant
agents-accessto the members who need it:- With IdP organization role sync, map an IdP group or role to
agents-access. - Without role sync, assign Coder Agents User from Admin settings > Organizations > Members.
- With IdP organization role sync, map an IdP group or role to
Keep the following behavior in mind:
- Removing a user from the mapped IdP group or role removes their Coder Agents access at their next sign-in.
- Owners and Organization Admins can always use Coder Agents, whatever the default roles are.
- Service accounts don't inherit
agents-accessfrom the default roles. Assign the role to a service account directly if it needs Coder Agents. - Members without the role can't use Coder Agents or open chats they created earlier. Their chats are kept and become available again when they regain the role. A chat shared with them stays readable.
- Model permissions still apply: users also need read access to at least one model.
Optimize your templates
The agent selects templates based on their name, description, and README. It does not read Terraform. Clear, specific descriptions are the most important factor in whether the agent picks the right template.
Update your template descriptions to include:
- The language, framework, or stack the template targets.
- Which repository or service it is for, if applicable.
- What type of work it supports (backend, frontend, data pipeline, etc.).
When 128 characters is not enough, put the most important routing context near
the top of the template's
README.md.
The chat agent's template listing includes a bounded README excerpt (roughly the
first 1,000 characters), and template detail includes the README (up to roughly
8,000 characters). Both are reduced to plain text: frontmatter is stripped,
link text is kept while link URLs are dropped, images and badges are dropped
entirely, and code blocks and tables are preserved as text.
Good examples:
| Description | Why it works |
|---|---|
| Python backend services for the payments repo. Includes Poetry, Python 3.12, and PostgreSQL | Specific language, repo, and toolchain |
| React frontend development for the customer portal. Node 20, pnpm, Storybook pre-installed | Clear stack, named project, key tools listed |
| General-purpose Go development environment with Go 1.23, Docker, and common CLI tools | Broad but descriptive |
Descriptions to avoid:
| Description | Problem |
|---|---|
| Team A template v2 | No information about what the template is for |
| Dev environment | Too generic to distinguish from other templates |
| Default | Tells the agent nothing |
See Template Optimization for the full guide, including dedicated agent templates, network boundaries, credential scoping, and pre-installing dependencies.
Things to know before you start
Plan for change between releases
Coder Agents is generally available. However, APIs, behavior, and configuration may change between releases. As always, you should review release notes and the changelog before upgrading, so changes do not affect production.
Use HTTPS for push notifications
Coder Agents use browser push notifications to alert you when a task completes or needs attention. Most browsers require a secure (HTTPS) origin for the Push API to work. If your access URL uses plain HTTP, push notifications may not function.
This does not affect agents themselves — only the browser notification
delivery. If you terminate TLS at a reverse proxy, ensure the
access URL is configured with an https:// scheme.
Set a deployment-wide system prompt
Administrators can set a system prompt that applies to all Coder Agents across the deployment. Use this to encode organizational conventions:
- Coding standards and style guidelines.
- Commit message formats.
- Branch naming conventions.
- Required review processes before merging.
- Any guardrails specific to your environment.
Configure the system prompt from Admin settings > AI > Coder Agents > Instructions
or via the API at PUT /api/v2/chats/config/system-prompt.
In a deployment with several organizations, organization administrators can also add organization instructions under Admin settings > AI > Coder Agents > Organization settings. Coder adds them after the deployment system prompt for new chats in that organization. Refer to Platform Controls for details.
Understand the security model
The agent runs in the control plane, not inside workspaces. This means:
- No LLM API keys in workspaces. Credentials stay in the control plane.
- No agent software in workspaces. No supply chain risk from third-party agent tools.
- User identity is always attached. Every action is tied to the user who submitted the prompt — no shared bot accounts.
- No privilege escalation. The agent has exactly the same permissions as the prompting user.
Agent workspaces inherit the same network access as any manually created workspace. If your templates don't restrict egress, the agent has full internet access from the workspace. Consider creating dedicated agent templates with tighter network policies.
Plan for LLM costs
Every conversation turn sends tokens to your LLM provider. Long-running tasks, sub-agent delegation, and complex multi-step work can consume significant token volume. Consider:
- Starting with a single model to establish a cost baseline.
- Capping spend with AI Gateway budgets.
- Monitoring provider dashboards for usage trends as adoption grows.
Plan for concurrency limits
Community licenses run up to 5 agents at once. Additional agents queue and start automatically when capacity frees. A Premium license with Agent Hours does not impose a concurrency limit unless the Agent Hours hard limit is reached. If the Agent Hours allocation is exhausted without a configured hard limit, Coder warns about usage but does not impose a concurrency limit. When the Agent Hours hard limit is reached, additional agents queue under the concurrency limit. Refer to Concurrent agents for details.
Pilot with a small group
Identify 3–5 developers and a few concrete use cases for the initial rollout. Good starting points:
- Low-risk, high-visibility tasks — generating unit tests, writing inline documentation, small refactors.
- Investigation and triage — exploring unfamiliar code, triaging bugs, understanding legacy systems.
- Prototyping — building proof-of-concept implementations, simple dashboards, internal tools.
To limit Coder Agents to the pilot group, see Control who can use Coder Agents.
Set expectations for how the team reviews agent output. Developers should still review all agent-produced code before merging. The agent is a force multiplier, not a replacement for developer judgment.
Use the API for programmatic automation
The Chats API enables programmatic access to Coder Agents. This is useful for building automations such as:
- Triggering Coder Agents from CI/CD pipelines when builds fail.
- Creating Coder Agents from GitHub webhooks on new issues or PRs.
- Building internal tools or dashboards on top of the API.
- Scripting batch operations across repositories.
Quick example — create a Coder Agent via the API:
curl -X POST https://coder.example.com/api/v2/chats \
-H "Coder-Session-Token: $CODER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": [
{"type": "text", "text": "Fix the failing tests in the auth service"}
]
}'
Stream updates in real time by connecting to the WebSocket endpoint:
GET /api/v2/chats/{chat}/stream
For service-to-service automation, use API keys rather than developer session tokens. Keep automation credentials narrowly scoped.
Link to a new chat with a prompt
To send users to a new chat with a message already written, link to /agents with a prompt query parameter.
URL-encode the message (for example, with encodeURIComponent in JavaScript):
https://coder.example.com/agents?prompt=Fix%20the%20failing%20tests%20in%20the%20auth%20service
The link fills in the message box only. Coder doesn't send the message: the user reviews it, can edit it, and selects Send. Because any website can create such a link, a warning in the message box asks the user to take care before sending. The warning disappears once the user edits the message.
If the user isn't signed in, Coder keeps the message through sign-in.
Don't put secrets in these links. URLs end up in browser history and server logs.
Add workspace context with AGENTS.md
Create an AGENTS.md file in the home directory (~/.coder/AGENTS.md) or
the workspace agent's working directory to provide persistent context to the
agent. This file is automatically read and included in the system prompt
for every conversation with a Coder Agent that uses that workspace.
Use it for:
- Repository-specific build and test instructions.
- Important architectural decisions or constraints.
- Links to relevant documentation or runbooks.
- Any context that helps the agent work effectively in that codebase.
Consider prebuilt workspaces for faster startup
Workspace provisioning is the main source of latency when the agent starts a task. If your templates take more than a minute to provision, consider configuring prebuilt workspaces to maintain a pool of ready-to-use workspaces. The agent gets assigned an already-running workspace instead of provisioning from scratch.
Provide feedback
Report bugs and feature requests as GitHub issues. For deployment-specific problems, such as provider configuration or performance in your environment, use your usual Coder support channel.
Good reports include:
- What you tried: the prompt, the template, and the model.
- What happened: the agent's behavior, any errors, and unexpected results.
- What you expected: the outcome you were looking for.
- Context: screenshots,
chat_idvalues, or links to the Agents page help the team investigate quickly.
Next steps
- Architecture — how the control plane, LLM providers, and workspaces interact.
- Models — configure additional providers and models.
- Platform Controls — system prompts, template routing, and admin-level configuration.
- Template Optimization — create agent-friendly templates with network boundaries and scoped credentials.
- Chats API: build programmatic integrations.