ulysses/routes
Wei Hong 7475779b7c
fix(chat): track chat hot-path background tasks for strong references (#4443) (#4444)
Two background tasks scheduled on every chat completion in
routes/chat_helpers.py — the memory/skill extraction dispatch and the
session auto-namer — are created via bare asyncio.create_task(...).
asyncio only holds a weak reference to the outer task, so the GC can
collect it mid-execution and the work silently never runs.

Add a module-private _BG_TASKS set and a _spawn_bg() helper that mirrors
WebhookManager._spawn_tracked (the pattern #3964 / #4336 established for
the webhook emitters two lines apart in the same function). Route both
call sites through it so the lifecycle owner is explicit.

Adds an AST-level guard test that fails on any bare
asyncio.create_task(...) statement in routes/chat_helpers.py to prevent
a regression — same shape as test_webhook_emitters_use_manager.py from
#4336.

The same bare pattern exists in routes/email_routes.py and
routes/cookbook_routes.py; left out of this PR per CONTRIBUTING.md's
"one fix per PR" and tracked in #4443's "Additional Information" for a
follow-up.
2026-06-18 21:26:11 +02:00
..
__init__.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
_validators.py fix(hwfit): validate remote SSH detection targets (#3718) 2026-06-11 00:43:49 +02:00
admin_wipe_routes.py refactor(constants): single source of truth for data dir (#3368) 2026-06-08 09:58:52 +02:00
api_token_routes.py fix(api): normalize non-object JSON bodies to empty dict in token PATCH (#3976) 2026-06-15 18:05:15 +01:00
assistant_routes.py fix(auth): centralize password and username validation constants (#4120) 2026-06-16 09:52:15 +02:00
auth_routes.py fix(auth): tie remember-me cookie lifetime to TOKEN_TTL (#4472) 2026-06-18 21:15:48 +02:00
backup_routes.py fix: backup import dropping a user's skill on cross-tenant title/id collision (#2057) 2026-06-09 08:04:22 +02:00
calendar_routes.py Harden CalDAV write-back with retries (#1193) 2026-06-15 15:59:31 +09:00
chat_helpers.py fix(chat): track chat hot-path background tasks for strong references (#4443) (#4444) 2026-06-18 21:26:11 +02:00
chat_routes.py fix(api): attribute bearer-token actions to the token owner on owner-scoped routes (#4054) 2026-06-15 23:56:22 +02:00
chatgpt_subscription_routes.py feat: add ChatGPT Subscription provider (#2876) 2026-06-08 10:19:18 +02:00
cleanup_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
codex_routes.py fix(email): enforce MCP owner boundaries (#4335) 2026-06-16 04:31:24 +01:00
compare_routes.py fix(endpoint): scope secondary endpoint lookups by owner 2026-06-08 11:51:55 +01:00
contacts_routes.py Fix failing post-merge tests 2026-06-15 22:49:06 +09:00
cookbook_helpers.py fix(cookbook): avoid launching Ollama during Windows cache scan (#4368) 2026-06-16 01:00:40 +02:00
cookbook_output.py fix(cookbook): report dead finished downloads as completed instead of stopped (#4025) 2026-06-15 15:26:55 +09:00
cookbook_routes.py fix(cookbook): harden remote serve host handling (#4345) 2026-06-16 03:46:32 +01:00
copilot_routes.py feat: add ChatGPT Subscription provider (#2876) 2026-06-08 10:19:18 +02:00
device_flow.py feat: add ChatGPT Subscription provider (#2876) 2026-06-08 10:19:18 +02:00
diagnostics_routes.py feat(ui): add real-time diagnostic logs console (#974) 2026-06-15 10:32:51 +02:00
document_helpers.py fix(auth): clean up rename and null-owner ownership (#4340) 2026-06-16 03:33:02 +01:00
document_routes.py fix(document): allow render-pdf to be framed and 503 cleanly on missing PyMuPDF (#2103) 2026-06-18 06:25:26 +00:00
editor_draft_routes.py Ignore invalid editor draft payloads (#1533) 2026-06-03 14:07:03 +09:00
email_helpers.py feat(email): add Google OAuth2 for Google Workspace / .edu IMAP & SMTP (#237) 2026-06-15 17:02:58 +01:00
email_pollers.py fix: quote IMAP mailbox arguments (#2170) 2026-06-05 16:00:20 +02:00
email_routes.py fix(email): enforce MCP owner boundaries (#4335) 2026-06-16 04:31:24 +01:00
embedding_routes.py feat(paths): abstract runtime path logic for frozen distribution packages (#969) 2026-06-15 17:44:10 +01:00
emoji_routes.py refactor(constants): single source of truth for data dir (#3368) 2026-06-08 09:58:52 +02:00
font_routes.py Keep compact font family names together (#1263) 2026-06-03 14:24:30 +09:00
gallery_helpers.py fix(gallery): fail closed for null-user owner scope (#3613) 2026-06-09 20:20:21 +02:00
gallery_routes.py fix(gallery): confine gallery image path resolution (#4352) 2026-06-16 03:28:09 +01:00
history_routes.py fix(sessions): copy message metadata when forking a session (#3409) 2026-06-08 20:49:15 +02:00
hwfit_routes.py Merge remote-tracking branch 'origin/dev' into test-main-dev-merge-20260615 2026-06-15 21:20:15 +09:00
mcp_routes.py fix(mcp): share oauth redirect URI (#4087) 2026-06-15 15:15:53 +09:00
memory_routes.py fix(routes): normalize session owner fallback helpers (#4313) 2026-06-16 06:07:42 +01:00
model_routes.py fix(endpoints): normalize URL handling (#4338) 2026-06-16 03:59:18 +01:00
note_routes.py refactor(auth): centralize the internal-tool pseudo-username into a constant (#4333) 2026-06-16 13:13:00 +02:00
personal_routes.py fix(auth): clean up rename and null-owner ownership (#4340) 2026-06-16 03:33:02 +01:00
prefs_routes.py refactor(constants): single source of truth for data dir (#3368) 2026-06-08 09:58:52 +02:00
preset_routes.py fix(presets): scope expand-prompt model resolution to owner (#3477) 2026-06-08 21:12:02 +02:00
research_routes.py refactor(auth): centralize the internal-tool pseudo-username into a constant (#4333) 2026-06-16 13:13:00 +02:00
search_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
session_routes.py fix(auth): clean up rename and null-owner ownership (#4340) 2026-06-16 03:33:02 +01:00
shell_routes.py refactor(auth): centralize the internal-tool pseudo-username into a constant (#4333) 2026-06-16 13:13:00 +02:00
signature_routes.py Constrain signature uploads to PNG data (#2844) 2026-06-05 13:17:43 +02:00
skills_routes.py Skills test: set explicit max_tokens=4096 instead of 0 2026-06-13 23:09:15 +09:00
stt_routes.py refactor(uploads): centralize upload byte-limits in upload_limits.py (#3364) (#3518) 2026-06-09 01:24:30 +02:00
task_routes.py refactor(auth): centralize the internal-tool pseudo-username into a constant (#4333) 2026-06-16 13:13:00 +02:00
tts_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
upload_routes.py fix(api): attribute bearer-token actions to the token owner on owner-scoped routes (#4054) 2026-06-15 23:56:22 +02:00
vault_routes.py refactor(constants): single source of truth for data dir (#3368) 2026-06-08 09:58:52 +02:00
webhook_routes.py fix(webhooks): route public emitters through fire_and_forget (#3964) (#4336) 2026-06-16 00:41:45 +02:00
workspace_routes.py feat(agent): confine agent file/shell tools to a selectable workspace (#3665) 2026-06-11 18:17:54 +02:00