Skip to main content

Basic usage

Calling search_web(...) will:
  • Measure duration
  • Record inputs/outputs
  • Append a ledger entry

Async functions

Exceptions

Agent Sentinel does not swallow your exceptions. If your function raises, the exception propagates normally — the SDK records the action as outcome="error" and logs the error string.

Fail-open vs fail-closed

  • Fail-open: ledger writes and remote sync should never crash your agent.
  • Fail-closed: policy violations intentionally raise before execution. Since 0.4.0, actions declared impact="medium" or "high" are also blocked when no policy is loaded (see Enforcement modes).

Decorator arguments

@guarded_action accepts the following keyword-only arguments. Anything beyond name, cost_usd, and tags is optional — sensible defaults apply.

Secret redaction

Before a ledger entry is written or uploaded, the SDK redacts tool inputs:
  • Values under sensitive-looking keys (api_key, secret, token, password, passwd, authorization, credential, private_key, and similar) become [redacted:<kind>].
  • String values that look like secrets (OpenAI, Stripe, AWS, GitHub and Slack keys, PEM private-key headers, JWTs) are redacted wherever they appear.
  • Values over 8 KB are truncated with a ...[truncated N bytes] marker.
The entry carries inputs_redacted: true when anything was replaced. Your function still receives the original arguments; only the recorded copy changes. To keep inputs out of the ledger entirely:
You can apply the same redaction yourself with agent_sentinel.redaction.redact_inputs(args, kwargs, max_bytes=8192).

Replay mode integration

If replay mode is active, decorated actions return recorded outputs instead of executing (and are logged with outcome="replayed"). See Replay.