Repository navigation
feat: add organization-scoped Coder Agents instructions - #30272
Conversation
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
|
@codex review
|
Security and authorization review (review pass 2 of at most 6)Reviewed commit: Verdict: go with minor follow-ups. No P0, P1, or P2 findings. P3 findings and disposition
Checked with no findings
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c42b5f9e05
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58eab5603a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 618bff67c7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Final advisory (review pass 5 of at most 6)Reviewed commit: Recommendation: READY. No blockers, and nothing to cut or split. Checked independently
Taken from evidence, not re-verified: UAT verdicts and screenshots, frontend states, docs content, and the review history. Non-blocking notes: Disposition: no code changes, because rounds 4 to 6 address blockers only. The snapshot behavior is already documented (
|
|
@codex review
|
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Add a per-organization chat system prompt that organization admins can
set. New chats created in the organization, including subagents, get the
organization instructions after the deployment instructions. Existing
chats are not affected.
- Storage: chat_organization_system_prompts table (migration 000608),
queries, dbauthz checks, audit table entry.
- API: GET/PUT /api/v2/organizations/{organization}/chats/config/system-prompt
with invisible-character sanitization and the shared prompt length limit.
- chatd: resolve the organization prompt at chat creation and subagent
spawn.
- UI: Organization instructions card on the organization agent settings
page, read-only for viewers.
- Docs: platform controls, organizations, architecture, best practices.
… organization instructions expose no save action
…uctions in the prompt size limit
…on prompt read comment
…ached prompt on refetch failure Address Codex review findings: add a Loader during initial prompt fetch (FE5), treat a background refetch error with cached data as a non-blocking issue instead of replacing the form with an error alert, and fix docs DOC1 and DOC6 violations.
Address Codex review round 3. Show a failed background refetch inline above the cached organization instructions instead of hiding it, so administrators know the value may be stale while their draft stays editable. Cover the refetch path with a Vitest test and a story, and make the read-only test assert only the unchanged value. Also put each added docs sentence on its own source line.
Address Codex review round 1. The update handler read the previous organization instructions for the audit diff with the caller's context, so a custom role that grants chat_model_config update without read returned 500. Read the previous value under a system context after the explicit update check, as the organization model override handler does, and cover the role in the authorization test.
…ntries and update-only roles
b4e7654 to
3850fba
Compare
| // Fail open: the deployment prompt still applies. | ||
| p.logger.Warn(ctx, "failed to fetch organization chat system prompt, omitting it", | ||
| slog.F("organization_id", organizationID), slog.Error(err)) | ||
| } |
There was a problem hiding this comment.
This is so weird, but apparently its the pattern?
I think we should stop doing it, for reasons mentioned in the issue, but probably in a separate PR. I'll fix it after this is merged.
There was a problem hiding this comment.
Agreed, and leaving it as is in this PR, since you're taking it in a follow-up. It matches resolveDeploymentSystemPrompt just above, which also falls back on a database error, so CODAGT-1330 can change both together.
Xum, an AI coding agent, replied on behalf of @ibetitsmike.
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.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_configpermission: 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 newchat_organization_system_promptaudit resource type. Migration000613(the next number after000612onmain) adds thechat_organization_system_promptstable.Testing
b027cb5ca67(permission matrix, validation, UI, row order, cross-organization isolation, audit, subagents, regression). Round 2 PASS on618bff67c75(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).main(98332c739b0) as3850fbaa922; other commit SHAs in this description are from before the rebase. Every check passed on3850fbaa922, withtest-go-pggreen on the first attempt. After the review fixes in item 7,mainwas merged in as006c4951749to resolve new conflicts in generated files and renumber the migration to000613. Every check passes on006c4951749. Before the rebase, every check passed onb4e76543df2.test-go-pg (ubuntu-latest)passed on its fourth attempt; the first three failed only theclipackage goroutine leak check, with every test passing. Two of those leaked a coderd instance, which also happens intermittently onmain:TestServer/Loggingcancelscoder serverduring startup, and an early return incli/server.goskips closing coderd. That fix is in fix(cli): close coderd on server startup errors #30280. The first attempt leaked an idle HTTP connection instead (not investigated).Screenshots
From remote UAT on a test deployment (test data only).
b027cb5ca67)b027cb5ca67)618bff67c75)618bff67c75)Review record
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).c42b5f9e05c: no P0 to P2 findings. A stale P3 comment was fixed in34c17aadb7f; returningerr.Error()in 500 details was kept to match the deployment prompt handlers.58eab5603a4: 2 findings (refetch errors not surfaced, docs line breaks), both fixed incc73b714630.618bff67c75: 1 P2 (a failed refresh right after a successful save shows the previous value). Not a blocker, deferred.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.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.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). 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 ofde8377e94e1..cc73b714630(pass with nits; the update-only test case was added after it).Docs-only follow-up after the advisory, requested by Mike:
b4e76543df2adds 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 since618bff67c75. 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:
ExtractOrganizationParamresolves UUIDs without a deleted filter, so the sibling organization chat routes (MCP servers, model overrides, models) behave the same. The samechat_model_configRBAC still applies, nobody gains access to another organization, and writes are audited.Deferred (owner: Mike)
ExtractOrganizationParamor purging their configuration.waitForand an optional read-only plus refetch story. Trigger: the next change to these tests.