aitp-playground

Run AITP scenario demonstrations end-to-end with real LLM-powered agents

Python FastAPI service that runs Agent Identity & Trust Protocol (AITP) scenario demonstrations end-to-end with real LLM-powered agents. Each scenario spins up a handful of agents that establish cryptographic identity, complete an AITP handshake, and do real LLM work under verifiable, scoped, revocable trust — so you can watch the protocol behave (and fail closed) instead of reading about it.

cp .env.example .env                  # optional: set OPENAI_API_KEY for real LLM output
docker compose up --build             # service on :8000  →  open http://localhost:8000/dashboard

How it works:

  1. Loads scenario packs from scenarios/ (intra-org, cross-org, cross-cloud) — declarative YAML, no code.
  2. Spawns each scenario's agents as their own Python subprocesses (CrewAI / LangChain / LangGraph / custom), each on its own port with its own identity.
  3. Each agent uses the aitp Python SDK (published to PyPI as aitp-sdk, built from aitp-rs/bindings/aitp-py) to build its identity and run the 4-message AITP handshake with peers.
  4. The runner drives capability calls, delegation, revocation, and more between agents, and surfaces a live event stream, narration, metrics, and a web dashboard.

This is a demo harness, not production. All AITP protocol logic lives in aitp-py; this repo contains no envelope signing, JCS, or handshake state. See docs/aitp-integration.md for exactly where that boundary sits.

What it demonstrates

One service, ~20 scenarios, each isolating one AITP behavior:

AreaScenarios show…
Identitypinned Ed25519/P-256 keys and OIDC (RFC-AITP-0002) ID-token binding
Handshake & TCTsthe 4-message mutual handshake; per-call capability authorization
Trust gatinga call with no/insufficient TCT is rejected (403), then succeeds after handshake; grant intersection
Delegationsingle-hop delegation and chained (multi-hop) redemption with scope narrowing (RFC-AITP-0006 / 0011)
Revocationfail-closed local revocation, and per-issuer signed lists (RFC-AITP-0008 §1.5): each agent pulls its own entries from the Control Plane, signs them with its own key, and serves them at /.well-known/aitp-revocation-list (how)
Lifecyclekey rotation (0003 §8), in-band TCT renewal (0013), a TCT verification cache, session bundles (0010), SPKI pinning
Discoverystatic localhost, did:web, and Control Plane registry — each with graceful fallback
Control Planeoptional enrollment, webhooks, trust-anchor provisioning, delegation-tree observability
Resilienceoperator-injected faults (manifest_404, peer_offline) that the run survives with structured outcomes

Beyond the intra-org /runs flow above, POST /hosted-agents and friends spawn a long-lived agent and drive a cross-domain handshake/invoke against a peer hosted by a different instance of this service — see architecture.md for the full route list.

Hosted agents aren't available on Railway: POST /hosted-agents returns 400 there. Federation runs through the TLS stack in federated/.

Everything is optional and degrades cleanly: no LLM key → deterministic stubs (handshakes still run); no Control Plane → static fallback. The published SDK wheel enables the full surface (renewal, session bundles, SPKI pinning, TCT cache, multi-hop delegation) by default; on a slimmed-down or older wheel the advanced scenarios report "feature not available" instead of crashing. Check GET /capabilities to see what your wheel exposes (feature flags: aitp-py README).

Revocation

Revoking a TCT in the Control Plane console reaches the agent that verifies it within one REVOCATION_POLL_SECS interval. Each agent verifies the TCTs it issued, so each one:

  1. pulls its own entries from the CP (GET /api/revocations?iss=<own AID>);
  2. signs them into its own revocation list, served at /.well-known/aitp-revocation-list and advertised in its Manifest as rfc-aitp-0008.revocation_list_uri;
  3. verifies that list against its own AID (aitp.verify_revocation_list) and enforces it, together with its local revocations, on every capability call, redemption and handshake (revocation="fail_closed").

If the CP is stopped, the last list stays served and enforced until its signed expires_at (REVOCATION_LIST_TTL_SECS). It is never replaced by an empty list: past expiry the route answers 503 and a fail_closed agent refuses calls. A restart re-signs with the same key. fail_open is not used anywhere. Details: aitp-integration.md; acceptance test: tests/integration/test_revocation_two_agents.py.

Documentation

The reader-facing docs are under docs/ (also published to the docs site) — start with architecture.md:

  • Architecture — components, runtime topology, where AITP lives.
  • Getting started — install, env, first scenario run, endpoint cheatsheet, CLI.
  • Scenarios — YAML schema, workflow step types, authoring guide.
  • AITP integration — where the SDK is called; identity, handshake, TCT, delegation, revocation, and the draft/extension surfaces (OIDC, renewal, bundles, pinning, multi-hop).
  • Observability — SSE events, narration, Prometheus metrics, the dashboard, run persistence.
  • Control plane — the optional CP: discovery, enrollment, revocation, webhooks, trust anchors.
  • Capabilities — which SDK features the installed wheel exposes, graceful degradation, conformance harness.

Deeper internals and ops mechanics — for hacking on the repo, not on the docs site — live under internal_docs/: the runner engine, the agent-worker pattern, LLM providers, Docker, and the test suite.

Sibling repos — the source of truth for everything the playground only orchestrates. The docs here link out to these rather than restating them:

Quick start

Two paths.

Docker (no host toolchain)

The Dockerfile is multi-stage. By default (AITP_SDK_SOURCE=pypi) it installs the exact aitp-sdk wheel pinned in uv.lock. That wheel lacks the experimental features (TCT renewal, session bundles, multi-hop delegation), so the published image and the compose stacks compile the same version's locked sdist with them instead (AITP_SDK_SOURCE=pypi-src, AITP_SDK_FEATURES=experimental). Pass --build-arg AITP_SDK_SOURCE=path to compile the sibling aitp-rs source (needs that checkout next to this repo). The compose files set the build context to the parent directory so sibling checkouts are visible when needed. Images use Python 3.13 (the full e2e stack also uses Node 24 and Postgres 18) — see docs/docker.md.

cp .env.example .env                  # compose reads .env (Doppler covers native runs)
$EDITOR .env                          # set OPENAI_API_KEY=sk-... (optional for stub runs)

# Just run the service:
docker compose up --build

# Or run the full end-to-end stack — Postgres + a real Control Plane +
# the playground + a tests container that runs the protocol e2e suite
# and (with an OPENAI_API_KEY) the live LLM e2e suite. Exit code of the
# `tests` container is the result.
docker compose -f docker-compose.test.yml up --build --abort-on-container-exit

These compose builds compile the locked aitp-sdk sdist with the experimental features (AITP_SDK_SOURCE=pypi-src), so a cold build pays a Rust compile (several minutes); a plain docker build with the default PyPI wheel takes a minute or two. The e2e stack also builds the Control Plane image from the sibling aitp-cp / aitp-rs checkouts.

Every push to main publishes a prebuilt image tagged main and sha-<short>. A release promotes one of those images, without rebuilding it, to X.Y.Z, X.Y and latest, so ghcr.io/agentidentitytrustprotocol/aitp-playground:latest is the latest release and is what the hosted service runs (how to release and roll back: docs/deployment.md). The image is built with the all-agents LLM extras baked in, so the deployed container calls a real provider whenever LLM_PROVIDER and the matching *_API_KEY are set at runtime (and falls back to deterministic stubs otherwise). The hosted service's variables come from Doppler; see docs/deployment.md.

Native (Python only — the SDK comes from PyPI)

# 1. Install the service. `uv sync` pulls every dependency including the
#    AITP SDK — distribution name `aitp-sdk`, import name `aitp` — which
#    ships prebuilt manylinux/macOS wheels, so no Rust toolchain is
#    needed. (Only when developing against unreleased SDK source do you
#    add a [tool.uv.sources] path override and build with maturin — see
#    the comments in pyproject.toml.)
uv sync                               # or: pip install -e .

# 2. Run. Every non-static route needs the key (x-api-key, or Bearer); unset, they answer 503.
export PLAYGROUND_API_KEY=$(openssl rand -hex 32)
uv run uvicorn aitp_playground.main:app --reload --port 8000

# 3. Trigger a scenario.
curl -X POST http://localhost:8000/runs \
  -H "Authorization: Bearer $PLAYGROUND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scenario_ref":"intra-org/research-and-write@1.0.0",
       "inputs":{"topic":"AI agent trust protocols"}}'

# 4. Watch live events (SSE) or poll:
curl -N -H "Authorization: Bearer $PLAYGROUND_API_KEY" http://localhost:8000/runs/<run_id>/events
curl    -H "Authorization: Bearer $PLAYGROUND_API_KEY" http://localhost:8000/runs/<run_id> | jq .

Authentication, rate limits and the spend cap are described in SECURITY.md.

Agent extras (CrewAI / LangChain / LangGraph + the OpenAI/Anthropic clients) are optional; without them the agents fall back to deterministic stubs and AITP handshakes still run end-to-end. Install when you want real LLM output:

pip install -e ".[all-agents]"

See docs/getting-started.md for the full env reference and the endpoint cheatsheet.

Repo map

aitp-playground/
├── docs/                  # reader-facing docs (published to the docs site)
├── internal_docs/         # contributor & build docs (not published)
├── src/aitp_playground/   # FastAPI service — no AITP protocol logic here
│   ├── api/               # routes: /runs /scenarios /agents /hosted-agents /packs /capabilities /metrics /dashboard /cp/* /cp-proxy/* /webhooks /healthz /internal/telemetry /internal/llm-quota
│   ├── registry/          # YAML pack loader + index + templates
│   ├── runner/            # scenario engine + run store (+ optional SQLite) + SSE
│   ├── hosting/           # subprocess spawn, identity, port alloc, adapters
│   ├── trust/             # peer resolver + did:web + per-run OIDC issuer
│   ├── observability/     # metrics + event narrator
│   ├── cp_client/         # optional Control Plane client
│   ├── capabilities.py    # SDK feature probe (GET /capabilities)
│   └── conformance.py     # RFC fixture catalog + readiness
├── agents/                # agent subprocess workers
│   ├── base/              # shared aitp_server / bootstrap / telemetry / llm / revocation (revocation_state.py, revocation_refresh.py, revocation_publish.py)
│   ├── researcher/        # CrewAI worker
│   ├── writer/            # LangChain worker
│   └── analyzer/          # LangGraph worker
├── scenarios/             # YAML scenario packs (registry on disk)
├── scripts/               # e2e inspection helpers (demo-e2e-run.sh)
├── federated/             # cross-domain federated demo stack — see federated/README.md
└── tests/                 # unit / integration / scenario / e2e

Tests & CI

# Default suites — fast, in-process, no subprocesses.
uv run pytest tests/unit/             # unit tests
uv run pytest tests/scenarios/        # scenario-pack validation

# Runner integration — spawns real agent subprocesses, no LLM keys needed.
AITP_E2E=1 uv run pytest tests/integration/test_runner.py -v

# Protocol e2e — delegation/revocation/rotation/etc. under real trust,
# still no LLM keys (runs inside the docker-compose.test.yml stack).
AITP_PROTOCOL_E2E=1 uv run pytest tests/integration/test_protocol_e2e.py -v

# Live LLM end-to-end — needs OPENAI_API_KEY (one-command via Docker, see above).
AITP_LLM_E2E=1 uv run pytest tests/integration/test_llm_e2e.py -v

# Lint (ruff) — same scope CI runs.
uv run ruff check src agents tests

CI (.github/workflows/ci.yml, on PRs and weekly) runs ruff lint, the unit + scenario suites with a coverage floor on Python 3.11 and 3.13 (installing aitp-sdk from PyPI via uv sync --locked, so the SDK-dependent tests run too), and the AITP_E2E=1 subprocess integration suite. docker.yml builds/pushes the image to ghcr.io (on main and v* tags) and runs the docker-compose e2e stack on main and on pull requests that touch uv.lock, the Dockerfiles or docker-compose.test.yml. See docs/getting-started.md for the tier-by-tier map.

License

See LICENSE.