Fix: migrate all remaining main_agent imports to current_app

email, scheduled_messages scheduler, and cron blueprints still imported
main_agent directly from agents. All now use current_app.main_agent so
they read the initialized value set by build_agent() in the lifespan.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-16 22:59:13 -04:00
parent 810d32dcc3
commit 2a81ea8f76
3 changed files with 10 additions and 20 deletions
+4 -9
View File
@@ -3,7 +3,7 @@ import logging
import os
from datetime import datetime, timezone
from quart import Blueprint, jsonify, request
from quart import Blueprint, current_app, jsonify, request
from blueprints.users.decorators import admin_required
from blueprints.scheduled_messages.models import MessageChannel
@@ -137,14 +137,9 @@ async def trigger_job(job_id: str):
return jsonify({"skipped": True}), 200
try:
from blueprints.conversation.agents import main_agent
from blueprints.conversation.prompts import SIMBA_SYSTEM_PROMPT
messages_payload = [
{"role": "system", "content": SIMBA_SYSTEM_PROMPT},
{"role": "user", "content": job.prompt},
]
response = await main_agent.ainvoke({"messages": messages_payload})
response = await current_app.main_agent.ainvoke(
{"messages": [{"role": "user", "content": job.prompt}]}
)
result = response.get("messages", [])[-1].content
if job.channel == MessageChannel.IMESSAGE: