HAK-16's picture
Initial deploy
1ffd0a4 verified
Raw History Blame Contribute Delete
750 Bytes
"""
GET /api/crisis/{crisis_id}/trace — agent trace endpoint.
Returns the full AgentTrace for a given crisis_id. Polled by the mobile app
to render the live reasoning timeline on AgentTraceScreen.
"""
from fastapi import APIRouter, HTTPException
from backend.services.trace import get_trace
router = APIRouter(prefix="/api/crisis", tags=["Crisis"])
@router.get("/{crisis_id}/trace")
async def get_crisis_trace(crisis_id: str) -> dict:
"""Return the agent reasoning trace for a completed pipeline run."""
trace = await get_trace(crisis_id)
if trace is None:
raise HTTPException(
status_code=404,
detail=f"No trace found for crisis {crisis_id!r}.",
)
return trace.model_dump(mode="json")