PikarcBlockedError
When Pikarc denies a run start, model call, or tool call, the SDK raisesPikarcBlockedError. This happens before your function executes — no tokens are consumed, no tools are invoked.
Attributes
| Attribute | Type | Description |
|---|---|---|
reason | str | Human-readable reason for the denial |
deny_reason | str | Machine-readable deny reason code (see table below) |
Deny Reason Codes
| Code | Description | When Checked |
|---|---|---|
KILL_SWITCH_ACTIVE | The workspace kill switch is enabled. All runs and steps are blocked. | Run start, Step |
USER_BLOCKED | This SDK user has been individually blocked. | Run start, Step |
WORKSPACE_DAILY_BUDGET_EXCEEDED | Total workspace spend today exceeds the configured daily budget. | Run start, Step |
USER_DAILY_BUDGET_EXCEEDED | This user’s spend today exceeds the configured per-user daily budget. | Run start, Step |
MONTHLY_RUN_LIMIT_EXCEEDED | The workspace has reached its monthly run limit (based on plan tier). | Run start |
MAX_CONCURRENT_RUNS_EXCEEDED | Too many runs are active simultaneously. | Run start |
RUN_ALREADY_ENDED | The run has already been ended (COMPLETED or FAILED). | Step |
Where Denials Can Happen
At run start
Whenguard.run() is entered, Pikarc evaluates all 6 rules. If denied, the async with block is never entered:
At step creation
Whenrun.model_call() or run.tool_call() is called, rules 1-4 are re-evaluated. If denied, fn is never called:
HTTP Errors
The SDK useshttpx under the hood. Network errors or non-2xx responses from the Pikarc API will raise httpx.HTTPStatusError:
Best Practices
- Always catch
PikarcBlockedError— it’s expected behavior, not a bug. Return a user-friendly message. - Always call
guard.close()— use afinallyblock or async context manager to clean up the HTTP client. - Catch at the right level — catch around
guard.run()for run-start denials, or around individualmodel_call()/tool_call()for step-level denials. - Log the deny reason —
e.deny_reasontells you exactly which guardrail triggered. Use it for monitoring and alerting.