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.
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).
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.