- Notifications
You must be signed in to change notification settings - Fork1.1k
feat(coderd): add task prompt modification endpoint#20811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
This adds a new PATCH endpoint to modify the prompt of an existing taskand restart its build. This is the backend implementation including:- New UpdateTaskPrompt database query- New PATCH /api/v2/tasks/{task}/prompt endpoint- Authorization checks for task modification- Database changes to support prompt updates- Generated API documentation and TypeScript typesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull 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".
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".
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
coderd/aitasks.go Outdated
| return | ||
| } | ||
| ifreq.Prompt=="" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I could see this as a use-case, set the prompt to empty for e.g. next start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can remove this then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Could you elaborate that use-case? 🤔 I'm not clear on what the agent would do with an empty prompt on next start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It looks like you need to fill something into the prompt in the UI too, so I’m fine with leaving the check.@ssncferreira my thought was that you might want to start up the task in idle state so that you can interact with agentapi directly, e.g. upload attachments, etc. But you can just as well type ”do nothing” as prompt to achieve that so aligning with UI is fine.
Uh oh!
There was an error while loading.Please reload this page.
coderd/aitasks.go Outdated
| // @Tags Experimental | ||
| // @Param user path string true "Username, user ID, or 'me' for the authenticated user" | ||
| // @Param task path string true "Task ID" format(uuid) | ||
| // @Param request body codersdk.UpdateTaskPromptRequest true "Update task prompt request" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Our terminology is becoming a bit inconsistent here, first you create a task withinput, but then updateprompt which replaces the input/prompt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Would you prefer renamingprompt toinput here? Happy to do so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Let's go with input to stay consistent 👍🏻
coderd/aitasks.go Outdated
| return | ||
| } | ||
| ifreq.Prompt=="" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Could you elaborate that use-case? 🤔 I'm not clear on what the agent would do with an empty prompt on next start
coderd/aitasks.go Outdated
| // Block updates if: | ||
| // 1. Job is actively running (pending, running, canceling) | ||
| // 2. Workspace is running (job succeeded with start transition) | ||
| ifjob.JobStatus==database.ProvisionerJobStatusPending|| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why are we disallowing prompt update on job pending? In this state, the provisioner hasn't even picked up the workspace build job yet, so it should be safe to update the prompt, correct?
Uh oh!
There was an error while loading.Please reload this page.
ssncferreira left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM ✅
Just some nits, but nothing blocking 🙂
coderd/aitasks.go Outdated
| }) | ||
| } | ||
| iftask.Status==database.TaskStatusInitializing||task.Status==database.TaskStatusActive { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
So this leaves us with: "pending,paused,unknown,error"...should we allow changes onunknown anderror?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm still happy with removing this entirely but this allows us to change onUnknown andError. The task status is consideredError when you cancel the workspace build, which is what needs to be done to stop it before it starts executing.
As for unknown, I'm on the fence and can be convinced either way on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Error could also mean the app is unhealthy. I guess a bigger question is. If a workspace is initializing or active,how is this API intended to be used? Do we cancel the current transition, run a stop transition on the workspace, update the prompt, then start it again?
In this scenario, one could see paused as the only acceptable state where prompt can be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Oh should I also run a stop transition after the cancel? 👀 My plan was to just cancel the transition (hence why I allow changing on error), update the prompt, and run a start transition again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@mafredri I've updated the PR and it only allows updating the input when the task is paused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@DanielleMaywood it's safest to run a stop transition because otherwise there isn't a guarantee the workspace will be in a valid state afterwards.
I think there's another issue related to this that I can't find right now, but the discussion here should give at least some context:#8266
Uh oh!
There was an error while loading.Please reload this page.
| -- name: UpdateTaskPrompt :one | ||
| UPDATE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
nit: I understand that the task status is computed from the viewtasks_with_status, so this might not be trivial, but should we change the query to only update the task's prompt if the task is in an allowed status? Otherwise, maybe just adding a comment that we should only update a task's prompt if it is in status 'pending', 'paused', 'unknown', or 'error' (i.e., NOT 'initializing' or 'active').
Uh oh!
There was an error while loading.Please reload this page.
ssncferreira commentedNov 20, 2025
Also, just a note on the Chromatic CI failed test: |
mafredri left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The main blocker is still thetask.Status check IMO, it's feels like somewhat arbitrary enforcement due to some states having multiple potential causes. Likeerror could be failed build or unhealthy app (potentially running task, just agentapi failing health check).
Some minor additional feedback inline.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
coderd/aitasks.go Outdated
| }) | ||
| } | ||
| iftask.Status==database.TaskStatusInitializing||task.Status==database.TaskStatusActive { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Error could also mean the app is unhealthy. I guess a bigger question is. If a workspace is initializing or active,how is this API intended to be used? Do we cancel the current transition, run a stop transition on the workspace, update the prompt, then start it again?
In this scenario, one could see paused as the only acceptable state where prompt can be updated?
Uh oh!
There was an error while loading.Please reload this page.
mafredri left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
![]()
82f525b intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This PR adds the backend implementation for modifying task prompts. Part ofcoder/internal#1084
Changes
UpdateTaskPromptdatabase query to update task prompts/api/v2/tasks/{task}/promptendpointNotes
This is part 1 of a 2-part PR stack. The frontend UI will be added in a follow-up PR based on this branch (#20812).
🤖 PR was written by Claude Sonnet 4.5 Thinking usingCoder Mux and reviewed by a human 👩