fastapi-fullstack 0.2.20__py3-none-any.whl → 0.2.22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {fastapi_fullstack-0.2.20.dist-info → fastapi_fullstack-0.2.22.dist-info}/METADATA +3 -1
  2. {fastapi_fullstack-0.2.20.dist-info → fastapi_fullstack-0.2.22.dist-info}/RECORD +24 -22
  3. {fastapi_fullstack-0.2.20.dist-info → fastapi_fullstack-0.2.22.dist-info}/WHEEL +1 -1
  4. fastapi_gen/UPGRADES.yaml +4 -0
  5. fastapi_gen/generator.py +3 -1
  6. fastapi_gen/template/hooks/post_gen_project.py +21 -3
  7. fastapi_gen/template/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +3 -3
  8. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/env.py +3 -0
  9. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/0027_user_magic_link_epoch.py +4 -2
  10. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/user.py +11 -2
  11. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/agent.py +35 -0
  12. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/agent_session.py +66 -9
  13. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/vectorstore.py +7 -5
  14. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/user.py +10 -0
  15. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_conversation_resume.py +181 -0
  16. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_deep_research_streaming.py +85 -0
  17. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_memory.py +25 -1
  18. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_migrations.py +19 -9
  19. fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_pydantic_deep_history.py +7 -1
  20. fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.dev.yml +3 -3
  21. fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.prod.yml +4 -4
  22. fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.yml +3 -3
  23. {fastapi_fullstack-0.2.20.dist-info → fastapi_fullstack-0.2.22.dist-info}/entry_points.txt +0 -0
  24. {fastapi_fullstack-0.2.20.dist-info → fastapi_fullstack-0.2.22.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: fastapi-fullstack
3
- Version: 0.2.20
3
+ Version: 0.2.22
4
4
  Summary: Full-stack FastAPI + Next.js template generator with Pydantic AI/LangChain agents, WebSocket streaming, 20+ enterprise integrations, and Logfire/LangSmith observability. Ship AI apps fast.
5
5
  Project-URL: Homepage, https://github.com/vstorm-co/full-stack-ai-agent-template
6
6
  Project-URL: Documentation, https://vstorm-co.github.io/full-stack-ai-agent-template/
@@ -19,8 +19,10 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Topic :: Software Development :: Code Generators
21
21
  Requires-Python: >=3.11
22
+ Requires-Dist: certifi>=2026.10.18
22
23
  Requires-Dist: click>=8.3.3
23
24
  Requires-Dist: cookiecutter>=2.7.0
25
+ Requires-Dist: dnspython>=2.9.2
24
26
  Requires-Dist: email-validator>=2.3.0
25
27
  Requires-Dist: packaging>=24.0
26
28
  Requires-Dist: pydantic>=2.13.0
@@ -1,7 +1,7 @@
1
1
  fastapi_gen/__init__.py,sha256=oK2gEM45SpSYBb-Itgr0GII88-5qfB0kmNkj90FkvQw,257
2
2
  fastapi_gen/cli.py,sha256=DXe3KZVtbphokBLYup93qhoAkD_2fUUrzrucSmP8xNM,61286
3
3
  fastapi_gen/config.py,sha256=Xx97sK57NDR-7-Ky9IogqVWbf0Wh5HAldKpNA6cvdCI,45581
4
- fastapi_gen/generator.py,sha256=vMZ18ANuhCKva2pDklIIAZO7bkwX-ehvPzmFV0ND3vw,8441
4
+ fastapi_gen/generator.py,sha256=orulEK-6QU3dJ2It4CGkzcH2K82kMCGKs_2OF_qo9QQ,8538
5
5
  fastapi_gen/prompts.py,sha256=VFsGDDJzYQxwTRE4T9VskkXRjuOkHC5139prhtyZhos,67865
6
6
  fastapi_gen/upgrade/__init__.py,sha256=-JlxOkKPW-rAbldIj2V4czXN3RGoP_tSm2hB0U8OO8M,640
7
7
  fastapi_gen/upgrade/_render_worker.py,sha256=dAq5pmWJPdB3VRujFSYSh9tQ8z7klow6rCucgXEH6rE,1363
@@ -17,10 +17,10 @@ fastapi_gen/upgrade/rename_guard.py,sha256=ap0ds5k93Hh6hhQhOxrDPsh-utTE1BeBYysrT
17
17
  fastapi_gen/upgrade/render.py,sha256=PmEm7BPmEfUK29RcVgPN9PttTX7oHeWnDgf_vgGja1s,5497
18
18
  fastapi_gen/upgrade/report.py,sha256=49v9kq2tkbeqqbdH-kRIM3kccaFfPVfjhi7Tm5cCVvE,3802
19
19
  fastapi_gen/upgrade/runner.py,sha256=msnj2RYii6low6gPeZ4TRMlL01Hq8a0zJyLBzPotxCI,19302
20
- fastapi_gen/UPGRADES.yaml,sha256=rmDRhqomfyX76UzhKNQglVmvwO7B-QtejSd_zlw_iCU,5381
20
+ fastapi_gen/UPGRADES.yaml,sha256=KWHs_vnhxjjsYXVNZkIGwLPxZsJlVkxIzTBlAXkcal0,5718
21
21
  fastapi_gen/template/VARIABLES.md,sha256=GEk5LqrItHC66PBYmmi5lokwzxDxGiLvnhlsZOw97JA,35410
22
22
  fastapi_gen/template/cookiecutter.json,sha256=e1xSqG9i-CTsux-nnCUWf6v7So67_jAp_puf_siHMWs,6397
23
- fastapi_gen/template/hooks/post_gen_project.py,sha256=9gJo1XBeZAw-XyrToHs-2SbQ96Y4auepHFBU66FWv1I,60932
23
+ fastapi_gen/template/hooks/post_gen_project.py,sha256=_SYRmnOkaLtCSSbAkWl3MBokfC7brqMU3O7XICEdBi0,61696
24
24
  fastapi_gen/template/{{cookiecutter.project_slug}}/.gitignore,sha256=yC3ZUp8Txp_1TPDabDlz4pGa2p1cNwr49de0dCcctOw,1515
25
25
  fastapi_gen/template/{{cookiecutter.project_slug}}/.gitlab-ci.yml,sha256=SYDjmai3eKIiz4MbiEBHm4hBA_Ksu3Pk4Enr7cGk46Y,4659
26
26
  fastapi_gen/template/{{cookiecutter.project_slug}}/AGENTS.md,sha256=HqhXNdBq1ZXlFJCC4V3CY8DorTkZkwFJcvv2O77Pwk4,2454
@@ -31,10 +31,10 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/MANUAL_STEPS.md,sha256=EGPQya
31
31
  fastapi_gen/template/{{cookiecutter.project_slug}}/Makefile,sha256=Pjqb8ph2XTiuEWhC99ECjYGMjq_ZiT8epdN5YgjzLos,18018
32
32
  fastapi_gen/template/{{cookiecutter.project_slug}}/README.md,sha256=nXNh5TKj2wMqxZDxoFp7Q1ej87IL-Rt_VTGBkQLfKCw,14314
33
33
  fastapi_gen/template/{{cookiecutter.project_slug}}/SECURITY.md,sha256=7X5u7feq2AXxWv2CMMNQZf5QQ5QkwBnzKlrcLz3RJ_Q,4735
34
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.dev.yml,sha256=vE2ELu0RD1pWH7t-8gE4DR9XlTEnr0VWHME-heu4Qfk,12356
34
+ fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.dev.yml,sha256=OBbGFxp1zvopxDpYi0UgdxGemjVUuvh7shGjfviog4A,12356
35
35
  fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.frontend.yml,sha256=5Iu2j3ChoUGn7VTVKLkXbGwtI21z1WdHg0IPhV3dPOQ,2726
36
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.prod.yml,sha256=fhPZjbBPYokn9Bp269zaTvY9c3-FVmj5jlYCay7FabU,24806
37
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.yml,sha256=Dutt64BSlDR0s9rfIX92edmXGzPFQrIMv6OUSf6Kv9k,13643
36
+ fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.prod.yml,sha256=OhCL2j9n7DZoWxZ4FBgwRhSsJZQGDpWmSP2dc-FNGgU,24806
37
+ fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.yml,sha256=meBOsqu-bGOl8IC8ICBZ-5xbOZmvn_24u2fteS3nGr8,13643
38
38
  fastapi_gen/template/{{cookiecutter.project_slug}}/.claude/settings.json,sha256=i6XfBDlx6N1AXg4-MrjmIzPhxRXvQC9PRXJFZyfNs1Y,363
39
39
  fastapi_gen/template/{{cookiecutter.project_slug}}/.claude/commands/add-endpoint.md,sha256=p0EsXDvW23v4uOSPRlwA84nVrB7_VVL_FnKFEE442AQ,1648
40
40
  fastapi_gen/template/{{cookiecutter.project_slug}}/.claude/commands/fix-issue.md,sha256=3bcQwYzf_EXTit9nlkplUd0-G5T9-gGranogIDS_kjU,800
@@ -54,14 +54,14 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/.claude/skills/channel-bot/SK
54
54
  fastapi_gen/template/{{cookiecutter.project_slug}}/.claude/skills/frontend-feature/SKILL.md,sha256=Nn-JVLiS6KBLXcQ5ePoJ5U2CnlENsRev9qT879r2r-0,2761
55
55
  fastapi_gen/template/{{cookiecutter.project_slug}}/.claude/skills/pytest-suite/SKILL.md,sha256=1h0AiPBxFxzXayGLdz_Yw6zdNCvvrIU8yZvG6Cjuy9Y,2523
56
56
  fastapi_gen/template/{{cookiecutter.project_slug}}/.claude/skills/rag-knowledge/SKILL.md,sha256=idONRjVqfUYLEE07ne9jHY56YjO6JLWINzTFgD1-kjk,3081
57
- fastapi_gen/template/{{cookiecutter.project_slug}}/.github/workflows/ci.yml,sha256=BGEXIL1HhomWCjymRsAVfztf8N-VShRdbmeKkJeIe90,4769
57
+ fastapi_gen/template/{{cookiecutter.project_slug}}/.github/workflows/ci.yml,sha256=sPUWvlV-8XrjE0KLbaJ3BXWiyqtzCVXnxNLpE6asQWU,4769
58
58
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.dockerignore,sha256=_iRaYQqTvt8_2yhJZUp60PPaL5XLiUFg0OSa-J_9XIQ,523
59
59
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.env.example,sha256=xjNr943EoYc2Z_agIia29o3YxQTfKGKLfYw5atC6hNo,12851
60
60
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.pre-commit-config.yaml,sha256=22sYeJOrYywl_5PWgPzCyIwhpqmymIDIzx2hlBRQ-yI,681
61
61
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/Dockerfile,sha256=CKyuUKwt41LHIH9VB28TEzes5_TQkUEo9rIBjE3v8a8,2184
62
62
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic.ini,sha256=vncO8XHTAW1ospWsdvtXD5PyMhp91CJmdVfv-6TakAY,737
63
63
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/pyproject.toml,sha256=sqvn2EcWc1Q1jxFK6680ZMPbz2wztpxBqbq0UMDmHCY,15908
64
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/env.py,sha256=ToYFSeUb4pJ3OIk-EHYDHnR8qVR0OOz5nECtC3r7kuE,3521
64
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/env.py,sha256=Zj7Sgd09NmvRvXDK4yqKf31cflg4n-uUGZRZL7lXS3k,3654
65
65
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/script.py.mako,sha256=ZCfgWrEMJRDF_WF_GRGptwAIJI6YnAditBG1axwAP9Q,700
66
66
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
67
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/0000_create_users.py,sha256=nbctAgtZhw4rX2LxlBcyXL398aYFI-8RFpEOkvVb88M,2048
@@ -91,7 +91,7 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/0023
91
91
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/0024_create_webhook_tables.py,sha256=HExnIhQAJXNCe1vxhagIhUr0BeBBv2MTBadQEY4GtY8,3233
92
92
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/0025_message_thinking.py,sha256=8Wi3zcAXADP6WbjuB-Na_Y_OZTx6DDETkrZAVrNEdl8,727
93
93
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/0026_create_mcp_connections.py,sha256=ADbedBphmfFnRiZ7fssMjD2fgfqz6YIUf7F2DguKm68,3188
94
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/0027_user_magic_link_epoch.py,sha256=tbI74ZtMv0UVT1sUiAzCZSd6w_efFVh-8-E_bypdt00,1411
94
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/0027_user_magic_link_epoch.py,sha256=M0mo6oM4b0KAJA9E_do670NFOtxH05J84zWaWp2F4Cg,1619
95
95
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/__init__.py,sha256=vNnuyVXC5oZ3yq46meWLNhkUYlMgod70TgvWyvgNhBk,68
96
96
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/admin.py,sha256=jK6iIS4OlsSBID2xZOYWZCEndpSAhxwclc_lceZKIUI,14043
97
97
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/main.py,sha256=n0zgtG3bbJFFavlQv2_nG4ILdNglgYr7vIZq8uuIJIA,18931
@@ -230,7 +230,7 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/subs
230
230
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/sync_log.py,sha256=OvRWm90MlfJ-lrljtU-71NoOVbqn4guHm99LMQe3qo4,2562
231
231
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/sync_source.py,sha256=nCGKUgOUpCEBNEySqdKgZyf_GBKBgtYfFsCco_WykTc,3846
232
232
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/usage_event.py,sha256=R9BqsRQTgqmxQOyKdr12dcrrkEWUoAMEy_4gWbfHJsE,5367
233
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/user.py,sha256=Ygoy0SIbDSbiP0y0-ZaZIXxql4ujtpj6QkAM--BSOPI,5854
233
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/user.py,sha256=bG0sNbbBgugASSp6LDp_NVBw7bcaHm0suhmuLYY-Q6U,6203
234
234
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/user_slash_command.py,sha256=85ANcoeRNFQE08t8-iuh9XJqpgVYB9fy-E2f5kt6QY0,2121
235
235
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/webhook.py,sha256=gEjUe-xVHvUOTD4tTJxr0SDiHAaJ-DtUN_TZlqlIjXA,3969
236
236
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/__init__.py,sha256=gAqdgjm0KBxNSEsFthF6URbtPjdEBuQpna_2q9wcMrQ,1996
@@ -260,9 +260,9 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/user_slas
260
260
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/webhook.py,sha256=VRwBD9l_lBfnPjQxp8kg4DOLyd6FCAUj5BZjoXZN0oI,2166
261
261
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/__init__.py,sha256=2eaFa3riNnh9BVf4A6i7ChK1yqCOA8VyTg1zeL2tYy0,523
262
262
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/admin.py,sha256=FzwzW6FpIx1Ciwj_9lCbWMzi-EWv3v2-J8Sopi9LiZU,5576
263
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/agent.py,sha256=FiZxLn0bPFgEewryGrxhNnuC9Wi90Ts0fDTk4KenPzE,12675
263
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/agent.py,sha256=ifWh0ryiT8PpR0zyXGx-cnVr8fwa3wTKquEl85tZatA,14137
264
264
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/agent_invocation.py,sha256=kh3KQA1mKg1AKnpf70hCdUCblqs4x_zdNyfMH7NjmhU,18321
265
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/agent_session.py,sha256=oGUwNxrrPUysGIZsgXPzwLb9J78aScrUuD2CDxPOmSc,119859
265
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/agent_session.py,sha256=-VOhjAGNJVZLKB0iozFac5WSOLz5o9nEwMT8eW-87ng,122375
266
266
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/anomaly_detection.py,sha256=uKPCzzdeyDSUbgkD7VwFIubEHhoU1LEoOp3R1_F0SlE,3112
267
267
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/channel_bot.py,sha256=R1tfQQcNxHKZ9C3yOD6Hh4TANY77FL4XNic4Rf40qWo,6383
268
268
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/contact.py,sha256=AuML8RHIozZkchZlNMjHsZhLWpTMxukfy1xk6mak3Bk,1697
@@ -287,7 +287,7 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/research
287
287
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/session.py,sha256=mABDVV3lMvmJsprr-y_XSMQ8hTb4PIEnK_bn5jasUUw,4103
288
288
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/sync_source.py,sha256=geoKqmIjDgxAzS5Jmm2qW7fdAl9i_1ZgfiGFMNf951k,12199
289
289
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/usage.py,sha256=SUNAEnnOZjXr_PXoFGjfkMjAw7aB5FvIHReeAVI4wx8,3756
290
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/user.py,sha256=AyDsjcISFmmSDBXxt2henHLhbHbQB6OUFEutp5Kyf3E,15528
290
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/user.py,sha256=LCQKKAfhMHvqKVqofF5MnPgN1JrpHQMvE2i8aqttyvg,15966
291
291
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/user_memory.py,sha256=Q-2qwUi945EMqmRrlRU4igwGd1M3cD0ZngQTgGldSlU,8198
292
292
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/user_slash_command.py,sha256=t1-IIExupr-pvhCt_JjmiLrWfzMEzR2cDcLfhfPVRCQ,5427
293
293
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/webhook.py,sha256=RCT96wAQDnr8CUG9_gzXYxi-Av3BXzjbl0BnxNY1qWw,7500
@@ -329,7 +329,7 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/inge
329
329
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/models.py,sha256=nSKRPTC38c5ZRvscKxiETE_Kh0LZxJOQZQn-iDuhCGo,3227
330
330
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/reranker.py,sha256=HmzukI24UJLizSSENofqxCA8o5G9KKYRsbi6L0y3MEs,8847
331
331
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/retrieval.py,sha256=01zLSFj4qbA-Ytu48igtaa-EAS8D9yrAjYKc5i-BFfw,9650
332
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/vectorstore.py,sha256=mkas1Hxj56FAmyCmdYzfVx_MOg-icASG2VlelKLoDZA,28302
332
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/vectorstore.py,sha256=2wkPl6OVZ9cdtS_l7ZQ5jxbZw4n8hjpEfxRT4VmOYPo,28398
333
333
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/connectors/__init__.py,sha256=YRggWgNzfm77aqpu-LDlfq7jP-D-YtmeRNQAD1cQiLU,2361
334
334
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/connectors/google_drive.py,sha256=CHSRHTH59fKNB6qndsmBtHZqB5ihFLUiSfBGqvXtAq4,7801
335
335
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/rag/connectors/s3.py,sha256=lVz2n5vX6WPSVjsdvR9PvOUM9WYKEr0V3rhAlSIkckw,5323
@@ -367,17 +367,19 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_chart_tool
367
367
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_clients.py,sha256=qKU2z4YVQMWdnNE9aH5lnACsdzQ1G4fcE9_sK8x7K2U,6282
368
368
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_commands.py,sha256=G7pRJgk0pDQRBIFUIhi0bbDnujwKcWCjCP9Q1D9TzYA,4894
369
369
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_conversation_kb_toggle.py,sha256=ZDlX1lMuLl4q41g0f8IE0oPt3lbca4an_8c19Z1xyo8,3888
370
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_conversation_resume.py,sha256=FVcZmYGf3uG-2OpBf4W2vQe-qQtKP9qobLYS5XPDy9s,6371
370
371
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_conversation_write_access.py,sha256=1srJF_IkCMZxoSxnEqN7YW2LSZzDo0tkXQ-1i_RaesM,4561
371
372
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_core.py,sha256=dF_RgCNrHnI3PqhOVqqcYg_XgcDPCmkR_YWw6POCngw,5973
373
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_deep_research_streaming.py,sha256=5I5D3GcGTcvUU4a-3ohOegUlsQmuYQkkL4OB1FSNqoo,2772
372
374
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_fetch_url.py,sha256=ZnPxBUYH6KyAWcQf1MTEQEUvb7tpDhXcmbVKRLR2Xuw,3595
373
375
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_kb_scoping.py,sha256=fEV6jEaPtW5oNyRBDAA_S2jHS2QyxXWmOG-EKhYD7Hk,6573
374
376
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_mcp_connections.py,sha256=SuyqG3pLHx3GOzte48M09sp-Aes5ikd2kxwbMYE8xLA,34833
375
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_memory.py,sha256=iGD_Ryab3lAV4MdBseglBQAImRIwD6SJrmTEazIdJHk,12907
377
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_memory.py,sha256=nRh_rsqsDzS50XlKxiQ6b1A2JlKgX0dqHOgri15zC70,13667
376
378
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_memory_channels.py,sha256=NK_YcOGSaZwVY8f9vFGN_oSN62enAUa00zsXLakdTYE,1964
377
379
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_memory_postgres.py,sha256=aZcaCFkefQwqZiyioKF8Iot-TbC9IKu-ETZMeksGVsc,4868
378
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_migrations.py,sha256=QJDbmRSyGCvZKBerFrSs4kA5f1PHaMNDShzCuqSR2NQ,3603
380
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_migrations.py,sha256=wf0DEAT8-WIe9YT7PZ6zUUN68OjLC1D8vQJZrfkLJ8Y,3946
379
381
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_openai_compatible.py,sha256=B2lxdMq6jp8s6vWGBqlIm-ZT7fFR1nmuSFtWRMnt0ak,2123
380
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_pydantic_deep_history.py,sha256=OH6WN7TasmMoJ_DVskNB1pGnzLMpoMGNnFVmzMc5bhM,5650
382
+ fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_pydantic_deep_history.py,sha256=Vl9bkzbpBrX6D4NMU8ZOldvvDlwE4OabHZCeN-QVONU,6065
381
383
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_rbac_teams.py,sha256=ryLOK_4YMtSBfRqeVFEnvcQXoGkQEpDrX0OAsCmm-v8,7037
382
384
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_repositories.py,sha256=uQHtc5I5OZpWnO7rC1Y8C7uw1WZWtG_HNWwxpI2OhtM,1286
383
385
  fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_repositories_teams.py,sha256=bIvtIATkynFWyvi81zXphiVyFf1cWu6qgRiB-EQzgMo,9675
@@ -942,8 +944,8 @@ fastapi_gen/template/{{cookiecutter.project_slug}}/kubernetes/service.yaml,sha25
942
944
  fastapi_gen/template/{{cookiecutter.project_slug}}/nginx/nginx.conf,sha256=2bWaxnv_rN4driEdtWgVz9eVfoKhB_Ohd_G8eOC3P3M,7619
943
945
  fastapi_gen/template/{{cookiecutter.project_slug}}/nginx/ssl/.gitkeep,sha256=o_WQQOgVGOLttT48x0EXSC4BbbDFemApFpmwhybcVUU,617
944
946
  fastapi_gen/template/{{cookiecutter.project_slug}}/scripts/export_demo_html.py,sha256=H1tbIfr1xrh2pRuoy5NwvAOYEu0S2vgnw_XsKNMKXeM,10414
945
- fastapi_fullstack-0.2.20.dist-info/METADATA,sha256=zxPYAVk90tBlrP-aCNfOxTtwh1Sezo37xvbw5DY6iyk,62263
946
- fastapi_fullstack-0.2.20.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
947
- fastapi_fullstack-0.2.20.dist-info/entry_points.txt,sha256=s9JXrISZp8LMYJGeVofOAd1wPTzpq-jwjSgSf4hWzjs,59
948
- fastapi_fullstack-0.2.20.dist-info/licenses/LICENSE,sha256=bL4JuK_rcA8y__Gg7PEuTs3g2Qf6VvSz2w2Jajd6nVU,1063
949
- fastapi_fullstack-0.2.20.dist-info/RECORD,,
947
+ fastapi_fullstack-0.2.22.dist-info/METADATA,sha256=00cqQL3JYJwB6sKNaDVPz1cWk9Visi_bR-wXfO9Cv8c,62330
948
+ fastapi_fullstack-0.2.22.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
949
+ fastapi_fullstack-0.2.22.dist-info/entry_points.txt,sha256=s9JXrISZp8LMYJGeVofOAd1wPTzpq-jwjSgSf4hWzjs,59
950
+ fastapi_fullstack-0.2.22.dist-info/licenses/LICENSE,sha256=bL4JuK_rcA8y__Gg7PEuTs3g2Qf6VvSz2w2Jajd6nVU,1063
951
+ fastapi_fullstack-0.2.22.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.4
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
fastapi_gen/UPGRADES.yaml CHANGED
@@ -18,6 +18,10 @@
18
18
  # manual_steps:
19
19
  # - "Run `alembic upgrade head` (new billing tables)."
20
20
 
21
+ - version: "0.2.21"
22
+ manual_steps:
23
+ - "Run `alembic upgrade head`. Since 0.2.19, projects without --mcp-client could not migrate past 0025 (`KeyError: '0026_create_mcp_connections'`); with the corrected chain the pending migrations apply, including 0027 (users.magic_link_epoch, which magic-link sign-in reads when --email is on)."
24
+
21
25
  - version: "0.2.20"
22
26
  breaking:
23
27
  - "Redis is replaced by Valkey (valkey/valkey:9-alpine) in the compose files and the generated CI. The protocol, the redis client, the REDIS_* settings and the `redis` service name are unchanged."
fastapi_gen/generator.py CHANGED
@@ -77,7 +77,8 @@ def generate_project(config: ProjectConfig, output_dir: Path | None = None) -> P
77
77
 
78
78
  # Check if target directory already exists and is not empty
79
79
  target_dir = output_dir / config.project_slug
80
- if target_dir.exists() and any(target_dir.iterdir()):
80
+ target_dir_exists = target_dir.exists()
81
+ if target_dir_exists and any(target_dir.iterdir()):
81
82
  raise ValueError(f"Directory '{target_dir}' already exists and is not empty")
82
83
 
83
84
  context = config.to_cookiecutter_context()
@@ -97,6 +98,7 @@ def generate_project(config: ProjectConfig, output_dir: Path | None = None) -> P
97
98
  extra_context=context,
98
99
  output_dir=str(output_dir),
99
100
  no_input=True,
101
+ overwrite_if_exists=target_dir_exists,
100
102
  )
101
103
  write_manifest(Path(project_path), context)
102
104
  except Exception:
@@ -79,7 +79,6 @@ def remove_file(path: str) -> None:
79
79
  """Remove a file if it exists."""
80
80
  if os.path.exists(path):
81
81
  os.remove(path)
82
- print(f" Removed: {os.path.relpath(path)}")
83
82
 
84
83
 
85
84
  def read_text(filepath: str) -> str:
@@ -121,7 +120,6 @@ def remove_dir(path: str) -> None:
121
120
  """Remove a directory if it exists."""
122
121
  if os.path.exists(path):
123
122
  shutil.rmtree(path)
124
- print(f" Removed: {os.path.relpath(path)}/")
125
123
 
126
124
 
127
125
  backend_app = os.path.join(os.getcwd(), "backend", "app")
@@ -255,6 +253,8 @@ if not enable_subagents and use_frontend:
255
253
 
256
254
  if not use_ai:
257
255
  remove_dir(os.path.join(backend_app, "agents"))
256
+ # Its module goes below; a test left behind fails the whole run at collection.
257
+ remove_file(os.path.join(os.getcwd(), "backend", "tests", "test_services_conversation.py"))
258
258
  remove_dir(os.path.join(os.getcwd(), ".claude", "skills", "agent-tool"))
259
259
  remove_file(os.path.join(backend_app, "services", "agent.py"))
260
260
  remove_file(os.path.join(backend_app, "services", "agent_session.py"))
@@ -516,6 +516,24 @@ if "{{ cookiecutter.use_pydantic_deep }}" != "True":
516
516
  if not (use_slack or use_telegram):
517
517
  remove_file(os.path.join(os.getcwd(), "backend", "tests", "test_channel_history.py"))
518
518
 
519
+ # The deep-research streaming tests render to a stub without it.
520
+ if not (
521
+ "{{ cookiecutter.use_pydantic_ai }}" == "True"
522
+ and "{{ cookiecutter.enable_deep_research }}" == "True"
523
+ ):
524
+ remove_file(os.path.join(os.getcwd(), "backend", "tests", "test_deep_research_streaming.py"))
525
+
526
+ # The conversation-resume tests render to a stub without a database and a
527
+ # Pydantic AI-based agent.
528
+ if not (
529
+ "{{ cookiecutter.use_database }}" == "True"
530
+ and (
531
+ "{{ cookiecutter.use_pydantic_ai }}" == "True"
532
+ or "{{ cookiecutter.use_pydantic_deep }}" == "True"
533
+ )
534
+ ):
535
+ remove_file(os.path.join(os.getcwd(), "backend", "tests", "test_conversation_resume.py"))
536
+
519
537
  # Scan all .py files under backend/app — catches any template that rendered to
520
538
  # a stub docstring because its feature gate was disabled.
521
539
  for root, _dirs, files in os.walk(backend_app):
@@ -731,7 +749,7 @@ else:
731
749
  "NEXT_PUBLIC_BRAND_LOGO_URL=",
732
750
  ])
733
751
 
734
- with open(frontend_env_local, "w") as f:
752
+ with open(frontend_env_local, "w", encoding="utf-8") as f:
735
753
  f.write("\n".join(env_lines) + "\n")
736
754
  print("Generated frontend/.env.local")
737
755
 
@@ -14,7 +14,7 @@ jobs:
14
14
  - uses: actions/checkout@v7
15
15
 
16
16
  - name: Install uv
17
- uses: astral-sh/setup-uv@v10.2.0
17
+ uses: astral-sh/setup-uv@v10.4.0
18
18
  with:
19
19
  version: "latest"
20
20
 
@@ -65,7 +65,7 @@ jobs:
65
65
  - uses: actions/checkout@v7
66
66
 
67
67
  - name: Install uv
68
- uses: astral-sh/setup-uv@v10.2.0
68
+ uses: astral-sh/setup-uv@v10.4.0
69
69
  with:
70
70
  version: "latest"
71
71
 
@@ -138,7 +138,7 @@ jobs:
138
138
  - uses: actions/checkout@v7
139
139
 
140
140
  - name: Install uv
141
- uses: astral-sh/setup-uv@v10.2.0
141
+ uses: astral-sh/setup-uv@v10.4.0
142
142
  with:
143
143
  version: "latest"
144
144
 
@@ -22,10 +22,13 @@ from app.db.base import Base
22
22
  {%- if cookiecutter.use_jwt %}
23
23
  from app.db.models.user import User # noqa: F401
24
24
  {%- endif %}
25
+ {%- if cookiecutter.use_ai %}
26
+ # Generated only with an AI framework; the core-tables migration creates them regardless.
25
27
  from app.db.models.conversation import Conversation, Message, ToolCall # noqa: F401
26
28
  {%- if cookiecutter.use_jwt %}
27
29
  from app.db.models.message_rating import MessageRating # noqa: F401
28
30
  {%- endif %}
31
+ {%- endif %}
29
32
  {%- if cookiecutter.enable_session_management and cookiecutter.use_jwt %}
30
33
  from app.db.models.session import Session # noqa: F401
31
34
  {%- endif %}
@@ -17,7 +17,8 @@ import sqlalchemy as sa
17
17
  from alembic import op
18
18
 
19
19
  revision = "0027_user_magic_link_epoch"
20
- down_revision = "0026_create_mcp_connections"
20
+ # 0026 exists only with the MCP client.
21
+ down_revision = "{% if cookiecutter.enable_mcp_client %}0026_create_mcp_connections{% else %}0025{% endif %}"
21
22
  branch_labels = None
22
23
  depends_on = None
23
24
 
@@ -41,7 +42,8 @@ magic-link sign-in) is disabled.
41
42
  """
42
43
 
43
44
  revision = "0027_user_magic_link_epoch"
44
- down_revision = "0026_create_mcp_connections"
45
+ # 0026 exists only with the MCP client.
46
+ down_revision = "{% if cookiecutter.enable_mcp_client %}0026_create_mcp_connections{% else %}0025{% endif %}"
45
47
  branch_labels = None
46
48
  depends_on = None
47
49
 
@@ -4,7 +4,8 @@
4
4
  from typing import Any
5
5
  from uuid import UUID
6
6
 
7
- from sqlalchemy import delete as sql_delete, func, literal, select
7
+ from sqlalchemy import asc, desc, func, literal, select
8
+ from sqlalchemy import delete as sql_delete
8
9
  from sqlalchemy.ext.asyncio import AsyncSession
9
10
 
10
11
  from app.db.models.user import User
@@ -143,6 +144,14 @@ async def delete(db: AsyncSession, user_id: UUID) -> User | None:
143
144
  return user
144
145
 
145
146
 
147
+ {%- if cookiecutter.enable_memory %}
148
+ async def list_non_admin_ids(db: AsyncSession) -> list[UUID]:
149
+ """Ids of the users without the admin role - those ``delete_non_admins`` removes."""
150
+ result = await db.execute(select(User.id).where(User.role != "admin"))
151
+ return list(result.scalars().all())
152
+
153
+
154
+ {%- endif %}
146
155
  async def delete_non_admins(db: AsyncSession) -> int:
147
156
  """Bulk-delete users without the admin role. Returns affected row count."""
148
157
  result = await db.execute(sql_delete(User).where(User.role != "admin"))
@@ -194,7 +203,7 @@ async def admin_list_with_counts(
194
203
  "conversations": conv_count_col,
195
204
  }
196
205
  sort_col = sort_columns.get(sort_by, User.created_at)
197
- sort_col = sort_col.desc() if sort_dir == "desc" else sort_col.asc()
206
+ sort_col = desc(sort_col) if sort_dir == "desc" else asc(sort_col)
198
207
  query = query.order_by(sort_col).offset(skip).limit(limit)
199
208
 
200
209
  total = await db.scalar(count_query) or 0
@@ -233,6 +233,41 @@ def normalize_tool_args(args: Any) -> dict[str, Any]:
233
233
  return args
234
234
 
235
235
 
236
+ # How much of a stored conversation a resumed session replays to the model.
237
+ HISTORY_REPLAY_LIMIT = 100
238
+
239
+
240
+ async def load_conversation_history(
241
+ conversation_id: str, *, current_prompt: str
242
+ ) -> list[dict[str, str]]:
243
+ """A stored conversation's user and assistant messages, oldest first, to resume it.
244
+
245
+ A session holds the conversation in memory only while it lasts; reconnecting,
246
+ or switching to another conversation, would otherwise start the model from
247
+ nothing. The most recent ``HISTORY_REPLAY_LIMIT`` messages are replayed.
248
+ ``persist_user_turn`` has already stored ``current_prompt`` as the last
249
+ message - it is this turn's prompt, so it is left out rather than sent twice.
250
+
251
+ The caller has already checked the user may access the conversation.
252
+ """
253
+ async with get_db_context() as db:
254
+ conv_service = get_conversation_service(db)
255
+ _, total = await conv_service.list_messages(UUID(conversation_id), limit=1)
256
+ messages, _ = await conv_service.list_messages(
257
+ UUID(conversation_id),
258
+ skip=max(0, total - HISTORY_REPLAY_LIMIT - 1),
259
+ limit=HISTORY_REPLAY_LIMIT + 1,
260
+ )
261
+ history = [
262
+ {"role": m.role, "content": m.content}
263
+ for m in messages
264
+ if m.role in ("user", "assistant") and m.content
265
+ ]
266
+ if history and history[-1] == {"role": "user", "content": current_prompt}:
267
+ history.pop()
268
+ return history[-HISTORY_REPLAY_LIMIT:]
269
+
270
+
236
271
  async def persist_assistant_turn(
237
272
  conversation_id: str,
238
273
  output: str,
@@ -35,6 +35,7 @@ from app.core.exceptions import AuthorizationError, NotFoundError
35
35
  from app.services.agent import (
36
36
  build_message_history,
37
37
  {%- if cookiecutter.use_database %}
38
+ load_conversation_history,
38
39
  persist_assistant_turn,
39
40
  persist_user_turn,
40
41
  {%- endif %}
@@ -93,6 +94,8 @@ class AgentSession:
93
94
  self.deps.ask_user = self._ask_user
94
95
  {%- if cookiecutter.use_database %}
95
96
  self.current_conversation_id: str | None = None
97
+ # The conversation ``conversation_history`` belongs to.
98
+ self._history_conversation_id: str | None = None
96
99
  {%- endif %}
97
100
  self._turn_task: asyncio.Task[None] | None = None
98
101
  self._ask_user_future: asyncio.Future[list[dict[str, Any]]] | None = None
@@ -210,6 +213,17 @@ class AgentSession:
210
213
  "conversation_created",
211
214
  {"conversation_id": self.current_conversation_id},
212
215
  )
216
+ if self.current_conversation_id != self._history_conversation_id:
217
+ # Another conversation, or this one resumed on a new connection: the
218
+ # model gets its stored history, not the previous conversation's.
219
+ self.conversation_history = (
220
+ await load_conversation_history(
221
+ self.current_conversation_id, current_prompt=user_message
222
+ )
223
+ if self.current_conversation_id and not newly_created
224
+ else []
225
+ )
226
+ self._history_conversation_id = self.current_conversation_id
213
227
  {%- endif %}
214
228
 
215
229
  await send_event(self.websocket, "user_prompt", {"content": user_message})
@@ -656,6 +670,10 @@ class AgentSession:
656
670
  collected_thinking: list[str],
657
671
  ) -> None:
658
672
  """Drive the agent_run iterator, dispatching each node to its streaming helper."""
673
+ {%- if cookiecutter.enable_deep_research %}
674
+ # Text held back from the latest model request (see _stream_request_events).
675
+ withheld_text: list[tuple[int, str]] = []
676
+ {%- endif %}
659
677
  async for node in agent_run:
660
678
  if Agent.is_user_prompt_node(node):
661
679
  prompt_text = (
@@ -667,28 +685,50 @@ class AgentSession:
667
685
  elif Agent.is_model_request_node(node):
668
686
  await send_event(self.websocket, "model_request_start", {})
669
687
  async with node.stream(agent_run.ctx) as request_stream:
688
+ {%- if cookiecutter.enable_deep_research %}
689
+ withheld_text = await self._stream_request_events(
690
+ request_stream, collected_thinking
691
+ )
692
+ {%- else %}
670
693
  await self._stream_request_events(request_stream, collected_thinking)
694
+ {%- endif %}
671
695
  elif Agent.is_call_tools_node(node):
672
696
  await send_event(self.websocket, "call_tools_start", {})
673
697
  async with node.stream(agent_run.ctx) as handle_stream:
674
698
  await self._stream_tool_events(handle_stream, collected_tool_calls)
675
699
  elif Agent.is_end_node(node) and agent_run.result is not None:
700
+ {%- if cookiecutter.enable_deep_research %}
701
+ # A run that ends on a step whose text was withheld as narration
702
+ # ended on its answer: send it, rather than a final result the
703
+ # chat never showed.
704
+ for index, content in withheld_text:
705
+ await send_event(
706
+ self.websocket, "text_delta", {"index": index, "content": content}
707
+ )
708
+ {%- endif %}
676
709
  await send_event(
677
710
  self.websocket, "final_result", {"output": agent_run.result.output}
678
711
  )
679
712
 
680
713
  async def _stream_request_events(
681
714
  self, request_stream: Any, collected_thinking: list[str]
715
+ {%- if cookiecutter.enable_deep_research %}
716
+ ) -> list[tuple[int, str]]:
717
+ {%- else %}
682
718
  ) -> None:
719
+ {%- endif %}
683
720
  """Forward model-request events (text/thinking/tool deltas + final-result start).
684
721
  {%- if cookiecutter.enable_deep_research %}
685
722
 
686
723
  During a deep research turn the model narrates every delegation step.
687
724
  A plain-text response ends a PydanticAI run, so a step that issues a
688
725
  planning/delegation tool call (``RESEARCH_TOOL_NAMES``) is interstitial:
689
- its text is buffered and dropped. A step with only content tools (charts,
690
- RAG) or no tool calls is the final answer and its text is released.
691
- Reasoning and tool events are always forwarded.
726
+ its text is withheld. A step with only content tools (charts, RAG) or no
727
+ tool calls is the final answer and its text is released. Reasoning and
728
+ tool events are always forwarded.
729
+
730
+ Returns the withheld text, for the caller to send should the run end on
731
+ this step after all.
692
732
  {%- endif %}
693
733
  """
694
734
  {%- if cookiecutter.enable_deep_research %}
@@ -776,11 +816,13 @@ class AgentSession:
776
816
  {%- if cookiecutter.enable_deep_research %}
777
817
 
778
818
  made_research_call = any(name in RESEARCH_TOOL_NAMES for name in tool_names.values())
779
- if deep_research and buffered_text and not made_research_call:
780
- for index, content in buffered_text:
781
- await send_event(
782
- self.websocket, "text_delta", {"index": index, "content": content}
783
- )
819
+ if not deep_research or not buffered_text:
820
+ return []
821
+ if made_research_call:
822
+ return buffered_text
823
+ for index, content in buffered_text:
824
+ await send_event(self.websocket, "text_delta", {"index": index, "content": content})
825
+ return []
784
826
  {%- endif %}
785
827
 
786
828
  async def _stream_tool_events(
@@ -2445,12 +2487,13 @@ from pydantic_ai.messages import (
2445
2487
  )
2446
2488
  from pydantic_ai_backends import StateBackend
2447
2489
 
2448
- from app.agents.pydantic_deep_assistant import PydanticDeepContext, get_agent
2490
+ from app.agents.pydantic_deep_assistant import PydanticDeepContext, get_agent, to_model_messages
2449
2491
  {%- if cookiecutter.use_database %}
2450
2492
  from app.core.exceptions import AuthorizationError, NotFoundError
2451
2493
  {%- endif %}
2452
2494
  from app.services.agent import (
2453
2495
  {%- if cookiecutter.use_database %}
2496
+ load_conversation_history,
2454
2497
  persist_assistant_turn,
2455
2498
  persist_user_turn,
2456
2499
  {%- endif %}
@@ -2614,7 +2657,21 @@ class AgentSession:
2614
2657
  conversation_key = "default"
2615
2658
  {%- endif %}
2616
2659
  if conversation_key != self._history_key:
2660
+ {%- if cookiecutter.use_database %}
2661
+ # Another conversation, or this one resumed on a new connection:
2662
+ # its stored history, not the previous conversation's.
2663
+ self._message_history = (
2664
+ to_model_messages(
2665
+ await load_conversation_history(
2666
+ self.current_conversation_id, current_prompt=user_message
2667
+ )
2668
+ )
2669
+ if self.current_conversation_id and not newly_created
2670
+ else []
2671
+ )
2672
+ {%- else %}
2617
2673
  self._message_history = []
2674
+ {%- endif %}
2618
2675
  self._workspace_documents = {}
2619
2676
  self._history_key = conversation_key
2620
2677
  assistant = get_agent(
@@ -300,12 +300,13 @@ class QdrantVectorStore(BaseVectorStore):
300
300
  )
301
301
  return [
302
302
  SearchResult(
303
- content=hit.payload.get("content", ""),
303
+ content=payload.get("content", ""),
304
304
  score=hit.score,
305
- metadata=hit.payload.get("metadata", {}),
306
- parent_doc_id=hit.payload.get("parent_doc_id"),
305
+ metadata=payload.get("metadata", {}),
306
+ parent_doc_id=payload.get("parent_doc_id"),
307
307
  )
308
308
  for hit in results
309
+ if (payload := hit.payload) is not None
309
310
  ]
310
311
 
311
312
  async def get_collection_info(self, collection_name: str) -> CollectionInfo:
@@ -332,8 +333,9 @@ class QdrantVectorStore(BaseVectorStore):
332
333
  await self._ensure_collection(collection_name)
333
334
  records, _ = await self.client.scroll(collection_name=collection_name, limit=10000, with_payload=True)
334
335
  results = [
335
- {"parent_doc_id": r.payload.get("parent_doc_id"), "metadata": r.payload.get("metadata", {})}
336
- for r in records
336
+ {"parent_doc_id": payload.get("parent_doc_id"), "metadata": payload.get("metadata", {})}
337
+ for record in records
338
+ if (payload := record.payload) is not None
337
339
  ]
338
340
  return self._group_documents(results)
339
341
 
@@ -84,7 +84,17 @@ class UserService:
84
84
  {%- endif %}
85
85
 
86
86
  async def delete_non_admins(self) -> int:
87
+ {%- if cookiecutter.enable_memory %}
88
+ user_ids = await user_repo.list_non_admin_ids(self.db)
89
+ deleted = await user_repo.delete_non_admins(self.db)
90
+ # As in delete(): the memory store has no foreign key to users, and a
91
+ # failure to clear it rolls the request's transaction back too.
92
+ for user_id in user_ids:
93
+ await forget_user_memory(user_id)
94
+ return deleted
95
+ {%- else %}
87
96
  return await user_repo.delete_non_admins(self.db)
97
+ {%- endif %}
88
98
 
89
99
  async def has_any(self) -> bool:
90
100
  return await user_repo.has_any(self.db)
@@ -0,0 +1,181 @@
1
+ {%- if cookiecutter.use_database and (cookiecutter.use_pydantic_ai or cookiecutter.use_pydantic_deep) %}
2
+ """A conversation resumed on a new connection keeps its context.
3
+
4
+ The session holds the conversation in memory only while the WebSocket lasts, so
5
+ a reconnect - or switching to another conversation - loads that conversation's
6
+ stored messages instead of starting the model from nothing, or from the
7
+ previous conversation's.
8
+ """
9
+
10
+ from collections.abc import AsyncIterator
11
+ from contextlib import asynccontextmanager
12
+ from unittest.mock import AsyncMock, MagicMock, patch
13
+ from uuid import uuid4
14
+
15
+ import pytest
16
+ from pydantic_ai.messages import ModelMessage, ModelRequest, ModelResponse, TextPart, UserPromptPart
17
+ from pydantic_ai.models.function import AgentInfo, DeltaToolCalls, FunctionModel
18
+
19
+ from app.services import agent as agent_service
20
+ from app.services.agent import HISTORY_REPLAY_LIMIT, load_conversation_history
21
+ from app.services.agent_session import AgentSession
22
+
23
+ pytestmark = pytest.mark.anyio
24
+
25
+
26
+ def _prompts(messages: list[ModelMessage]) -> list[str]:
27
+ return [
28
+ part.content
29
+ for message in messages
30
+ if isinstance(message, ModelRequest)
31
+ for part in message.parts
32
+ if isinstance(part, UserPromptPart)
33
+ and isinstance(part.content, str)
34
+ # The harness adds its memory trust marker as a user-role message
35
+ # for providers that cannot insert a system message mid-history.
36
+ and not part.content.startswith("<system>The accompanying <memory>")
37
+ ]
38
+
39
+
40
+ class _Recorder:
41
+ """A streaming model that records the prompts each request carried."""
42
+
43
+ def __init__(self) -> None:
44
+ self.seen: list[list[str]] = []
45
+
46
+ def respond(self, messages: list[ModelMessage], info: AgentInfo) -> ModelResponse:
47
+ self.seen.append(_prompts(messages))
48
+ return ModelResponse(parts=[TextPart(content="ok")])
49
+
50
+ async def stream(
51
+ self, messages: list[ModelMessage], info: AgentInfo
52
+ ) -> AsyncIterator[str | DeltaToolCalls]:
53
+ self.respond(messages, info)
54
+ yield "ok"
55
+
56
+ def model(self) -> FunctionModel:
57
+ return FunctionModel(self.respond, stream_function=self.stream)
58
+
59
+
60
+ def _session() -> AgentSession:
61
+ {%- if cookiecutter.websocket_auth_jwt %}
62
+ return AgentSession(MagicMock(), MagicMock(id=uuid4(), email="u@example.com"))
63
+ {%- else %}
64
+ return AgentSession(MagicMock())
65
+ {%- endif %}
66
+
67
+
68
+ async def _turn(
69
+ session: AgentSession,
70
+ model: _Recorder,
71
+ text: str,
72
+ conversation_id: str,
73
+ *,
74
+ stored: list[dict[str, str]],
75
+ newly_created: bool = False,
76
+ ) -> None:
77
+ with (
78
+ {%- if cookiecutter.use_pydantic_ai %}
79
+ patch("app.agents.assistant._build_model", lambda _name: model.model()),
80
+ {%- else %}
81
+ patch(
82
+ "app.agents.pydantic_deep_assistant.PydanticDeepAssistant._get_model_string",
83
+ lambda self: model.model(),
84
+ ),
85
+ {%- endif %}
86
+ patch(
87
+ "app.services.agent_session.persist_user_turn",
88
+ AsyncMock(return_value=(conversation_id, newly_created, None)),
89
+ ),
90
+ patch(
91
+ "app.services.agent_session.load_conversation_history",
92
+ AsyncMock(return_value=list(stored)),
93
+ ),
94
+ patch("app.services.agent_session.persist_assistant_turn", AsyncMock(return_value=None)),
95
+ {%- if cookiecutter.enable_teams and cookiecutter.enable_rag %}
96
+ patch("app.services.agent_session.resolve_kb_collections", AsyncMock(return_value=[])),
97
+ {%- endif %}
98
+ {%- if cookiecutter.enable_mcp_client %}
99
+ patch("app.services.agent_session.build_toolsets_for_user", AsyncMock(return_value=[])),
100
+ {%- endif %}
101
+ patch("app.services.agent_session.send_event", AsyncMock()),
102
+ ):
103
+ await session.process_message({"message": text, "conversation_id": conversation_id})
104
+
105
+
106
+ STORED = [
107
+ {"role": "user", "content": "my name is Ada"},
108
+ {"role": "assistant", "content": "Hello Ada"},
109
+ ]
110
+
111
+
112
+ async def test_a_resumed_conversation_starts_from_its_stored_history():
113
+ """A new connection: nothing in memory, the conversation in the database."""
114
+ model = _Recorder()
115
+
116
+ await _turn(_session(), model, "what is my name?", str(uuid4()), stored=STORED)
117
+
118
+ assert model.seen[-1] == ["my name is Ada", "what is my name?"]
119
+
120
+
121
+ async def test_a_new_conversation_starts_empty():
122
+ model = _Recorder()
123
+
124
+ await _turn(_session(), model, "hello", str(uuid4()), stored=STORED, newly_created=True)
125
+
126
+ assert model.seen[-1] == ["hello"]
127
+
128
+
129
+ async def test_switching_conversations_does_not_carry_the_previous_one_over():
130
+ session, model = _session(), _Recorder()
131
+ first, second = str(uuid4()), str(uuid4())
132
+
133
+ await _turn(session, model, "the secret is 42", first, stored=[])
134
+ await _turn(session, model, "what is the secret?", second, stored=[])
135
+
136
+ assert model.seen[-1] == ["what is the secret?"]
137
+
138
+
139
+ def _stored_messages(count: int) -> list[MagicMock]:
140
+ return [
141
+ MagicMock(role="user" if i % 2 == 0 else "assistant", content=f"m{i}") for i in range(count)
142
+ ]
143
+
144
+
145
+ @asynccontextmanager
146
+ async def _db():
147
+ yield MagicMock()
148
+
149
+
150
+ async def _load(messages: list[MagicMock], current_prompt: str) -> list[dict[str, str]]:
151
+ service = MagicMock()
152
+
153
+ async def list_messages(_conversation_id, *, skip: int = 0, limit: int = 100):
154
+ return messages[skip : skip + limit], len(messages)
155
+
156
+ service.list_messages = list_messages
157
+ with (
158
+ patch.object(agent_service, "get_db_context", _db),
159
+ patch.object(agent_service, "get_conversation_service", return_value=service),
160
+ ):
161
+ return await load_conversation_history(str(uuid4()), current_prompt=current_prompt)
162
+
163
+
164
+ async def test_the_current_prompt_is_not_replayed_as_history():
165
+ messages = [*_stored_messages(2), MagicMock(role="user", content="now")]
166
+
167
+ history = await _load(messages, "now")
168
+
169
+ assert history == [{"role": "user", "content": "m0"}, {"role": "assistant", "content": "m1"}]
170
+
171
+
172
+ async def test_only_the_most_recent_messages_are_replayed():
173
+ messages = [*_stored_messages(HISTORY_REPLAY_LIMIT + 10), MagicMock(role="user", content="now")]
174
+
175
+ history = await _load(messages, "now")
176
+
177
+ assert len(history) == HISTORY_REPLAY_LIMIT
178
+ assert history[-1]["content"] == f"m{HISTORY_REPLAY_LIMIT + 9}"
179
+ {%- else %}
180
+ """Conversation resume tests - not configured (needs a database and Pydantic AI or PydanticDeep)."""
181
+ {%- endif %}
@@ -0,0 +1,85 @@
1
+ {%- if cookiecutter.use_pydantic_ai and cookiecutter.enable_deep_research %}
2
+ """Deep research releases withheld narration when a run ends on it.
3
+
4
+ Text sent with a planning or delegation tool call is held back as narration.
5
+ Pydantic AI continues the run after such a step, so that text is normally not
6
+ the answer - but if a run does end there, it was, and must reach the chat
7
+ before ``final_result``.
8
+ """
9
+
10
+ from contextlib import asynccontextmanager
11
+ from types import SimpleNamespace
12
+ from unittest.mock import AsyncMock, MagicMock, patch
13
+ from uuid import uuid4
14
+
15
+ import pytest
16
+
17
+ from app.services.agent_session import AgentSession
18
+
19
+ pytestmark = pytest.mark.anyio
20
+
21
+
22
+ class _Request:
23
+ @asynccontextmanager
24
+ async def stream(self, _ctx):
25
+ yield MagicMock()
26
+
27
+
28
+ class _End:
29
+ pass
30
+
31
+
32
+ class _Run:
33
+ """An agent run of one model request followed by the end of the run."""
34
+
35
+ def __init__(self, output: str) -> None:
36
+ self.ctx = MagicMock()
37
+ self.result = SimpleNamespace(output=output)
38
+
39
+ async def __aiter__(self):
40
+ yield _Request()
41
+ yield _End()
42
+
43
+
44
+ async def _events_for(withheld: list[tuple[int, str]]) -> list[tuple[str, dict]]:
45
+ {%- if cookiecutter.websocket_auth_jwt %}
46
+ session = AgentSession(MagicMock(), MagicMock(id=uuid4(), email="u@example.com"))
47
+ {%- else %}
48
+ session = AgentSession(MagicMock())
49
+ {%- endif %}
50
+ events: list[tuple[str, dict]] = []
51
+
52
+ async def _send(_websocket, event_type, data):
53
+ events.append((event_type, data))
54
+
55
+ with (
56
+ patch("app.services.agent_session.send_event", _send),
57
+ patch.object(session, "_stream_request_events", AsyncMock(return_value=withheld)),
58
+ patch("app.services.agent_session.Agent.is_user_prompt_node", lambda node: False),
59
+ patch(
60
+ "app.services.agent_session.Agent.is_model_request_node",
61
+ lambda node: isinstance(node, _Request),
62
+ ),
63
+ patch("app.services.agent_session.Agent.is_call_tools_node", lambda node: False),
64
+ patch("app.services.agent_session.Agent.is_end_node", lambda node: isinstance(node, _End)),
65
+ ):
66
+ await session._stream_agent_run(_Run("the report"), "go", [], [])
67
+ return events
68
+
69
+
70
+ async def test_text_withheld_from_the_last_step_is_sent_before_the_result():
71
+ events = await _events_for([(0, "the report")])
72
+
73
+ assert events[-2:] == [
74
+ ("text_delta", {"index": 0, "content": "the report"}),
75
+ ("final_result", {"output": "the report"}),
76
+ ]
77
+
78
+
79
+ async def test_nothing_extra_is_sent_when_nothing_was_withheld():
80
+ events = await _events_for([])
81
+
82
+ assert [event for event, _ in events] == ["model_request_start", "final_result"]
83
+ {%- else %}
84
+ """Deep research streaming tests - not configured (needs Pydantic AI deep research)."""
85
+ {%- endif %}
@@ -1,6 +1,6 @@
1
1
  """Tests for the agent memory capability factory and the user memory service."""
2
2
 
3
- from unittest.mock import patch
3
+ from unittest.mock import AsyncMock, MagicMock, patch
4
4
  from uuid import uuid4
5
5
 
6
6
  import pytest
@@ -295,3 +295,27 @@ class TestUserMemoryService:
295
295
 
296
296
  assert listing.items == []
297
297
  {%- endif %}
298
+
299
+
300
+ @pytest.mark.anyio
301
+ async def test_deleting_all_non_admins_forgets_their_memory():
302
+ """The bulk reset removes rows the memory store has no foreign key to."""
303
+ from app.services.user import UserService
304
+
305
+ ids = [uuid4(), uuid4()]
306
+ forgotten: list = []
307
+
308
+ async def _forget(user_id):
309
+ forgotten.append(user_id)
310
+ return 1
311
+
312
+ with (
313
+ patch("app.services.user.user_repo.list_non_admin_ids", AsyncMock(return_value=ids)),
314
+ patch("app.services.user.user_repo.delete_non_admins", AsyncMock(return_value=2)),
315
+ patch("app.services.user.forget_user_memory", _forget),
316
+ ):
317
+ deleted = await UserService(MagicMock()).delete_non_admins()
318
+
319
+ assert deleted == 2
320
+ assert forgotten == ids
321
+
@@ -13,15 +13,25 @@ import pytest
13
13
 
14
14
 
15
15
  def _db_available() -> bool:
16
- """Return True if the database backend is reachable via alembic current."""
17
- result = subprocess.run(
18
- [sys.executable, "-m", "alembic", "current"],
19
- capture_output=True,
20
- text=True,
21
- cwd=".",
22
- timeout=10,
23
- )
24
- return result.returncode == 0
16
+ """Return True if the database answers a connection.
17
+
18
+ Checked directly rather than through `alembic current`: that also fails on
19
+ a broken migration chain, which would then skip these tests as "no
20
+ database" instead of failing them.
21
+ """
22
+ from sqlalchemy import create_engine
23
+ from sqlalchemy.exc import OperationalError
24
+
25
+ from app.core.config import settings
26
+
27
+ engine = create_engine(settings.DATABASE_URL_SYNC, connect_args={"connect_timeout": 5})
28
+ try:
29
+ with engine.connect():
30
+ return True
31
+ except OperationalError:
32
+ return False
33
+ finally:
34
+ engine.dispose()
25
35
 
26
36
 
27
37
  pytestmark = pytest.mark.skipif(
@@ -36,7 +36,11 @@ def _prompts(messages: list[ModelMessage]) -> list[str]:
36
36
  for message in messages
37
37
  if isinstance(message, ModelRequest)
38
38
  for part in message.parts
39
- if isinstance(part, UserPromptPart) and isinstance(part.content, str)
39
+ if isinstance(part, UserPromptPart)
40
+ and isinstance(part.content, str)
41
+ # The harness adds its memory trust marker as a user-role message
42
+ # for providers that cannot insert a system message mid-history.
43
+ and not part.content.startswith("<system>The accompanying <memory>")
40
44
  ]
41
45
 
42
46
 
@@ -86,6 +90,8 @@ async def _turn(
86
90
  AsyncMock(return_value=(conversation_id, False, None)),
87
91
  ),
88
92
  patch("app.services.agent_session.persist_assistant_turn", AsyncMock()),
93
+ # A conversation with nothing stored yet: the session carries what follows.
94
+ patch("app.services.agent_session.load_conversation_history", AsyncMock(return_value=[])),
89
95
  {%- endif %}
90
96
  {%- if cookiecutter.enable_teams and cookiecutter.enable_rag %}
91
97
  patch("app.services.agent_session.resolve_kb_collections", AsyncMock(return_value=[])),
@@ -123,7 +123,7 @@ services:
123
123
  {%- if cookiecutter.use_milvus %}
124
124
 
125
125
  etcd:
126
- image: quay.io/coreos/etcd:v3.7.2
126
+ image: quay.io/coreos/etcd:v3.7.4
127
127
  container_name: {{ cookiecutter.project_slug }}_etcd
128
128
  command: >
129
129
  etcd --advertise-client-urls http://etcd:2379
@@ -162,7 +162,7 @@ services:
162
162
  restart: unless-stopped
163
163
 
164
164
  milvus:
165
- image: milvusdb/milvus:v2.6.25
165
+ image: milvusdb/milvus:v2.6.27
166
166
  container_name: {{ cookiecutter.project_slug }}_milvus
167
167
  command: ["milvus", "run", "standalone"]
168
168
  ports:
@@ -196,7 +196,7 @@ services:
196
196
  {%- if cookiecutter.use_qdrant %}
197
197
 
198
198
  qdrant:
199
- image: qdrant/qdrant:v1.19.2
199
+ image: qdrant/qdrant:v1.20.2
200
200
  container_name: {{ cookiecutter.project_slug }}_qdrant
201
201
  ports:
202
202
  - "6333:6333"
@@ -47,7 +47,7 @@
47
47
  services:
48
48
  {%- if cookiecutter.include_traefik_service %}
49
49
  traefik:
50
- image: traefik:v3.7
50
+ image: traefik:v3.8
51
51
  container_name: {{ cookiecutter.project_slug }}_traefik
52
52
  command:
53
53
  - "--api.dashboard=true"
@@ -273,7 +273,7 @@ services:
273
273
  {%- if cookiecutter.use_milvus %}
274
274
 
275
275
  etcd:
276
- image: quay.io/coreos/etcd:v3.7.2
276
+ image: quay.io/coreos/etcd:v3.7.4
277
277
  container_name: {{ cookiecutter.project_slug }}_etcd
278
278
  volumes:
279
279
  - etcd_data:/var/lib/etcd
@@ -316,7 +316,7 @@ services:
316
316
  memory: 256M
317
317
 
318
318
  milvus:
319
- image: milvusdb/milvus:v2.6.25
319
+ image: milvusdb/milvus:v2.6.27
320
320
  container_name: {{ cookiecutter.project_slug }}_milvus
321
321
  command: ["milvus", "run", "standalone"]
322
322
  # NO external ports - only accessible within backend-internal network
@@ -351,7 +351,7 @@ services:
351
351
  {%- if cookiecutter.use_qdrant %}
352
352
 
353
353
  qdrant:
354
- image: qdrant/qdrant:v1.19.2
354
+ image: qdrant/qdrant:v1.20.2
355
355
  container_name: {{ cookiecutter.project_slug }}_qdrant
356
356
  # NO external ports in production - only accessible within backend-internal network
357
357
  volumes:
@@ -125,7 +125,7 @@ services:
125
125
  {%- if cookiecutter.use_milvus %}
126
126
 
127
127
  etcd:
128
- image: quay.io/coreos/etcd:v3.7.2
128
+ image: quay.io/coreos/etcd:v3.7.4
129
129
  container_name: {{ cookiecutter.project_slug }}_etcd
130
130
  command: >
131
131
  etcd --advertise-client-urls http://etcd:2379
@@ -164,7 +164,7 @@ services:
164
164
  restart: unless-stopped
165
165
 
166
166
  milvus:
167
- image: milvusdb/milvus:v2.6.25
167
+ image: milvusdb/milvus:v2.6.27
168
168
  container_name: {{ cookiecutter.project_slug }}_milvus
169
169
  command: ["milvus", "run", "standalone"]
170
170
  ports:
@@ -198,7 +198,7 @@ services:
198
198
  {%- if cookiecutter.use_qdrant %}
199
199
 
200
200
  qdrant:
201
- image: qdrant/qdrant:v1.19.2
201
+ image: qdrant/qdrant:v1.20.2
202
202
  container_name: {{ cookiecutter.project_slug }}_qdrant
203
203
  ports:
204
204
  - "6333:6333"