File size: 909 Bytes
1ffd0a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
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))