Examples¶
Complete, runnable programs in the
examples/
directory. Every page shows real output from running the script. The offline
examples also run in the test suite, so they keep working.
Run without any service¶
| Example | Shows |
|---|---|
| Minimal graph | The smallest instrumented graph and what it captures |
| Fraud review: full explanation | Evidence, a decision, provenance, and one decision explained to two audiences |
| Retrieval and tools | Retrievers and ToolNode calls captured automatically and turned into evidence |
| Human-in-the-loop | interrupt() and Command(resume=...), linked to the checkpoint to replay |
| Multi-agent retries and correlation | A recovered tool timeout and a shared run and trace ID |
| Disclosure matrix | One decision checked against every policy, audience, and engine |
Two more scripts back the documentation: the
canonical model gallery
prints every record type for the Concepts pages, and
failure_modes.py
produces the output in Configure failure modes.
Run with a chat model¶
These need OPENAI_API_KEY. Set OPENAI_BASE_URL for an OpenAI-compatible
gateway and OPENAI_MODEL to pick the model (default gpt-4o-mini).
| Example | Shows | Also needs |
|---|---|---|
| create_agent decision | Recording and explaining a decision from agent middleware | |
| create_agent inside a node | An agent nested in a larger graph, captured as one run | |
| deepagents | A deep agent instrumented with no framework-specific code | examples group |
| MCP tools | Tool calls served by the Playwright MCP server | examples group, Node.js |
Run with a database¶
| Example | Shows | Needs |
|---|---|---|
| PostgreSQL store | A complete ProvenanceStore subclass that keeps records in PostgreSQL |
examples group, XAI_POSTGRES_DSN |
Running an example¶
From a clone of the repository:
For the model-backed examples: