Repository navigation
Conversation
A webhook event for a new_chat automation now creates a chat as the automation owner instead of answering 501. - Before the create, the owner must be able to read the automation's enabled model config in the same organization (409 otherwise) and create a chat in the organization (403 otherwise), so a refusal happens before any lifecycle hook runs. - The chat gets the automation name plus the acceptance time in UTC as its title, client type api, the automation's model config and reasoning effort, and no selected MCP servers. No title is generated. - The AdmitInTx callback of CreateChat locks the automation and repeats every check, consumes a single-use webhook, and sets chats.automation_id through the new UpdateChatAutomationIDByID query. A refusal rolls back the whole creation.
Signed-off-by: Thomas Kosiewski <tk@coder.com>
- TestPublishAutomationWebhook/NewChatRefusedUnderLock changes the model config or the owner's roles while the user_prompt_submit hook runs, so only the checks repeated in the admission callback can refuse the input. Removing that recheck made both cases create a chat. - TestChatAutomationEvents/ModelDisabled also posts to a new_chat automation and expects 409, not a retryable 500. - The owner role removal is one fixture helper instead of two copies.
…oks' into HEAD # Conflicts: # coderd/x/chatd/automations_publish.go # coderd/x/chatd/automations_publish_test.go
…oks' into tk/codagt-1210b-automations-new-chat
|
@codex review |
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: 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". |
…oks' into tk/codagt-1210b-automations-new-chat
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fe8d5de6c
ℹ️ 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".
Chat creation through the chat API records an audit entry; a chat that a webhook event creates did not. The events endpoint now records one after the send, as created by the automation owner, with the automation and input ids in the additional fields. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex 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". |
…gt-1210b-automations-new-chat No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main d9c13dc: no content conflicts; make gen produced no diff
Generated with |
…gt-1210b-automations-new-chat No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main 35abc22: no content conflicts; make gen produced no diff
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum (an AI coding agent) prepared and posted this review on behalf of Mike. Each finding came from automated review passes and was re-verified against the code; please push back on anything that looks wrong.
The new_chat delivery path matches CODAGT-1210 part 2 and the RFC: creation goes through CreateChat with AdmitInTx, every pre-create check is repeated under the automation lock, a refusal rolls back the whole chat, and the earlier Codex audit finding is fixed. One small audit robustness gap remains.
Verdict: no blocking issues
Severity: P0 0, P1 0, P2 0, P3 1 inline (plus 1 folded nit)
Nits:
coderd/exp_chat_automations.go:495:json.Marshalof amap[string]stringcannot fail, so thefields = nilbranch is dead and would silently dropautomation_id/input_idif it ever ran. Drop the branch or log the error like theGetChatByIDfailure above it.
Review coverage
- code-review Standards: 2 findings; 1 kept (folded nit), 1 dropped (ARCHITECTURE.md edits are the owner's work per AGENTS.md Chatd, and the PR body says the user will review that prose)
- code-review Spec: 0 findings; no spec gaps or scope creep
- Adjudicator: 1 additional P3 found while verifying the audit path
- frontend-review: skipped, no files under site/
- coder-frontend-review: skipped, no files under site/
| audit.BackgroundAudit(ctx, &audit.BackgroundAuditParams[database.Chat]{ | ||
| Audit: *api.Auditor.Load(), | ||
| Log: api.Logger, | ||
| UserID: automation.OwnerID, | ||
| OrganizationID: automation.OrganizationID, | ||
| Action: database.AuditActionCreate, | ||
| New: chat, | ||
| Status: http.StatusAccepted, | ||
| IP: r.RemoteAddr, | ||
| UserAgent: r.UserAgent(), | ||
| AdditionalFields: fields, | ||
| }) |
There was a problem hiding this comment.
P3: Automation chat audit entry can be lost on client disconnect and has no request ID
BackgroundAudit and the GetChatByID above it run on the request context, so a webhook sender that disconnects or times out after CreateChat commits cancels both calls: the chat exists but no create entry is written (only a log line). The entry also leaves RequestID as the zero UUID although httpmw.AttachRequestID runs on this route, so it cannot be tied to the server logs. Other request-scoped background audits (auditChatModelConfigTransitions in coderd/exp_chats.go, coderd/usersecrets.go) use context.WithoutCancel(ctx) and pass httpmw.RequestID(r), and audit.InitRequest exports on context.Background().
Fix: derive auditCtx := context.WithoutCancel(ctx) at the top of auditChatAutomationCreatedChat, use it for the lookup and the export, and set RequestID: httpmw.RequestID(r).
There was a problem hiding this comment.
Fixed in 3a1f381: auditChatAutomationCreatedChat uses context.WithoutCancel(ctx) for the chat lookup and the export, and sets RequestID: httpmw.RequestID(r). TestChatAutomationEvents/NewChatTarget now asserts the entry's request ID is set. The same commit drops the dead json.Marshal error branch.
Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high
…gt-1210b-automations-new-chat No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Run the created-chat lookup and audit export on a context detached from the webhook request so a disconnecting sender cannot drop the entry, and record the request ID. Drop the dead json.Marshal error branch. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main d11809f: merged #30127; the created-chat audit now survives a client disconnect and carries the request ID, and the dead json.Marshal branch is gone (Mike's review)
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum re-reviewed this PR on behalf of @ibetitsmike using GPT-6.1 Sol (high) Exec subagents.
All three prior items are fixed in code; the existing audit thread is answered but still unresolved/outdated on GitHub, with no duplicate inline comment here. New findings: Standards 0, Spec 0, Frontend 0 (no own-layer site changes). Saved fresh-head webhook, publisher/creation/dependency and authorization tests passed, and the request-ID negative control failed as intended. Disconnect survival is source-verified only, broader local checks were not rerun, and Storybook remains failed; supplied inherited Pixel logs show report-server HTTP 500, not an own-layer source defect.
…gt-1210b-automations-new-chat No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main a328bee: merged #30127
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum validated this PR and approved it on behalf of @ibetitsmike.
Validated head af833abeef5a. The audit lifetime, request-ID and create-audit fixes remain intact after the restack. Fresh real new-chat HTTP/audit, publisher/creation/dependency and authorization tests passed. Current required CI passed. Disconnect survival remains source-verified rather than newly reproduced, and accepted tool/workspace follow-ups remain unchanged.
…gt-1210b-automations-new-chat No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
merged #30127
Generated with |
…gt-1210b-automations-new-chat No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
merged #30127
Generated with |
…gt-1210b-automations-new-chat No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Generated with |
…tions-new-chat Brings main ff158c0 into this layer. No conflicts. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Main now starts automatic title generation for every chat whose title source is fallback, the default. new_chat automation chats set an explicit title but no source, so title generation would replace it with a title derived from the first message, which includes the webhook event data. Mark the title as user-set, as the chat API does for an explicit title. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…tions-schedules Brings the new_chat automation title source fix from #30134. Resolved automations_publish.go: this layer's automationNewChatTitle call keeps the new TitleSource line. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…ations-run-now Brings the new_chat automation title source fix from #30134. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…ions-chat-labels Brings the new_chat automation title source fix from #30134. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…mations-list-page Brings the new_chat automation title source fix from #30134. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…tions-editor Brings the new_chat automation title source fix from #30134. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…ons-webhook-editor Brings the new_chat automation title source fix from #30134. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…automations-tool Brings the new_chat automation title source fix from #30134. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
Main sync (sweep 11) found one behavior interaction in this layer, fixed in 7f5d2aa: Main ( Generated with |
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum validated this PR and approved it on behalf of @ibetitsmike.
Revalidated head 7f5d2aa18e6b against base b623c2606b78. Independent Standards and Spec renewal found no new blockers; the original accepted exclusions remain unchanged.
Re-reviewed the explicit user title source and its privacy boundary. HTTP, publisher, authorization, SDK and inherited title-generation checks passed. The maintained stored-row assertion passed, failed when only the production TitleSource assignment was removed through a scratch Go overlay, then passed restored.
Approval is scoped to this layer and the reviewed inherited interactions. No full-repository suite, fresh Pixel screenshots or remote UAT claimed.
Closes CODAGT-1210. Part of CODAGT-1135.
What this adds
new_chatautomation creates a new chat as the automation owner through chatdCreateChatwith anAdmitInTxcallback, and the endpoint answers202with the newchat_id.api, and selects no MCP servers (the organization's Force On servers still apply). Its title is set explicitly to the automation name plus the acceptance time in UTC (<name> 2006-01-02 15:04 UTC), so automatic title generation does not run and event data never becomes the title.403), and the owner can read the automation's model config, which must be enabled and in the same organization (409). Auser_prompt_submitdenial creates no chat.chats.automation_idon the new chat (new queryUpdateChatAutomationIDByID, dbauthz: update on the chat), consumes a single-use webhook, and returns the provenance. A refusal rolls back the whole creation.automation_idandinput_idin the additional fields), as chat creation through the chat API does.Notes for reviewers
coderd/apidoc,dbmock,dbmetrics,querier.go,queries.sql.go).api, two message parts, andautomation_idset; single-use concurrency created exactly one chat; a disabled model config gave409with no chat.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high