Repository navigation
Conversation
The chat gets a manage_automations_enabled switch that only its owner can change. The new tool lists the chat owner's automations and gets one by ID, as the chat owner. The tool is in a turn only for a root chat with the switch on, outside plan and explore modes, while the experiment is on for the owner.
…on and bound a list in bytes
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)
ℹ️ 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: 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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…, a whole prompt in get and the order of list
… a chat whose switch is off
…turning a column list
…anage_automations tests
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Bravo. 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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
… its scope The switch query is now :execrows. A chat that a purge deletes between the permission read and the write gets 404 again (it was 204 since the query stopped returning a row). Two new subtests pin the new behavior: the write reaches the chat of the request and no other chat (owner's other chat, another user's chat), and a chat deleted just before the write gives 404.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. 🎉 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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…tk/automations-tool-read Conflict in coderd/chatautomations.go: the sync of #32079 edited the doc of loadChatAutomationRefs, which this PR moved to chatautomation.LoadRefs. The deletion stays. The create handler of #32096 now calls chatautomation.LoadRefs, and LoadRefs reads the chats through GetReadableChatsByIDs, the filtering read that #32079 renamed so that main's all-or-nothing GetChatsByIDs stays.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 496388cb1a
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| } | ||
| // This row holds the decrypted webhook secret. The converter never copies | ||
| // it. | ||
| automation, err := options.DB.GetChatAutomationByID(ctx, id) |
There was a problem hiding this comment.
🛡️ Codex Security Review
Security: Restrict automation lookup to the chat owner
When chat automations are enabled for both users, an organization member can place instructions in an automation prompt and give its ID to an organization admin. getAutomation authorizes the lookup as the admin/chat owner but checks only the organization, so it returns the member-controlled prompt as a tool result; the next model step also has workspace tools running as the admin. A successful indirect injection can therefore create, start, or stop workspaces with elevated authority. Restrict get to the owner's automations, as list already does.
SECURITY.md reference: SECURITY.md:L27-L39
Useful? React with 👍 / 👎.
- TestManageAutomationsDefault: the create-time default is asserted by TestManageAutomationsTurn and TestChatManageAutomationsSwitch OwnerExperimentOn and OwnerExperimentOff, and the child row exercises a branch that the only caller never takes. - TestManageAutomationsAvailable EvaluatorError and NoEvaluator rows and the error mode of automationsEvaluator: fail-closed is owned by the experiments package, and a nil evaluator panics every other CreateChat test. - TestManageAutomationsTurn ExperimentOff row: the predicate owns the gate and ExperimentOffInSecondStep proves the tool list follows it. - TestManageAutomationsTurn secret counts in chat_messages and chat_debug_steps: the tool tests assert that every result is free of the secret, and that result is the only source of those rows. - TestToolGet Missing and SoftDeletedOwner rows: they hit the Malformed and Unknown branches, and the database tests own the soft-delete trigger. - TestToolUnknownAction row read-back: the tool has no write path, so it cannot fail. - TestChatManageAutomationsSwitch OneChatOnly: dropping the id filter changes the sqlc parameter type and breaks the build. - TestChatManageAutomationsSwitch hasField: omitempty and the key name are pinned by the generated types and docs.
- F1: the tool test call helper also counts the webhook secret in resp.Metadata, so a tool result that attaches the decrypted row as user_result metadata fails every get test. - F2: TestChatManageAutomationsSwitch OwnerExperimentOn creates a second chat of the owner and asserts that a write to the first chat leaves it on, so a switch write widened to the owner's chats fails. - M1: TestToolUnknownAction sends the id of an automation again, so an unknown action that falls through to get fails. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
|
||
| No other input states are supported. | ||
|
|
||
| A root chat starts with its `manage_automations_enabled` switch on when the `chat-automations` experiment is on for its owner. Sub-agent chats and chats that are created while the experiment is off start with it off. |
There was a problem hiding this comment.
The docs spell the concept "Sub-agent" here, but the rest of the page, including the lines just above and below this one, spells it "subagent" (one word). This is a consistency fix within one page, so the term matches everywhere (Consistency, Continuity Editor).
Suggested change:
| A root chat starts with its `manage_automations_enabled` switch on when the `chat-automations` experiment is on for its owner. Sub-agent chats and chats that are created while the experiment is off start with it off. | |
| A root chat starts with its `manage_automations_enabled` switch on when the `chat-automations` experiment is on for its owner. Subagent chats and chats that are created while the experiment is off start with it off. |
|
|
||
| ##### Chat automations tool | ||
|
|
||
| A turn offers the `manage_automations` tool only when all of these hold: the chat's `manage_automations_enabled` switch is on, the chat is a root chat and isn't archived, the chat is in neither plan mode nor explore mode, and the `chat-automations` experiment is on for the chat owner. The experiment is evaluated through `Config.ExperimentEvaluator` each time chatd builds the tools of a generation step. A failed evaluation or a missing evaluator counts as off, so turning the experiment off removes the tool from the next step without a write to the chat. |
There was a problem hiding this comment.
The gate names "plan mode" and "explore mode" without defining either. "Plan mode" appears on this page only as an undefined bullet. "Explore" appears elsewhere on the page only for the unrelated subagent-model context. Readers cannot tell which chat field the gate reads. The code gates on chat.PlanMode and on chat.Mode == database.ChatModeExplore (manage_automations.go:31-32, turn_environment.go:1970-1971). Add a one-line definition of each term where this sentence first uses it as a gate, so a reader can tell which field each names. This is a suggestion, not a blocking finding (Newcomer)
|
|
||
| ##### Chat automations tool | ||
|
|
||
| A turn offers the `manage_automations` tool only when all of these hold: the chat's `manage_automations_enabled` switch is on, the chat is a root chat and isn't archived, the chat is in neither plan mode nor explore mode, and the `chat-automations` experiment is on for the chat owner. The experiment is evaluated through `Config.ExperimentEvaluator` each time chatd builds the tools of a generation step. A failed evaluation or a missing evaluator counts as off, so turning the experiment off removes the tool from the next step without a write to the chat. |
There was a problem hiding this comment.
The sentence is long for body prose and lists four conditions in one clause. Separating the conditions with semicolons makes the list easier to scan. The style guide's sentence-length target is 25 words, but it is a target, not a rule for this file (Copy Editor).
Suggested change:
| A turn offers the `manage_automations` tool only when all of these hold: the chat's `manage_automations_enabled` switch is on, the chat is a root chat and isn't archived, the chat is in neither plan mode nor explore mode, and the `chat-automations` experiment is on for the chat owner. The experiment is evaluated through `Config.ExperimentEvaluator` each time chatd builds the tools of a generation step. A failed evaluation or a missing evaluator counts as off, so turning the experiment off removes the tool from the next step without a write to the chat. | |
| A turn offers the `manage_automations` tool only when all of these hold: the chat's `manage_automations_enabled` switch is on; the chat is a root chat that isn't archived; the chat is in neither plan mode nor explore mode; and the `chat-automations` experiment is on for the chat owner. The experiment is evaluated through `Config.ExperimentEvaluator` each time chatd builds the tools of a generation step. A failed evaluation or a missing evaluator counts as off, so turning the experiment off removes the tool from the next step without a write to the chat. |
|
|
||
| A turn offers the `manage_automations` tool only when all of these hold: the chat's `manage_automations_enabled` switch is on, the chat is a root chat and isn't archived, the chat is in neither plan mode nor explore mode, and the `chat-automations` experiment is on for the chat owner. The experiment is evaluated through `Config.ExperimentEvaluator` each time chatd builds the tools of a generation step. A failed evaluation or a missing evaluator counts as off, so turning the experiment off removes the tool from the next step without a write to the chat. | ||
|
|
||
| The tool acts as the chat owner. Each call loads the owner's RBAC subject and reads through dbauthz, so the tool has no permission rules of its own and has the same permissions in every turn. `list` returns the owner's own automations in the chat's organization, newest first, also in an administrator's chat. A `list` result holds at most 20 automations and 32 KiB of them, each prompt is cut to 200 characters, and the result says what it cut. `get` returns any automation of the chat's organization that the owner can read. A result never holds a webhook secret, because it is built by the converter of the API. Any other action is a tool error. |
There was a problem hiding this comment.
This sentence joins two claims with one comma clause. Splitting it makes each claim easy to read on its own (Copy Editor). This is a suggestion; the sentence-length target is not a rule for this file.
Suggested change:
| The tool acts as the chat owner. Each call loads the owner's RBAC subject and reads through dbauthz, so the tool has no permission rules of its own and has the same permissions in every turn. `list` returns the owner's own automations in the chat's organization, newest first, also in an administrator's chat. A `list` result holds at most 20 automations and 32 KiB of them, each prompt is cut to 200 characters, and the result says what it cut. `get` returns any automation of the chat's organization that the owner can read. A result never holds a webhook secret, because it is built by the converter of the API. Any other action is a tool error. | |
| The tool acts as the chat owner. Each call loads the owner's RBAC subject and reads through dbauthz. The tool has no permission rules of its own, so it has the same permissions in every turn. `list` returns the owner's own automations in the chat's organization, newest first, also in an administrator's chat. A `list` result holds at most 20 automations and 32 KiB of them, each prompt is cut to 200 characters, and the result says what it cut. `get` returns any automation of the chat's organization that the owner can read. A result never holds a webhook secret, because it is built by the converter of the API. Any other action is a tool error. |
|
|
||
| A turn offers the `manage_automations` tool only when all of these hold: the chat's `manage_automations_enabled` switch is on, the chat is a root chat and isn't archived, the chat is in neither plan mode nor explore mode, and the `chat-automations` experiment is on for the chat owner. The experiment is evaluated through `Config.ExperimentEvaluator` each time chatd builds the tools of a generation step. A failed evaluation or a missing evaluator counts as off, so turning the experiment off removes the tool from the next step without a write to the chat. | ||
|
|
||
| The tool acts as the chat owner. Each call loads the owner's RBAC subject and reads through dbauthz, so the tool has no permission rules of its own and has the same permissions in every turn. `list` returns the owner's own automations in the chat's organization, newest first, also in an administrator's chat. A `list` result holds at most 20 automations and 32 KiB of them, each prompt is cut to 200 characters, and the result says what it cut. `get` returns any automation of the chat's organization that the owner can read. A result never holds a webhook secret, because it is built by the converter of the API. Any other action is a tool error. |
There was a problem hiding this comment.
The write actions (create, update, enable, disable, delete, run_now) are out of scope for this PR and will land later. A reader who sees only this section cannot tell whether list and get are the permanent action set. Consider saying "Only list and get are supported today; any other action is a tool error." This doesn't change what a reader would do now, so it is a suggestion (Newcomer).
Documentation CheckDesign notes
Findings for agents- id: consistency-1
persona: consistency
class: suggestion
blocking: false
file: coderd/x/chatd/ARCHITECTURE.md
line: 591
quote: "Sub-agent chats and chats that are created while the experiment is off start with it off."
problem: "The page spells the concept \"Sub-agent\" here and \"subagent\" everywhere else."
fix: "Subagent chats and chats that are created while the experiment is off start with it off."
verified: true
- id: learner-1
persona: learner
class: suggestion
blocking: false
file: coderd/x/chatd/ARCHITECTURE.md
line: 1244
quote: "the chat is in neither plan mode nor explore mode"
problem: "Neither term is defined on the page. Plan mode appears only as an undefined bullet, and explore mode is not a chat-level term anywhere else on the page."
fix: "Define each term where this sentence first uses it as a gate."
verified: true
- id: language-2
persona: language
class: suggestion
blocking: false
file: coderd/x/chatd/ARCHITECTURE.md
line: 1244
quote: "A turn offers the `manage_automations` tool only when all of these hold"
problem: "The sentence is 47 words and lists four conditions in one clause. The 25-word target in the style guide is not enforced for this file."
fix: "Separate the four conditions with semicolons."
verified: true
- id: language-1
persona: language
class: suggestion
blocking: false
file: coderd/x/chatd/ARCHITECTURE.md
line: 1246
quote: "Each call loads the owner's RBAC subject and reads through dbauthz, so the tool has no permission rules of its own and has the same permissions in every turn."
problem: "The sentence joins two claims in one clause chain."
fix: "Split after \"dbauthz\"."
verified: true
- id: learner-2
persona: learner
class: suggestion
blocking: false
file: coderd/x/chatd/ARCHITECTURE.md
line: 1246
quote: "Any other action is a tool error."
problem: "The section does not say that write actions are out of scope for this PR."
fix: "Say that only list and get are supported today."
verified: trueAutomated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong. |
A chat agent can read the chat automations of its owner (RFC: Automations for Coder Agents). This PR adds the
manage_automationstool with thelistandgetactions, and the chat switchmanage_automations_enabledthat turns it on and off, behind thechat-automationsexperiment. The write actions come with a later PR. Part of CODAGT-1135.Stacked on #32096. Review only this diff. It merges after #32096.
What changed
manage_automations.listreturns the chat owner's own automations in the chat's organization, newest first, also in an administrator's chat.getreturns one automation of the chat's organization by ID. Each call loads the chat owner's RBAC subject and reads through dbauthz, so the tool has no permission rules of its own. Both build the result with the converter of the API, so a result never holds a webhook secret. Any other action, the write actions included, is a tool error that names the two actions.Config.ExperimentEvaluator. It is read each time chatd builds the tools for a model request or for running tool calls, so turning the experiment off removes the tool from the next request without a write to the chat. A failed evaluation or a missing evaluator counts as off.manage_automations_enabledis on the chat response (omitted while false, so a response is unchanged with the experiment off) and in the update request. Only the chat owner can change it: an administrator withupdategets 403. Turning it on needs the experiment for the owner (400), and turning it off is always allowed. The write is one new query that sets the column.chatautomation.LoadRefsis the function that the list, get and create routes use to load owners and chats (it wasloadChatAutomationRefs), moved so that the tool and the routes share it. It reads chats throughGetReadableChatsByIDs, the read that leaves out unreadable chats.Suggested reading order:
coderd/x/chatd/chatautomation/tool.go,coderd/x/chatd/manage_automations.go, the switch check inupdateChat(coderd/exp_chats.go), then the tests. The rest is generated code and docs.Scope
create,update,enable,disable,delete,run_now), any change to the automation routes, a migration, and frontend code beyond the generated types.Tradeoffs
getuses RBAC only, and it also answers "not found" for an automation of another organization than the chat's, as the API does for a route. Otherwise the prompt of an automation from another organization would land in the history of this chat, which administrators of this chat's organization can read.listresult holds at most 20 automations and 32 KiB. Each prompt is cut to 200 characters (prompt_truncated), and anotesays what was cut. Agetresult holds the full prompt.readandworkspace_id.ARCHITECTURE.md prose was drafted by an agent at the user's request; the user will review it.
Live check
On a local enterprise build with a fake model provider: the tool appeared only for users with the experiment on,
listandgetreturned what the rules above say, the switch API answered 403 and 400 as described, and a canary webhook secret appeared 0 times in the model log, the messages API,chat_messagesand the server and PostgreSQL logs.Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh