failproofai-sdk so Failproof AI can reconstruct each run, audit its behavior, and find evidence-backed failures. The SDK writes structured events for the Failproof daemon to deliver to Cloud. It requires Python 3.10 or newer.
Tracing makes custom agents observable and auditable. Preventing an unsafe action before it executes also requires an enforcement hook in your runtime.
To enforce policies in a custom agent setup, contact Failproof AI. We will help map your runtime’s model, tool, and lifecycle boundaries to policy hooks.
Install failproofai-sdk
The SDK is currently distributed as a private wheel. Ask your Failproof AI contact for the current version and download access.
uv, download the wheel first and run uv add ./failproofai_sdk-${VERSION}-py3-none-any.whl. Pin the wheel in a private artifact repository or dependency lock.
The package is installed as failproofai-sdk and imported in Python as failproofai.
Connect the Failproof daemon
- Dashboard
- CLI
-
Go to Admin → Keys and create a key with
events:add. - Connect the Failproof daemon to Cloud on the agent machine.
- Run one instrumented session, then find its exact ID under Observe → Events.
-
Go to Observe → Sessions, select the same environment, and open the reconstructed trace.

Instrument a complete run
Callconfigure() once during process startup. Every event call is keyword-only and requires a stable session_id and agent_id.
agent_start once per actor. For sub-agents, reuse the parent’s session_id, give each actor a distinct agent_id, and set parent_id to the parent agent ID, not the session ID.
Configuration reference
The SDK writes to the explicit
base_dir when set. Otherwise, it uses the Failproof daemon’s custom-agents spool under FAILPROOFAI_HOME or ~/.failproofai.
The SDK queues calls in memory and writes batches on a background thread. It also attempts a final flush through Python’s atexit handling. For short-lived workers, allow normal interpreter shutdown; hard process termination can lose events still in memory.
Event catalog
All methods returnNone. Fields left as None are omitted rather than written as JSON null.
Use
outcome="failed", "error", "timeout", or "rejected" when a completion should count as a failure. Other values, including "failure", are not classified as failures by the current backend.
Correlation and duration rules
- Reuse the same
tool_call_id,hook_id,pause_id, orinput_idfor the matching completion event. - The SDK computes
duration_msfortool_result,hook_completed,agent_resume, andhuman_input. Passing it yourself to those methods raisesValueError. - Tool and hook IDs share one process-wide pending map. Make them globally unique across concurrent sessions and across both namespaces; provider IDs or UUIDs are safest.
- A pair split across processes still correlates downstream, but the SDK cannot compute its in-process duration.
- The pending map holds at most 10,000 starts and evicts the oldest entry when full.
Custom fields and payloads
Every event accepts extra keyword fields. Use JSON-compatible values when downstream queries need structure. Unsupported leaves such as UUIDs, datetimes, decimals, sets, bytes, and model objects are stringified by the writer. Reserved custom names aretimestamp, session_id, agent_id, type, and environment. Optional-field typos are accepted as new custom fields, so review emitted JSON when a standard field does not appear in Cloud.
Deliver and verify
- Dashboard
- CLI
In Observe → Events, verify
agent_start exists first and agent_end exists last. Then open Observe → Sessions and confirm model, tool, human, hook, and error events appear in the intended order. Use the session ID as the primary troubleshooting key.$FAILPROOFAI_HOME/custom-agents/events, otherwise ~/.failproofai/custom-agents/events. JSONL files prove SDK emission; a growing spool points to daemon configuration or delivery, while an empty spool points to instrumentation or process lifetime.

