Skip to content

feat: add Run now for schedule chat automations - #30166

Merged
ThomasK33 merged 13 commits into
tk/codagt-1211-automations-schedulesfrom
tk/codagt-1211b-automations-run-now
Oct 2, 2026
Merged

ThomasK33 merged 13 commits into
tk/codagt-1211-automations-schedulesfrom
tk/codagt-1211b-automations-run-now

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Closes CODAGT-1211. Part of CODAGT-1135.

Stack: PR 7b of "Automations for Coder Agents", on top of 7a (#30160, the schedule scanner), which sits on 1210 5b (#30134).

Adds Run now for schedule automations: POST /api/experimental/organizations/{organization}/chat-automations/{automation}/runs publishes the saved prompt at once through the existing Publish path, with no occurrence. It never writes the automation row, so the schedule cursor and revision stay unchanged.

  • Owner-only. chatd.RunAutomation(ctx, actorID, id) compares the caller with the automation owner before anything else, so org admins and site owners get 403 even though dbauthz lets them read and write the row (CODAGT-1226). A user who cannot read the automation gets 404, and the route sits behind the experiment gate, so a caller with chat-automations off gets 404. Publish also checks the owner's experiment again.
  • Statuses. 202 with input_id and chat_id; 400 for a non-schedule automation; 409 for a disabled schedule, a busy chat with When busy skip, or an unavailable target or model; 429 when the chat queue or the automations' share of it is full; hook denials use the same response as chat messages.
  • new_chat. A Run now of a new_chat schedule creates a chat titled with the run time in the schedule's time zone and records the same audit entry as webhook-created chats.

Tests

coderd/exp_chat_automation_runs_test.go runs against a real coderdtest server: the owner's run saves one message with the returned input id and leaves the whole automation row byte-equal; org admin and site owner get 403 (also on a webhook automation, proving the owner check comes first) and a non-reader gets 404, with nothing saved; webhook 400, disabled 409, busy skip 409, queue share 429; new_chat title, owner, and audit entry. The experiment gate test covers the new route.

Dogfood UAT ran on a real dev instance through Coder Agents and passed: immediate publish with the cursor and revision unchanged, 409/429 refusals, 403 for an org admin and the site owner, 404 with the experiment off, and a one-minute schedule that kept one message per minute around a Run now.

Size

About 325 hand-written lines (about 190 of them tests). Generated: coderd/apidoc/docs.go, coderd/apidoc/swagger.json, docs/reference/api/schemas.md, site/src/api/typesGenerated.ts (213 lines).

ARCHITECTURE.md prose was drafted by an agent at the user's request; the user will review it.

Also replaces the CODAGT-1209 ARCHITECTURE.md TODO from #30117; the prose was drafted by an agent at the user's request, and the user will review it.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

POST /api/experimental/organizations/{organization}/chat-automations/{automation}/runs
publishes the saved prompt of an enabled schedule automation immediately,
through the same Publish path as a scheduled occurrence but without one,
so the schedule cursor and revision stay unchanged and the automation
row is not written.

Only the owner can run an automation; organization admins and site
owners get 403. Webhook automations get 400 and disabled ones 409.
Admission refusals reuse the webhook responses (409 busy with skip or
target/model unavailable, 429 queue or automation share full). Chats a
new_chat automation creates are titled with the run time in the
schedule's time zone and audited like webhook-created chats.

Adds ChatAutomationRunResponse and ExperimentalClient.RunChatAutomation.
Name the concrete status codes in the Run now error mapper comment, and
document in ARCHITECTURE.md that a target chat with no usable model and
no default model gets 400, as a person's message does.
Run now reused the webhook detail "The automation skips events while
the chat is busy." A busy chat with skip now gets a run-specific detail.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33 ThomasK33 changed the title feat(coderd): add Run now for schedule chat automations feat: add Run now for schedule chat automations Sep 30, 2026
@linear-code

linear-code Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

CODAGT-1135

CODAGT-1211

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T06:33:49.558316Z 25b8907 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 6417debe10

ℹ️ 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".

…le and delete

Replaces the CODAGT-1209 TODO in ARCHITECTURE.md with prose: disable
bumps the queue generation in an automation-only transaction and then
deletes older queued rows through DeleteQueuedMessage as chatd; delete
removes the automation row first and then its queued rows; the queue
promotion guard discards any row the cleanup leaves behind.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 25b89076c1

ℹ️ 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".

@ThomasK33

Copy link
Copy Markdown
Member Author

CI evidence for the exact head 25b8907: ci workflow_dispatch run https://github.com/coder/coder/actions/runs/36684161189 passed on the first attempt, including required.

Why workflow_dispatch: GitHub creates no pull_request runs for this pushed stacked PR, and its mergeable state stays UNKNOWN.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1211b-automations-run-now

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

sync with main d9c13dc: no content conflicts; make gen produced no diff


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ThomasK33
ThomasK33 marked this pull request as ready for review October 1, 2026 09:38

@ibetitsmike ibetitsmike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Run now is small and matches CODAGT-1211: RunAutomation checks the owner before anything else, refuses webhook and disabled automations, and publishes through the shared admission path without an occurrence, so the schedule cursor and revision are never written. After re-verifying the reviewer findings against the code, none was worth asking you to fix.

Verdict: no blocking issues

Severity: P0 0, P1 0, P2 0, P3 0

Review coverage
  • code-review Standards: 2 findings raised, 0 kept (the ARCHITECTURE.md prose is the author's to own per AGENTS.md; the duplicate response type follows the codersdk pattern of one response type per endpoint, and the frontend already uses it later in the stack)
  • code-review Spec: 0 findings; status mapping, owner-only check, and new_chat audit match CODAGT-1211, CODAGT-1226, and the PRD
  • frontend-review plus coder-frontend-review (generated typesGenerated.ts only): FE2 PASS, FE1 and FE3 to FE10 N/A, generated type naming and consistency PASS

…agt-1211b-automations-run-now

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

sync with main 35abc22: no content conflicts; make gen produced no diff


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1211b-automations-run-now

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

sync with main d11809f: merged #30160


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ibetitsmike ibetitsmike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xum re-reviewed this PR on behalf of @ibetitsmike using GPT-6.1 Sol (high) Exec subagents.

The inherited audit lifetime/request-ID and scanner-plumbing fixes are intact; #30166 has no outstanding prior issue or unanswered thread. New findings: Standards 0, Spec 0, Frontend 0. Final fresh-head logs show Run now, experiment-gate, webhook and selected lifecycle/admission tests passing in coderd (1.483s), chatd (1.386s) and chatstate (0.692s), with the saved layer diff verified. Disconnect survival is source-verified rather than regression-tested; full/required CI is unavailable in the snapshot and Pixel is pending, so this is not an all-CI-green verdict.

…agt-1211b-automations-run-now

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

sync with main a328bee: merged #30160


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ibetitsmike ibetitsmike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xum validated this PR and approved it on behalf of @ibetitsmike.

Validated head c537251a3654. Revalidated the replacement head after withholding approval of the superseded pin. The introducing-layer payload and Run now contracts remain unchanged; scoped project/store integration is sound. Fresh Run now and caller-gate tests passed on this exact head, and current required CI passed. Generated-only frontend changes introduce no new visual behavior; no Pixel approval or full-stack merge-readiness claim is made.

…agt-1211b-automations-run-now

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

merged #30160


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1211b-automations-run-now

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

merged #30160


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1211b-automations-run-now

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

merged #30160 (main dc07908)


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…ations-run-now

Brings main ff158c0 into this layer. No conflicts.

---
_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`_
@ThomasK33
ThomasK33 merged commit b25f885 into main Oct 2, 2026
52 of 54 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
@ThomasK33
ThomasK33 deleted the tk/codagt-1211b-automations-run-now branch October 2, 2026 15:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants