Commit 1a7c835
feat(web): apply chat preferences to agent system prompt
Threads the signed-in user's chat preferences through the agent so the
final answer is biased by their saved settings.
- `agent.ts` exports a new `ResolvedChatUserPreferences` interface and
accepts it as an optional field on `CreateMessageStreamResponseProps`,
`AgentOptions`, and `createPrompt`. When present,
`renderChatPreferencesPromptBlock()` produces a `<user_preferences>`
block that is appended after `</answer_instructions>` in the system
prompt, where the model sees it last. When absent, no block is
emitted and behavior is identical to today.
- `api/(server)/chat/route.ts` loads `chatPreferences` and
`chatCustomInstructions` from the user's row (only when
`user` is defined, which excludes anonymous chats), parses the JSONB
through `chatPreferencesSchema` defensively, and passes the result to
`createMessageStream`. The query is `select`-narrowed to the two
columns the agent actually needs.
- `features/mcp/askCodebase.ts` does not load preferences. MCP has no
user-settings surface yet; the call site has an explicit comment
pointing back to #1242 so a future maintainer knows it was a
conscious omission rather than an oversight.
Soft-bias framing in the prompt block is intentional: preferences are
described as guidance that shapes the final answer and must never
override correctness or the explicit user message. This keeps existing
agent behavior intact even when preferences are aggressive (e.g.
"one-paragraph summary" + "describe code only" together).
Refs #1242
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 9d40e7d commit 1a7c835
3 files changed
Lines changed: 61 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
96 | 118 | | |
97 | 119 | | |
98 | 120 | | |
| |||
112 | 134 | | |
113 | 135 | | |
114 | 136 | | |
| 137 | + | |
115 | 138 | | |
116 | 139 | | |
117 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
20 | 34 | | |
21 | 35 | | |
22 | 36 | | |
| |||
43 | 57 | | |
44 | 58 | | |
45 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
46 | 66 | | |
47 | 67 | | |
48 | 68 | | |
| |||
56 | 76 | | |
57 | 77 | | |
58 | 78 | | |
| 79 | + | |
59 | 80 | | |
60 | 81 | | |
61 | 82 | | |
| |||
109 | 130 | | |
110 | 131 | | |
111 | 132 | | |
| 133 | + | |
112 | 134 | | |
113 | 135 | | |
114 | 136 | | |
| |||
154 | 176 | | |
155 | 177 | | |
156 | 178 | | |
| 179 | + | |
157 | 180 | | |
158 | 181 | | |
159 | 182 | | |
| |||
166 | 189 | | |
167 | 190 | | |
168 | 191 | | |
| 192 | + | |
169 | 193 | | |
170 | 194 | | |
171 | 195 | | |
| |||
195 | 219 | | |
196 | 220 | | |
197 | 221 | | |
| 222 | + | |
198 | 223 | | |
199 | 224 | | |
200 | 225 | | |
| |||
234 | 259 | | |
235 | 260 | | |
236 | 261 | | |
| 262 | + | |
237 | 263 | | |
238 | 264 | | |
239 | 265 | | |
| |||
243 | 269 | | |
244 | 270 | | |
245 | 271 | | |
| 272 | + | |
246 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
247 | 278 | | |
248 | 279 | | |
249 | 280 | | |
| |||
317 | 348 | | |
318 | 349 | | |
319 | 350 | | |
| 351 | + | |
| 352 | + | |
320 | 353 | | |
321 | 354 | | |
322 | 355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
| |||
0 commit comments