Restore active sessions on startup

This commit is contained in:
2026-05-12 08:04:59 -05:00
parent a09197e85a
commit bce93b39e0
3 changed files with 64 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ async def startup_event():
orchestrator = AgentOrchestrator(
loop_interval_seconds=settings.AGENT_LOOP_INTERVAL_SECONDS
)
await orchestrator.restore_active_sessions()
agent_loop_task = asyncio.create_task(agent_loop())
logger.info("Application started successfully")
except Exception as e:
@@ -143,6 +144,22 @@ async def get_ledger(session_id: str) -> dict:
}
@app.get("/admin/session/status")
async def get_session_status(session_id: str) -> dict:
"""Get status for an active stream session."""
if not orchestrator:
raise HTTPException(status_code=503, detail="Orchestrator not initialized")
status = await orchestrator.get_session_status(session_id)
if not status:
raise HTTPException(status_code=404, detail="Active session not found")
return {
**status,
"timestamp": datetime.utcnow().isoformat(),
}
@app.get("/admin/loop/status")
async def get_loop_status() -> dict:
"""Get the background agent loop runtime configuration."""