File size: 772 Bytes
fd0c71a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """Explanation agent."""
from __future__ import annotations
from app.common.types import PolyGuardAction, PolyGuardState
class ExplainerAgent:
name = "ExplainerAgent"
def run(self, state: PolyGuardState, action: PolyGuardAction, critic_report: dict) -> dict:
return {
"explanation": (
f"Action {action.action_type.value} selected for mode {action.mode.value}. "
f"Burden score={state.burden_score:.3f}, meds={len(state.patient.medications)}. "
f"Critic legal={critic_report.get('legal', False)}."
),
"grounded_facts": {
"burden_score": state.burden_score,
"polypharmacy_count": len(state.patient.medications),
},
}
|