Skip to content

feat(chatd): add user-level custom prompt for agent chats#22896

Merged
kylecarbs merged 2 commits intomainfrom
user-chat-custom-prompt
Mar 10, 2026
Merged

feat(chatd): add user-level custom prompt for agent chats#22896
kylecarbs merged 2 commits intomainfrom
user-chat-custom-prompt

Conversation

@kylecarbs
Copy link
Member

@kylecarbs kylecarbs commented Mar 10, 2026

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.

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
@coder-tasks
Copy link
Contributor

coder-tasks bot commented Mar 10, 2026

Documentation Check

Updates Needed

  • docs/ai-coder/agents/platform-controls.md - The doc currently states *"All agent configuration is admin-level"* and *"Developers never need to configure anything... They do not need to... write a system prompt"* and *"Developers cannot override them."* This PR introduces user-level prompt configuration, which directly contradicts the documented design philosophy. The "What platform teams control today" section (specifically the "System prompt" subsection) and the design philosophy statements need to reflect that users can now set their own custom prompt that layers on top of the admin-configured system prompt.

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)
@kylecarbs kylecarbs requested a review from hugodutka March 10, 2026 14:52
@kylecarbs kylecarbs merged commit b6d1a11 into main Mar 10, 2026
29 checks passed
@kylecarbs kylecarbs deleted the user-chat-custom-prompt branch March 10, 2026 15:17
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2026
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