Skip to content

Error Handling

Raised when the pipeline blocks a request:

from tappass import Agent, PolicyBlockError
agent = Agent("http://localhost:9620", "tp_...")
try:
response = agent.chat("Show me all credit card numbers")
except PolicyBlockError as e:
print(e.blocked_by) # "detect_pii"
print(e.classification) # "RESTRICTED"
print(e.reason) # "PII detected in request"
print(e.step_details) # full step output
FieldTypeDescription
blocked_bystrPipeline step that blocked
classificationstrData classification at time of block
reasonstrHuman-readable reason
step_detailsdictFull step output (detections, scores)

The SDK retries on transient errors (network timeouts, 502/503/504):

agent = Agent(
"http://localhost:9620",
"tp_...",
timeout=30, # per-request timeout
max_retries=2, # retry count (default: 2)
)

PolicyBlockError is never retried: it’s a deliberate policy decision, not a transient failure.

from tappass.errors import TapPassConnectionError
try:
response = agent.chat("Hello")
except TapPassConnectionError:
print("TapPass server is unreachable")