errors defines the canonical harness exception taxonomy and denial reason codes used by runtime control flow, CLI rendering, and audit classification.
ErrorCategory classifies failures into transient, model_logic, permission, and system classes for consistent reporting and run-failure labeling.
AgentHarnessError(base): message + optional remediationhint;__str__appends hint when present.BudgetExceededError(MODEL_LOGIC): iteration/tool-call/cost envelope exhausted.ToolValidationError(MODEL_LOGIC): malformed model decision payload.ToolPermissionError(PERMISSION): policy/approval/plan-gate denial with optionalreason_code.ToolExecutionError(SYSTEM): local tool runtime failure.RunCancelledError(SYSTEM): cancellation token triggered.
- Harness-raised domain errors should inherit
AgentHarnessError. - Subclasses must set stable
categoryvalues for downstream categorization. - Remediation guidance should be carried in
hintinstead of implicit message-only wording. - Permission denials should attach
DenialReasonCodewhen a specific gate is known. - String formatting is deterministic: message first, hint second line when present.
AgentHarnessError.__str__never drops the primary message.- Exception construction performs no I/O or state mutation.
DenialReasonCodevalues remain lowercase stable tokens for audit/search indexing.