HAK-16's picture
Initial deploy
1ffd0a4 verified
Raw History Blame Contribute Delete
909 Bytes
"""
Agent trace schemas — Phase 13.
AgentTrace is the complete pipeline reasoning record for a single crisis event.
Persisted to Firestore agent_logs and served via GET /api/crisis/{id}/trace,
which powers the in-app reasoning timeline on AgentTraceScreen.
"""
from __future__ import annotations
from datetime import datetime, timezone
from typing import Literal
from pydantic import BaseModel, Field
class AgentTraceStep(BaseModel):
step_number: int
agent_name: str
action: str
reasoning: str
confidence: float | None
output_summary: str
timestamp: datetime
FinalOutcome = Literal["responded", "denied", "inconclusive", "low_risk_auto"]
class AgentTrace(BaseModel):
crisis_id: str
steps: list[AgentTraceStep]
total_duration_seconds: float
final_outcome: FinalOutcome
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))