Examples

Example: Minimal

Minimal embedded gateway + @harness example.

Example: Minimal

Overview

Smallest working example using auto_instrument() with OpenAI and LangGraph. Zero decorator — governance applied via runtime patching.

Why It Matters

Proves auto-instrumentation works with minimal code before integrating into a larger app.

Prerequisites

pip install "agentrust-sdk[embedded]" openai langgraph

Step-by-Step Guide

cd examples/
python minimal.py

Key code pattern:

from agentrust_sdk import auto_instrument, embed_gateway
embed_gateway()
auto_instrument()
# existing OpenAI/LangGraph code runs unchanged

Examples

Source: examples/minimal.py

Best Practices

  • Run with embedded gateway first (no API key needed)
  • Verify with agentrust audit tail

Common Mistakes

  • Importing openai before auto_instrument()

Troubleshooting

See Auto-Instrumentation.