feat(coderd): add task prompt modification endpoint (#20811)

This PR adds the backend implementation for modifying task prompts. Part
of https://github.com/coder/internal/issues/1084

## Changes

- New `UpdateTaskPrompt` database query to update task prompts
- New PATCH `/api/v2/tasks/{task}/prompt` endpoint

## Notes

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
(https://github.com/coder/coder/pull/20812).

---

🤖 PR was written by Claude Sonnet 4.5 Thinking using [Coder
Mux](https://github.com/coder/cmux) and reviewed by a human 👩
This commit is contained in:
Danielle Maywood
2025-11-25 11:13:32 +00:00
committed by GitHub
parent afd40436f0
commit 82f525baf3
18 changed files with 659 additions and 37 deletions
+50 -13
View File
@@ -90,10 +90,10 @@ curl -X GET http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{task}
### Parameters
| Name | In | Type | Required | Description |
|--------|------|--------------|----------|-------------------------------------------------------|
| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user |
| `task` | path | string(uuid) | true | Task ID |
| Name | In | Type | Required | Description |
|--------|------|--------|----------|-------------------------------------------------------|
| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user |
| `task` | path | string | true | Task ID, or task name |
### Example responses
@@ -121,10 +121,10 @@ curl -X DELETE http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{ta
### Parameters
| Name | In | Type | Required | Description |
|--------|------|--------------|----------|-------------------------------------------------------|
| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user |
| `task` | path | string(uuid) | true | Task ID |
| Name | In | Type | Required | Description |
|--------|------|--------|----------|-------------------------------------------------------|
| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user |
| `task` | path | string | true | Task ID, or task name |
### Responses
@@ -134,6 +134,43 @@ curl -X DELETE http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{ta
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Update AI task input
### Code samples
```shell
# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{task}/input \
-H 'Content-Type: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`PATCH /api/experimental/tasks/{user}/{task}/input`
> Body parameter
```json
{
"input": "string"
}
```
### Parameters
| Name | In | Type | Required | Description |
|--------|------|------------------------------------------------------------------------------|----------|-------------------------------------------------------|
| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user |
| `task` | path | string | true | Task ID, or task name |
| `body` | body | [codersdk.UpdateTaskInputRequest](schemas.md#codersdkupdatetaskinputrequest) | true | Update task input request |
### Responses
| Status | Meaning | Description | Schema |
|--------|-----------------------------------------------------------------|-------------|--------|
| 204 | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) | No Content | |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get AI task logs
### Code samples
@@ -149,10 +186,10 @@ curl -X GET http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{task}
### Parameters
| Name | In | Type | Required | Description |
|--------|------|--------------|----------|-------------------------------------------------------|
| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user |
| `task` | path | string(uuid) | true | Task ID |
| Name | In | Type | Required | Description |
|--------|------|--------|----------|-------------------------------------------------------|
| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user |
| `task` | path | string | true | Task ID, or task name |
### Example responses
@@ -192,7 +229,7 @@ curl -X POST http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{task
| Name | In | Type | Required | Description |
|--------|------|----------------------------------------------------------------|----------|-------------------------------------------------------|
| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user |
| `task` | path | string(uuid) | true | Task ID |
| `task` | path | string | true | Task ID, or task name |
| `body` | body | [codersdk.TaskSendRequest](schemas.md#codersdktasksendrequest) | true | Task input request |
### Responses
+14
View File
@@ -9198,6 +9198,20 @@ Restarts will only happen on weekdays in this list on weeks which line up with W
|---------|-----------------|----------|--------------|-------------|
| `roles` | array of string | false | | |
## codersdk.UpdateTaskInputRequest
```json
{
"input": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|---------|--------|----------|--------------|-------------|
| `input` | string | false | | |
## codersdk.UpdateTemplateACL
```json