Commit 59c4a3f
feat(agent): add custom-agent self-updates with user isolation (#2713)
* feat(agent): add update_agent tool for in-chat custom-agent self-updates (#2616)
Custom agents had no built-in way to persist updates to their own SOUL.md /
config.yaml from a normal chat — `setup_agent` was only bound during the
bootstrap flow, so when the user asked the agent to refine its description
or personality, the agent would shell out via bash/write_file and the edits
landed in a temporary sandbox/tool workspace instead of
`{base_dir}/agents/{agent_name}/`.
Changes:
- New `update_agent` builtin tool with partial-update semantics (only the
fields you pass are written) and atomic temp-file + os.replace writes so
a failed update never corrupts existing SOUL.md / config.yaml.
- Lead agent now binds `update_agent` in the non-bootstrap path whenever
`agent_name` is set in the runtime context. Default agent (no
agent_name) and bootstrap flow are unchanged.
- New `<self_update>` system-prompt section is injected for custom agents,
instructing them to use `update_agent` — and explicitly NOT bash /
write_file — to persist self-updates.
- Tests: 11 new cases in `tests/test_update_agent_tool.py` covering
validation (missing/invalid agent_name, unknown agent, no fields),
partial updates (soul-only, description-only, skills=[] vs omitted),
no-op detection, atomic-write safety, and AgentConfig round-tripping;
plus 2 new cases in `tests/test_lead_agent_prompt.py` covering the
self-update prompt section.
- Docs: updated backend/CLAUDE.md builtin tools list and tools.mdx
(en/zh) with the new tool description.
* feat(agent): isolate custom agents per user
Store custom agent definitions under the effective user, keep legacy agents readable until migration, and cover API/tool/migration behavior with tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat: consistent write/delete targets & add --user-id to migration
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent e8675f2 commit 59c4a3f
18 files changed
Lines changed: 956 additions & 61 deletions
File tree
- backend
- app/gateway/routers
- packages/harness/deerflow
- agents/lead_agent
- config
- tools/builtins
- scripts
- tests
- frontend/src/content
- en/harness
- zh/harness
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
266 | 268 | | |
267 | 269 | | |
268 | 270 | | |
| |||
354 | 356 | | |
355 | 357 | | |
356 | 358 | | |
| 359 | + | |
357 | 360 | | |
358 | 361 | | |
359 | 362 | | |
360 | | - | |
| 363 | + | |
361 | 364 | | |
362 | 365 | | |
363 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
93 | | - | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| |||
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| 120 | + | |
119 | 121 | | |
120 | | - | |
121 | | - | |
| 122 | + | |
| 123 | + | |
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
| |||
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
147 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
| |||
169 | 176 | | |
170 | 177 | | |
171 | 178 | | |
| 179 | + | |
172 | 180 | | |
173 | 181 | | |
174 | | - | |
175 | | - | |
| 182 | + | |
| 183 | + | |
176 | 184 | | |
177 | 185 | | |
178 | 186 | | |
| |||
202 | 210 | | |
203 | 211 | | |
204 | 212 | | |
| 213 | + | |
| 214 | + | |
205 | 215 | | |
206 | | - | |
| 216 | + | |
| 217 | + | |
207 | 218 | | |
208 | | - | |
| 219 | + | |
209 | 220 | | |
210 | 221 | | |
211 | 222 | | |
| |||
232 | 243 | | |
233 | 244 | | |
234 | 245 | | |
235 | | - | |
236 | | - | |
| 246 | + | |
| 247 | + | |
237 | 248 | | |
238 | 249 | | |
239 | 250 | | |
| |||
267 | 278 | | |
268 | 279 | | |
269 | 280 | | |
| 281 | + | |
270 | 282 | | |
271 | 283 | | |
272 | | - | |
| 284 | + | |
273 | 285 | | |
274 | 286 | | |
275 | 287 | | |
276 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
277 | 295 | | |
278 | 296 | | |
279 | 297 | | |
| |||
314 | 332 | | |
315 | 333 | | |
316 | 334 | | |
317 | | - | |
318 | | - | |
| 335 | + | |
| 336 | + | |
319 | 337 | | |
320 | 338 | | |
321 | 339 | | |
| |||
402 | 420 | | |
403 | 421 | | |
404 | 422 | | |
405 | | - | |
| 423 | + | |
| 424 | + | |
406 | 425 | | |
407 | 426 | | |
408 | 427 | | |
409 | 428 | | |
410 | | - | |
411 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
412 | 432 | | |
413 | 433 | | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
414 | 439 | | |
415 | 440 | | |
416 | 441 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
393 | 396 | | |
394 | 397 | | |
395 | 398 | | |
| |||
398 | 401 | | |
399 | 402 | | |
400 | 403 | | |
401 | | - | |
| 404 | + | |
| 405 | + | |
402 | 406 | | |
403 | 407 | | |
404 | 408 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
347 | 348 | | |
348 | 349 | | |
349 | 350 | | |
| |||
643 | 644 | | |
644 | 645 | | |
645 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
646 | 667 | | |
647 | 668 | | |
648 | 669 | | |
| |||
772 | 793 | | |
773 | 794 | | |
774 | 795 | | |
| 796 | + | |
775 | 797 | | |
776 | 798 | | |
777 | 799 | | |
| |||
0 commit comments