Confidence-gated actions
Use the same semantic interpretation for actions with different risk profiles.
01
HOW IT WORKS
from dataclasses import dataclass
@dataclass(frozen=True)
class ActionDecision:
route: str
requires_confirmation: bool = False
def gate_action(choice: str, confidence: float) -> ActionDecision:
if confidence < 0.60:
return ActionDecision("human_review")
if choice == "check_balance":
return ActionDecision("show_balance")
if choice == "approve_transfer":
return ActionDecision("approve_transfer", requires_confirmation=confidence <= 0.90)
if choice == "support":
return ActionDecision("support")
return ActionDecision("human_review")The thresholds above are illustrative, not universal defaults. Tune them against labeled examples, expected loss, and the reversibility of the action. TypeSafe’s confidence guidance recommends lower thresholds for recoverable actions and higher thresholds for high-stakes actions.
Source: Confidence and confidence-gated routing.
임계값은 코드의 몫
이 패턴을 한 줄로