Fix agent invocation missing thread_id in scheduler and cron trigger

The checkpointer requires a thread_id in configurable. Use stable IDs
derived from the message/job ID so each has its own checkpoint thread.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 08:26:20 -04:00
parent 504753eef9
commit 171410cf26
2 changed files with 6 additions and 4 deletions
+2 -1
View File
@@ -138,7 +138,8 @@ async def trigger_job(job_id: str):
try:
response = await current_app.main_agent.ainvoke(
{"messages": [{"role": "user", "content": job.prompt}]}
{"messages": [{"role": "user", "content": job.prompt}]},
config={"configurable": {"thread_id": f"cron-{job.id}"}},
)
result = response.get("messages", [])[-1].content
+4 -3
View File
@@ -14,9 +14,10 @@ RECURRENCE_DELTAS = {
}
async def _run_agent(prompt: str) -> str:
async def _run_agent(prompt: str, thread_id: str) -> str:
response = await current_app.main_agent.ainvoke(
{"messages": [{"role": "user", "content": prompt}]}
{"messages": [{"role": "user", "content": prompt}]},
config={"configurable": {"thread_id": thread_id}},
)
return response.get("messages", [])[-1].content
@@ -60,7 +61,7 @@ async def process_due_messages() -> dict:
send_content = msg.content
if msg.use_agent:
send_content = await _run_agent(msg.content)
send_content = await _run_agent(msg.content, f"scheduled-{msg.id}")
if msg.channel == MessageChannel.IMESSAGE:
from blueprints.imessage import send_imessage