feat(chatd): add user-level custom prompt for agent chats#22896
Merged
feat(chatd): add user-level custom prompt for agent chats#22896
Conversation
Adds a user-level custom prompt option for agent chats. Users can set
a personal prompt that is injected into every chat as a system message,
allowing them to customize the agent's behavior (e.g., preferred
language, coding style, verbosity).
The prompt is stored in the existing user_configs table (no migration
needed) and resolved at runtime so updates take effect immediately on
ongoing chats. It is wrapped in <user-instructions> tags and injected
after workspace instructions, giving it the highest positional weight
among system-level instructions while remaining subordinate to the
base system prompt.
API:
- GET /api/v2/users/{user}/chat-prompt
- PUT /api/v2/users/{user}/chat-prompt
Changes:
- New SQL queries: GetUserChatCustomPrompt, UpdateUserChatCustomPrompt
- SDK types: UserChatCustomPromptResponse, UpdateUserChatCustomPromptRequest
- HTTP handlers with 128 KiB size limit (same as deployment prompt)
- dbauthz: ReadPersonal/UpdatePersonal authorization
- chatd: resolveUserPrompt() injected in both runChat and ReloadMessages
Contributor
Documentation CheckUpdates Needed
Automated review via Coder Tasks |
Move the user-level custom prompt endpoints from /api/v2/users/{user}/
to /api/experimental/chats/config/ alongside other chat configuration:
- GET /api/experimental/chats/config/user-prompt
- PUT /api/experimental/chats/config/user-prompt
Changes:
- Handlers moved from coderd/users.go to coderd/chats.go
- Use httpmw.APIKey(r).UserID instead of httpmw.UserParam(r)
- SDK types + client methods moved from codersdk/users.go to
codersdk/chats.go
- Routes registered under /chats/config alongside system-prompt
- Swagger annotations removed (experimental endpoints are hidden
from docs gen)
hugodutka
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a user-level custom prompt to the database.
I'll be doing a follow-up for the UI, as we currently do not have user-level settings (it's just admin). I'll also make it very obvious for chats where there is a user-level prompt, but I don't know how yet.