Skip to main content
All SDK errors extend MiddlewareError, which extends Error. Each error class has a unique code string and structured fields for programmatic handling.

Error Hierarchy

Catching Errors

Error Reference

ProhibitedPracticeError

Thrown when input matches an EU AI Act Article 5 prohibited practice (138 patterns, 8 categories, 6 languages).

PIIDetectedError

Thrown in block sanitize mode when PII is detected in input.

BiasDetectedError

Thrown in block bias mode when aggregate bias score exceeds threshold. BiasEvidence:

SafetyViolationError

Thrown when response safety score exceeds threshold. SafetyFinding:

DisclosureMissingError

Thrown in block disclosure mode when AI disclosure is not found in the response.

HumanGateDeniedError

Thrown when HITL gate denies an action (human denial or timeout).

DomainViolationError

Thrown by domain-specific hooks (HR, finance, healthcare, etc.).

PermissionDeniedError

Thrown in agent mode when a method is on the passport’s denied list.

BudgetExceededError

Thrown in agent mode when accumulated cost exceeds the session budget.

RateLimitError

Thrown in agent mode when actions exceed the per-minute rate limit.

CircuitBreakerError

Thrown in agent mode when the circuit breaker is open (too many consecutive errors).

Configuration

Set modes and thresholds for each hook.

Agent Mode

Permission, budget, rate limit, circuit breaker.