Embedded Gateway

Embedded Gateway Overview

In-process SQLite gateway on :8765 for local development and CI.

Embedded Gateway Overview

Overview

The embedded gateway runs a lightweight FastAPI governance server inside your Python process, backed by SQLite. It exposes the same POST /v1/runtime/validate endpoint as the full edge gateway but with reduced capabilities.

Why It Matters

Embedded mode eliminates infrastructure dependencies for development, CI, demos, and air-gapped environments while providing real HTTP validation and local audit storage.

Prerequisites

pip install "agentrust-sdk[embedded]"

Step-by-Step Guide

1. Start programmatically

from agentrust_sdk import embed_gateway, EmbeddedGateway

# Simple
gw = embed_gateway()  # http://localhost:8765

# Explicit
with EmbeddedGateway(port=8765, db_path="~/.agentrust/embedded.db") as gw:
    print(gw.url)

2. SDK auto-configuration

embed_gateway() sets AGENTRUST_GATEWAY_URL to the embedded URL. All SDK paths (@harness, client, auto-instrument) route to it automatically.

3. Configuration

VariableDefault
AGENTRUST_EMBED_PORT8765
AGENTRUST_EMBED_DB~/.agentrust/embedded.db
AGENTRUST_EMBED_TOKENAuto-generated UUID

4. Audit inspection

agentrust audit tail
agentrust export ./embedded-audit.jsonl

Embedded capabilities

FeatureEmbeddedFull Edge
HTTP validate endpoint
Schema validation
Basic policy
Full risk engine❌ (always LOW)
Review queue
LLM judge
Trust chain
Webhooks
Multi-tenant

Examples

See Embedded Quickstart and Examples: Embedded Only.

Best Practices

  • Use embedded for dev/CI only
  • Call embed_gateway() once at process startup (before agent calls)
  • Purge test data: agentrust purge --confirm
  • Promote to full edge for production risk calibration

Common Mistakes

  • Running multiple embedded gateways on same port
  • Using embedded risk scores for production policy tuning
  • Expecting Team/Enterprise features in embedded mode

Troubleshooting

IssueFix
Port in useAGENTRUST_EMBED_PORT=8766
Missing uvicornInstall [embedded] extra
Auth errorsUse auto-generated token or set AGENTRUST_EMBED_TOKEN