Python SDKExceptions Reference

Error Handling & Exceptions

SICTACK provides an exhaustive, typed exception hierarchy. Every exception carries structured attributes for programmatic inspection without parsing error message strings.

Exception Hierarchy

All SDK exceptions inherit from SictackError (aliased to IntentLockError for compatibility):

Exception Tree
SictackError (Base, alias: IntentLockError)
├── PolicyError
├── ToolNotRegisteredError
├── PermissionDeniedError
├── ApprovalRequiredError
├── ApprovalExpiredError
├── ApprovalReplayError
├── ApprovalMismatchError
├── ArgumentValidationError
├── ReplayDetectedError
└── AuditError

Structured Context Attributes

You never need to regex parse error messages. Exceptions dynamically store contextual arguments as typed instance attributes:

Exception ClassContext AttributesTrigger Condition
PermissionDeniedError.tool_name, .policy_id, .action_hash, .reasonAction blocked by explicit "deny" rule or fail-closed default.
ApprovalRequiredError.approval_id, .action_hash, .tool_nameTool execution suspended awaiting human operator approval.
ApprovalExpiredError.approval_idApproval ticket presented after its TTL expiration.
ApprovalReplayError.approval_idAttempted reuse of an already-consumed single-use approval token.
ApprovalMismatchError.approval_id, .expected_hash, .actual_hashAction parameters altered after approval token was issued.
ToolNotRegisteredError.tool_nameAgent attempted to call a tool not registered in its registry.
ArgumentValidationError.tool_name, .errorsSupplied arguments fail schema validation.
ReplayDetectedError.action_hash, .tool_nameExact duplicate action hash detected in non-idempotent context.

Recommended Catch Pattern

Handle expected security states gracefully while alerting on replay or tampering anomalies:

robust_exception_handling.py
from sictack.exceptions import (
    IntentLockError,
    PermissionDeniedError,
    ApprovalRequiredError,
    ApprovalExpiredError,
    ApprovalReplayError,
    ApprovalMismatchError,
    ToolNotRegisteredError,
    ArgumentValidationError,
)

try:
    result = agent.execute(tool_call)
except ApprovalRequiredError as e:
    # Trigger operator approval flow
    print(f"Action suspended. Approval ID: {e.approval_id}")
    print(f"Tool: {e.tool_name}, Hash: {e.action_hash}")

except PermissionDeniedError as e:
    # Deterministic policy denial
    print(f"Action denied by policy '{e.policy_id}': {e.reason}")

except ApprovalExpiredError as e:
    # Approval token exceeded TTL
    print(f"Approval {e.approval_id} has expired. A new request must be created.")

except ApprovalReplayError as e:
    # Security violation: token reuse attempt
    print(f"SECURITY ALERT: Approval {e.approval_id} has already been consumed.")

except ApprovalMismatchError as e:
    # Security violation: parameters tampered
    print(f"SECURITY ALERT: Parameter mismatch! Expected {e.expected_hash}, got {e.actual_hash}")

except ToolNotRegisteredError as e:
    print(f"Tool '{e.tool_name}' is not registered with this agent.")

except ArgumentValidationError as e:
    print(f"Invalid tool arguments for '{e.tool_name}': {e.errors}")

except SictackError as e:
    # Catch-all for any other SICTACK runtime exceptions
    print(f"SICTACK security fault: {e.message}")