HowDocumentation Index
Fetch the complete documentation index at: https://docs.agentguardian.io/llms.txt
Use this file to discover all available pages before exploring further.
agent-guardian signals failure. CLI exit codes drive CI gates;
the LLMError hierarchy lets SDK callers branch on transport / auth /
quota faults without parsing strings.
When to use this
- You’re writing a CI job and need to know which exit codes a
scanstep can return. - You’re wrapping the SDK and need a clean
try / excepttaxonomy for provider failures. - You’re debugging a scan that exited non-zero and want to know what the number means.
CLI exit codes
Defined insrc/agent_guardian/cli.py. Every top-level command exits
with one of these.
| Code | Constant | Raised by | Meaning |
|---|---|---|---|
0 | EXIT_OK | Any command on success | Success. |
1 | EXIT_FAIL_UNDER | scan (with --fail-under N), verify, publish, last-score --score-only | Final AIVSS < N, signature verification failed, or last-score had no scans on record. |
2 | EXIT_CONFIG | All commands | Configuration error: bad flag, missing file, unknown format, unsafe serve bind, contract migration failure, invalid scan_id. |
3 | EXIT_TARGET_UNREACHABLE | scan (HTTP endpoint mode) | Endpoint preflight could not reach the target after 3 attempts (5s, 10s, 15s — cold-start tolerant). |
4 | EXIT_LLM_PROVIDER | scan | LLM provider misconfigured (missing key, unknown provider) or model not found during pre-scan validation. |
5 | EXIT_SANDBOX | scan | Sandbox violation — an agent attempted a blocked filesystem / network operation. |
130 | EXIT_USER_INTERRUPT | scan | Operator hit Ctrl-C (POSIX convention: 128 + SIGINT(2)). |
How CI gates branch on this
Sample exit-code triggers
A few concrete shapes:LLM provider exception taxonomy
Defined insrc/agent_guardian/llm/errors.py. Every provider client
maps HTTP / SDK errors into one of these so the rest of the framework
can decide whether to retry, surface to the operator, or abort the scan
without caring about the underlying transport.
agent_guardian (the top-level package).
| Exception | When | Retry? | Typical cause |
|---|---|---|---|
LLMError | Base class | — | Catch this if you don’t care about the sub-class. |
LLMRateLimitError | 429, quota exhausted | Yes (honour retry_after) | You’re hitting your tier’s TPM / RPM cap. The exception carries an optional retry_after (seconds) lifted from the provider’s Retry-After header. |
LLMAuthError | 401, 403 | No | Missing / wrong / revoked API key. Check AGENT_GUARDIAN_<PROVIDER>_API_KEY or the conventional fallback (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY / GOOGLE_API_KEY). |
LLMTimeoutError | Transport timeout | Yes | The request didn’t complete in the client’s deadline. Often a cold start; sometimes a provider blip. |
LLMTransientError | 5xx, network blip | Yes | Provider-side fault. Backoff and retry. |
LLMPermanentError | Non-retryable 4xx | No | Bad model name, malformed payload, content-policy refusal that won’t change on retry. |
LLMResponseFormatError | 200 OK, malformed body | Maybe (could be a schema drift) | Provider returned success but the body was missing required fields. Usually a provider schema change. |
Catching them in your code
agent_guardian.llm.retry helpers honour this taxonomy:
they retry the transient classes (LLMRateLimitError,
LLMTimeoutError, LLMTransientError), respect retry_after, and
fail fast on the rest.
Mapping back to a CLI exit code
When the CLI hits a provider error during a scan, it surfaces it asEXIT_LLM_PROVIDER (4) after pre-scan validation, or lets the swarm’s
internal retry policy absorb transients. The operator always sees:
How to interpret the result
0/1are the only exit codes a healthy scan should produce. Anything else means the scan didn’t run to completion.2/3/4are operator-fixable: bad config, dead endpoint, missing key. Surface the underlying message on stderr — the CLI tells you which.5is rare and means an agent tried to escape the sandbox. File an issue with the scan transcript.130is just Ctrl-C — no action needed.- In Python code, prefer catching specific
LLMErrorsubclasses over the base — your retry policy depends on the distinction.
Next step
- Wire these exit codes into a GitHub Actions job: GitHub Actions integration.
- Use the SDK to drive your own retry policy: Python SDK.
- Tune what the CLI surfaces via Configuration and
AGENT_GUARDIAN_LOG_LEVEL=DEBUG.