Code Examples

Working demos and integration patterns for AGEI

Public Demos - No Login Required

All examples use a service account for governance tracking

Policy & Gate Sandbox

Test how AGEI turns policies into enforcement decisions and evidence receipts

Interactive

Interactive sandbox where you can see the full AGEI workflow in action. Test sample AI requests and watch how policies become enforcement gates that produce cryptographic evidence.

Try Sample Scenarios:

  • Low-risk approve - "Summarize what AGEI does" → approve, LOW_RISK_INFORMATIONAL_USE
  • Medical escalation - "I have chest pain..." → escalate, MEDICAL_SAFETY_ESCALATION
  • Refund authority denial - "Give 85% refund..." → deny, INSUFFICIENT_AUTHORITY_SCOPE
  • Custom test - Enter your own input to see the gate evaluation

See the Full Workflow:

AI Request → AI Implementation → Policy → Gate → Evaluation → Outcome → Evidence Receipt

Governed Gemini Demo

Live interactive AGEI demonstration

Live Demo

Interactive web demo showing AGEI governance for Google Gemini text chat and image generation. Each interaction creates a receipt in the vault, and generated images can be watermarked with QR code verification.

Complete Evidence Flow:

  • • Text chat with Gemini → Gate evaluation → Receipt creation
  • • Image generation → Hash computation → AGEI receipt
  • • Watermark application → QR code embedding → Provenance records
  • • Public verification page → Artifact authenticity proof
  • • Server-side API key protection (never exposed to browser)
  • • Real CIAF-LCM evidence path: receipts → vault → audit packs

Agentic AGEI Demo

Governance-first AI agents with real policy enforcement

New

Real agentic interaction demonstrating AGEI governance BEFORE and AFTER every agent action. Watch how policies approve, deny, or escalate agent requests in real-time. Each step creates immutable receipts.

Agentic Governance Flow:

  • • Sales Agent: Authority limits, CRM access control, discount policies
  • • Medical Agent: Diagnostic escalation, clinician review requirements
  • • Session tracking → agent_sessions table
  • • Tool invocations → agent_tool_invocations with gate checks
  • • Input → Gate → Output receipt chain
  • • Real-time governance decisions (Approve/Deny/Escalate/Inspect)

Running Examples

1. Configure Environment

export CIAF_BASE_URL="http://localhost:3001"
export TEST_ORG_ID="your-org-id"
export AGENT_PRINCIPAL_ID="your-agent-id"
export SUPABASE_SERVICE_ROLE_KEY="your-service-role-key"

2. Run Example

cd examples
python agei_end_to_end_demo.py

Python SDK Examples

agei_end_to_end_demo.py

Complete governance workflow demonstration

Recommended

Demonstrates complete AGEI workflow from agent session to HITL review to anomaly detection. Shows all major features in one 5-minute demo.

What it shows:

  • • Starting an agent session
  • • Registering agent tools with risk classification
  • • Tool evaluation with automatic HITL escalation
  • • Creating behavior baselines
  • • Detecting anomalies and automated responses
  • • Complete cryptographic evidence trail

agent_behavior_monitoring_demo.py

Agent anomaly detection system

Demonstrates behavioral baseline creation and 6 types of anomaly detection with automated security responses.

Simulated Scenarios:

  • • Unusual tool usage (tool not in baseline)
  • • Request volume spike (8.5σ deviation)
  • • Off-hours access (Sunday 2:30 AM)
  • • Failed authentication attempts
  • • Privilege escalation attempt
  • • Automated responses (session terminated, API key suspended)

policy_gate_demo.py

Policy gate evaluation patterns

Shows four-outcome gate model with specific reason codes and server-side policy evaluation.

Outcomes Demonstrated:

  • Approve - Evidence satisfies policy (accuracy ≥ threshold)
  • Deny - Clear policy violation (bias exceeds limit)
  • Escalate - Critical risk requires human review
  • Inspect - Missing required evidence fields

hitl_demo.py

Human-in-the-loop review workflow

Complete HITL workflow from escalation creation to reviewer notification to decision recording.

Workflow Steps:

  • • Create HITL request with evidence package
  • • Generate SHA-256 approval token
  • • Send SendGrid notification to reviewer
  • • Display approval link and expiration time
  • • Show SLA-based timeout (15min - 4hr)
  • • Demonstrate decision types (approve/deny/modify)

agent_tools_demo.py

Agent tool registration and evaluation

Shows how to register agent tools with risk classifications and evaluate tool requests with automatic HITL escalation for critical tools.

Tool Risk Classes:

  • Low - Read-only operations (lookup_customer)
  • Moderate - Standard actions (create_ticket)
  • High - Sensitive operations (send_customer_message)
  • Critical - Requires human review (delete_customer_data)

receipt_verification_demo.py

Cryptographic evidence verification

Demonstrates how to verify cryptographic receipts, check hash chains, and validate evidence integrity.

Verification Steps:

  • • Retrieve receipt from database
  • • Verify SHA-256 content hash
  • • Check optional digital signature
  • • Validate hash chain to parent evidence
  • • Verify Merkle proof (if applicable)

audit_pack_export_demo.py

Compliance evidence export

Shows how to create audit packs for regulatory compliance, including all receipts, evaluations, and decisions for a specific model or workflow.

Export Includes:

  • • All receipts for specific model/agent
  • • Policy evaluations with outcomes
  • • HITL requests and decisions
  • • Anomaly alerts and responses
  • • Cryptographic sealing for immutability

SQL Examples

demo_lifecycle.sql

Complete AI lifecycle demonstration

Creates sample organization, policies, gates, and complete evidence trail from dataset ingestion through model deployment to inference.

-- Run in Supabase SQL Editor
\i supabase/demo_lifecycle.sql