Getting started

Local dev loop, common commands, and a first scenario run.

Prerequisites

  • Python 3.11+ (matches pyproject.toml's requires-python).
  • uv (recommended) or pip.

That's it — the AITP SDK installs from PyPI (see below), so no Rust toolchain is needed for normal development.

Prefer Docker? Skip to docker.md — docker compose -f docker-compose.test.yml up --build --abort-on-container-exit runs the service plus the e2e suite end-to-end with no host toolchain.

The SDK

The AITP SDK is a regular dependency: distribution name aitp-sdk on PyPI, import name aitp. It ships prebuilt manylinux/macOS wheels, so uv sync (or pip install -e .) installs it like any other package — no maturin, no local build.

You only build from source when developing against unreleased SDK changes in the sibling aitp-rs checkout. In that case add a path override (requires a local Rust toolchain):

# pyproject.toml
[tool.uv.sources]
aitp-sdk = { path = "../aitp-rs/bindings/aitp-py" }

or build the extension into your active venv directly with maturin develop --release from ../aitp-rs/bindings/aitp-py — build details (features, wheels) are the SDK's own docs: aitp-py README and sdk-python.md § Build.

See the comments in pyproject.toml for the authoritative story — the floor pin there records every wire-breaking aitp-sdk bump with a rationale bullet (from the pre-0.3 aitp/0.1 incompatibility through the 0.11.0 pinned-key proof encoding fix, plus routine floor tracking). Read pyproject.toml directly rather than trusting a version number restated here; it drifts. Since 0.17 the floor is the aitp/0.3 wire protocol, so a control plane you point this at must run aitp >= 0.17 too. The SDK's own release history is in the aitp-rs CHANGELOG.

Install the service

cd aitp-playground
uv sync                              # or: pip install -e .

Verify the SDK is importable:

uv run python -c "import importlib.metadata as md; import aitp; print(md.version('aitp-sdk'))"

Optional agent extras (only needed if you want real LangChain/CrewAI/LangGraph running on the host):

pip install -e ".[all-agents]"       # crewai + langchain + langgraph + LLM clients
# or per agent:
pip install -e ".[researcher]"
pip install -e ".[writer]"
pip install -e ".[analyzer]"

Without the extras the agents fall back to deterministic stubs — handshakes and TCTs still happen, only the LLM output is canned. Great for fast iteration on the runner.

Configure

If you have access to the Doppler project aitp-playground, use its dev config instead of a .env file. Run doppler setup -p aitp-playground -c dev once in the repo, then start things under doppler run --, for example doppler run -- uv run uvicorn aitp_playground.main:app --reload --port 8000. That puts every variable in the real process environment, so agent subprocesses see the LLM keys too (see the note below). The hosted deployment's values live in the prd config; deployment.md covers how they reach Railway. dev holds a subset of .env.example's keys and no PLAYGROUND_API_KEY, so set that one yourself (with doppler run, export it or add a personal override in dev_personal). Doppler covers native runs only: docker compose reads .env (env_file: .env), so a compose run still needs the file.

Without Doppler, copy .env.example → .env and edit. The only key the service strictly needs for real LLM output is OPENAI_API_KEY (or ANTHROPIC_API_KEY if you set LLM_PROVIDER=anthropic). Everything else has a sensible default.

.env and native runs. The service reads .env through its pydantic Settings only; nothing copies it into the process environment. Agent subprocesses inherit the service's real environment and read OPENAI_API_KEY / LLM_PROVIDER / *_MODEL straight from it. So for a native uvicorn run, export the LLM variables in your shell (or use set -a; source .env; set +a) — a key present only in .env is invisible to the agents and they silently use the stub. docker-compose.yml and docker-compose.test.yml use env_file: .env, which puts them in the container environment, so those just work (docker-compose.dev.yml does not load .env; pass the variables through your shell).

VarDefaultPurpose
PORT8000uvicorn bind port
HOST0.0.0.0uvicorn bind host
SCENARIOS_DIR./scenariosWhere the registry walks
REGISTRY_CACHE_TTL_MS00 = reload every lookup (hot reload while authoring)
AGENT_BASE_PORT8100First port handed to spawned agents
AGENT_PYTHONpython3Interpreter for agent subprocesses
PLAYGROUND_BASE_URLhttp://localhost:8000This service's public origin: the CP webhook URL it subscribes and the CLI's default target
PLAYGROUND_INTERNAL_URLhttp://127.0.0.1:8000Where this service's own agents reach it (telemetry, LLM quota). Must be loopback: /internal/* only trusts direct loopback peers
CP_BASE_URL(empty)Optional Control Plane base URL (control-plane.md)
CP_API_KEY(empty)Optional CP bearer
CP_READ_API_KEY(empty)Optional CP bearer used only by GET /cp-proxy/* (a read-only CP key). Falls back to CP_API_KEY
CP_PROXY_TIMEOUT_SECONDS10Per-request timeout for GET /cp-proxy/* (connect and each read; the event stream has no read timeout)
CP_TIMEOUT_MS5000Per-request timeout for CP calls
CP_WEBHOOK_TEARDOWN_GRACE_SECS120How long after a run ends (and its events are ingested) its CP webhook subscription is deleted
REVOCATION_FAIL_MODEfail_closedAxis B: what to do about the absence of a fresh verified list. With CP_BASE_URL set, each agent verifies its own signed list against its own AID. fail_closed refuses capability calls while degraded (the spec's own default); soft_fail serves on the last verified deny-set. Never governs authenticity — an unverifiable list is discarded either way.
REVOCATION_MAX_STALENESS_SECS300Axis B: how long since the last successful pull before the posture is "degraded"
REVOCATION_POLL_SECS60Cadence for the background pull, re-sign and verify of each agent's own revocation list
REVOCATION_LIST_TTL_SECS3600Lifetime (expires_at) of each agent's own signed revocation list. Re-signed every poll; if the CP is unreachable the agent serves its last list until this runs out, then answers 503 rather than an empty list
PUBLIC_HOST / PUBLIC_SCHEME(empty) / httpsPublic origin this service advertises for agents it hosts via POST /hosted-agents (federated/cross-domain demos). Empty PUBLIC_HOST means "no public origin", and POST /hosted-agents needs one in its body.
INSECURE_LOCALHOST_DANGEROUSfalseLocal/test only. Scenario agents serve plain http://localhost instead of TLS on loopback, and SDK calls pass insecure_localhost_dangerous. Any non-loopback http:// endpoint is refused either way. The service refuses to start with this on a Railway deployment.
LLM_PROVIDERopenaiopenai or anthropic
OPENAI_API_KEY / ANTHROPIC_API_KEY(empty)Required for real LLM output
OPENAI_MODELgpt-4o-miniOverride
ANTHROPIC_MODELclaude-sonnet-4-6Override
RUN_HISTORY_DB(empty)When set, persist runs + events to this SQLite file so they survive a restart. Empty = in-memory only.
PLAYGROUND_API_KEY(empty)Key(s) for every authenticated route (see the endpoint table), sent as x-api-key or Authorization: Bearer. Comma-separated to overlap a rotation. Empty fails closed: those routes answer 503.
AITP_PLAYGROUND_REQUIRE_API_KEYfalsetrue puts every path except /healthz, the CP webhook and loopback /internal/* behind the key, static listings included. The service refuses to start if this is true and PLAYGROUND_API_KEY is empty. See SECURITY.md
RATE_LIMIT_PER_MINUTE / RATE_LIMIT_BURST10 / 5Token bucket on POST /runs and POST /hosted-agents/{id}/invoke, applied per client IP and per API key
MAX_RUNS_PER_HOUR30Global cap on run creations plus hosted invokes in any rolling hour; the next one gets 429 before any agent starts
RUN_RATE_LIMIT_PER_IP5Run launches (POST /runs) and hosted invokes per trusted client IP (X-AITP-Client-IP with a valid key) in RUN_RATE_LIMIT_WINDOW_SECONDS; the next gets 429 run_rate_limited. Keyless and header-less callers are not per-IP limited
RUN_RATE_LIMIT_WINDOW_SECONDS600Sliding window for RUN_RATE_LIMIT_PER_IP
MAX_CONCURRENT_RUNS3Runs in progress at once, service-wide; the next launch gets 429 max_concurrent_runs with Retry-After: 10. A slot frees when the run ends (success, failure, cancel or deadline)
RUN_DEADLINE_SECONDS900A run still going after this ends failed with code: run_deadline_exceeded, its agents torn down
LLM_QUOTA_PER_IP_PER_DAY30Real LLM call units per trusted client IP (X-AITP-Client-IP) per UTC day. Over quota, the agent answers with its deterministic mock. 0 refuses every real call
LLM_QUOTA_PER_IP_PER_MONTH300The same, per UTC calendar month
LLM_QUOTA_GLOBAL_PER_DAY1000Real LLM call units across every caller per UTC day
LLM_QUOTA_GLOBAL_PER_MONTH10000The same, per UTC calendar month
LLM_QUOTA_STOREautoWhere the quota counters live: postgres, memory, unavailable (refuse every real call), or auto: postgres when DATABASE_URL is set, else memory locally and unavailable on Railway
DATABASE_URLunsetThe dedicated playground Postgres for the quota counters (a Railway reference variable in prod, not a Doppler key). The table playground_llm_usage is created on first connect. Never logged
RUN_TOKEN_BUDGET40000Output-token budget per run, split across the run's agents and enforced in each agent before every provider call (429 once spent). A hosted agent gets the whole budget for its lifetime.
LLM_MAX_TOKENS_PER_CALL1024max_tokens cap on every single provider call
LOG_LEVELINFOStandard logging level

Provider selection is process-wide, not per-scenario: LLM_PROVIDER picks openai or anthropic, and if the matching API key is missing the agent falls back to its deterministic stub rather than erroring. There is deliberately no cross-provider failover — silently swapping providers behind your back would make debugging harder, and the point of the demo is to show the real path running. Look for llm.started / llm.complete in the run's event log to confirm a real provider call happened rather than a stub. A key that is present but fails at call time (expired, wrong scope, quota, unreachable) does not fall back to the stub: the agent emits llm.failed (with the provider's error text) and answers HTTP 502, and the run fails with a message of the form <agent> self-execute <capability> failed: status=502 detail=….

Before a real call the agent also asks the playground's LLM quota (LLM_QUOTA_* above). Over quota, the capability answers with its stub and the run is flagged rather than failed; see observability.md § LLM quota.

Run the service

uv run uvicorn aitp_playground.main:app --reload --port 8000

Hit health to confirm:

curl -s http://localhost:8000/healthz
# {"status":"ok"}

First scenario run

curl -s -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 identity"}}'
# {"run_id":"<uuid>","status":"pending","scenario_ref":"intra-org/research-and-write@1.0.0"}

Watch it run:

# Poll the final state:
curl -s -H "Authorization: Bearer $PLAYGROUND_API_KEY" http://localhost:8000/runs/<uuid> | jq .

# Or stream events live (SSE):
curl -N -H "Authorization: Bearer $PLAYGROUND_API_KEY" http://localhost:8000/runs/<uuid>/events

Cancel a stuck run:

curl -s -X POST -H "Authorization: Bearer $PLAYGROUND_API_KEY" http://localhost:8000/runs/<uuid>/cancel

Useful endpoints

Only the static routes are public: /healthz, /capabilities, /packs, /scenarios*, the /dashboard HTML shell and the OpenAPI docs. Every other route needs the key, as x-api-key: $PLAYGROUND_API_KEY or Authorization: Bearer $PLAYGROUND_API_KEY (401 without it, 503 when the service has no key configured). With AITP_PLAYGROUND_REQUIRE_API_KEY=true the static routes need it too; only /healthz stays open. POST /webhooks/cp/{run_id} is verified by the CP's HMAC instead, and POST /internal/telemetry by a per-process token only the playground's own agents hold. See SECURITY.md.

EndpointWhat
GET /healthzLiveness
GET /capabilitiesInstalled aitp wheel + which optional features it exposes (capabilities.md)
GET /packsList loaded scenario packs
GET /scenariosList all scenarios with refs, plus sdk_features_required / sdk_available
GET /scenarios/{pack}/{scenario}@{version}Full scenario YAML, parsed (+ template list); same SDK fields, per template too
POST /runsStart a run (async; returns run_id immediately). Body accepts template to run a variant and an optional free-form run_label (echoed back in the create/list/get responses).
GET /runsList recent runs (in-memory by default; RUN_HISTORY_DB makes them durable)
GET /runs/{id}Full run record incl. outputs and events, and the LLM quota flag (llm_quota_exceeded, llm_quota.resets_at, llm_calls_on_mock; observability.md)
GET /runs/{id}/statusJust status + event count
GET /runs/{id}/eventsSSE event stream (replay + live)
GET /runs/{id}/narrateHuman-readable narration of the event log (text/plain)
GET /runs/{id}/cp-auditAudit events the CP recorded for this run (control-plane.md)
GET /runs/{id}/cp-sessionsHandshake sessions the CP observed for this run
GET /runs/{id}/cp-deliveriesCP webhook deliveries this run has received (requires a prior cp_subscribe_webhook step)
POST /webhooks/cp/{run_id}Receiver Control Plane POSTs to during webhook fan-out (HMAC-verified, including the signed X-Aitp-Timestamp, which must be within 5 minutes; a repeated deliveryId is not recorded twice)
POST /runs/{id}/cancelMark cancelled, then kill agent subprocesses (this order closes the D-16 race: a concurrent dispatch failure that lands after the mark sees status=cancelled already, never a stale running)
GET /agentsList currently-running agent processes
GET /metricsPrometheus metrics (observability.md)
GET /dashboardSingle-page trust console (HTML). The shell is public; its data calls need the key, so it is a local-dev view
GET /cp/*Read-only Control Plane observability projections (control-plane.md)
GET /cp-proxy/*Key-gated passthrough to an allowlist of Control Plane reads, for the console (control-plane.md)
POST /internal/telemetrySink for agents — not for external use
POST /internal/llm-quotaThe LLM quota check agents make before a real call; loopback only, agent token (SECURITY.md)

OpenAPI is at http://localhost:8000/docs while the server runs.

The endpoints above all belong to the intra-org /runs flow. A separate /hosted-agents surface spawns a long-lived agent and drives a cross-domain handshake/invoke against a peer hosted by a different playground instance — see architecture.md for the full route list.

Scenario authoring CLI

For dev work without spinning up the API:

uv run python -m aitp_playground.cli list

uv run python -m aitp_playground.cli validate
uv run python -m aitp_playground.cli validate scenarios/intra-org/research-and-write

uv run python -m aitp_playground.cli dry-run intra-org/research-and-write@1.0.0 \
  --inputs '{"topic":"test"}'

dry-run validates the inputs against the scenario schema and prints the trust mode, agent list, and workflow steps without spawning anything. Useful for catching typos before you wait for spawns.

The CLI has a few more subcommands:

uv run python -m aitp_playground.cli new intra-org/my-scenario@1.0.0   # scaffold on disk
uv run python -m aitp_playground.cli lint                              # cross-scenario refs + step graph
uv run python -m aitp_playground.cli trace intra-org/research-and-write@1.0.0 \
  --inputs '{"topic":"AI agents"}'                                     # run against a live server + narrate
uv run python -m aitp_playground.cli conformance                      # RFC fixture catalog + wheel readiness

trace drives a run against a running playground and streams the narration; conformance is covered in capabilities.md.

Common dev loops

You're working on…Run
Scenario YAMLEdit + dry-run; if good, hit POST /runs. REGISTRY_CACHE_TTL_MS=0 so no restart needed.
Runner engineuv run pytest tests/unit/ for the fast loop; AITP_E2E=1 uv run pytest tests/integration/test_runner.py -v to drive real subprocesses (stub LLMs, no keys).
Agent workerRestart the uvicorn server so it re-spawns subprocesses with your changes.
Real LLM behaviorSet OPENAI_API_KEY and either run a scenario or AITP_LLM_E2E=1 uv run pytest tests/integration/test_llm_e2e.py.

Development & testing

The test suite is tiered; each tier past the default is gated behind an env var so pytest stays fast by default.

TierCommandGateWhat it needs
Unituv run pytest tests/unit/none (default)Nothing — fast, in-process.
Scenario packsuv run pytest tests/scenarios/none (default)Validates every YAML pack on disk.
Runner integrationuv run pytest tests/integration/test_runner.py -vAITP_E2E=1Spawns real agent subprocesses; deterministic stubs, no LLM keys.
Protocol e2euv run pytest tests/integration/test_protocol_e2e.py -vAITP_PROTOCOL_E2E=1Delegation/revocation/rotation under real trust. Designed to run inside the docker-compose.test.yml stack (real Control Plane + Postgres).
LLM e2euv run pytest tests/integration/test_llm_e2e.py -vAITP_LLM_E2E=1Real provider calls — needs OPENAI_API_KEY. Also run by the Docker test stack.

Linting is ruff (configured in pyproject.toml; ruff format exists but formatting is not CI-enforced):

uv run ruff check src agents tests     # what CI runs

How CI maps onto these (.github/workflows/):

  • ci.yml — on every PR to main (plus a weekly scheduled run; not on push, because strict branch protection means a PR run already tested the merged tree): a ruff lint job; the unit + scenario suites with two separate coverage gates (src/* ≥88%, agents/base/* ≥54% — kept separate so a regression in one can't hide behind the other's floor) on a Python 3.11/3.13 matrix, run against uv sync --locked (which installs aitp-sdk from PyPI, so the SDK-dependent tests run rather than skip). That job also clones aitp-verifier-py so the vendored JCS canonicalizer's drift guard is a real gate rather than a skip. A separate AITP_E2E=1 integration job (no ordering dependency on the test job) runs test_runner.py and the in-process test_federated_handshake.py.
  • docker.yml — builds the playground image on PRs; on main and v* tags it pushes to ghcr.io (with the all-agents LLM extras baked in). It runs the full docker-compose.test.yml e2e stack (protocol e2e + LLM e2e when the OPENAI_API_KEY secret is set) on main, and also on PRs that touch uv.lock, Dockerfile, Dockerfile.cp-e2e or docker-compose.test.yml, so an SDK-pin or base-image bump is exercised before it merges.
  • bump-aitp.yml / auto-merge.yml — the event-driven aitp-sdk lock bump (dispatched when aitp-rs publishes) and the auto-merge of green routine bumps; both call shared workflows from aitp-ci.
  • notify-website.yml — pings the docs site to re-sync when docs/** or README.md change on main.

The suite is laid out in four directories:

tests/
├── conftest.py       # sets PYTHONPATH and SCENARIOS_DIR
├── unit/              # fast, in-process, no subprocesses (default target)
├── integration/       # test_runner.py, test_protocol_e2e.py, test_llm_e2e.py,
│                       #   test_federated_handshake.py — gated by AITP_E2E / AITP_PROTOCOL_E2E / AITP_LLM_E2E
├── e2e_federated/     # two-service federated stack, gated by AITP_FEDERATED_E2E (see federated/README.md)
└── scenarios/         # offline registry consistency checks (no spawn, no LLM)
SuiteTriggerNeeds OpenAI key?Needs spawn?Wall time
tests/unit/defaultnonoseconds
tests/scenarios/defaultnonoseconds
tests/integration/test_runner.pyAITP_E2E=1no (stubs)yes~30-45s
tests/integration/test_protocol_e2e.pyAITP_PROTOCOL_E2E=1no (stubs)yes (Docker recommended)minutes
tests/integration/test_llm_e2e.pyAITP_LLM_E2E=1yesyes (Docker recommended)minutes

test_federated_handshake.py shares the AITP_E2E gate with test_runner.py and needs no Docker stack (an in-process TestClient over two real loopback ports; it still spawns agent subprocesses). The tests/e2e_federated/ suite needs the Docker stack from federated/ up first.

Protocol e2e and LLM e2e are designed to run inside the docker-compose.test.yml stack, where the gates and service URLs are pre-wired — see docker.md for the one-command recipe.

Troubleshooting

  • AITP_BOOTSTRAP_FILE not set — an agent is being launched without the env var. Almost always means you ran an agent script directly instead of letting the supervisor spawn it.
  • Subprocess exits before AITP_AGENT_READY — supervisor prints the child's stderr. Most common cause: missing optional dep or broken import in the agent's crew.py/chain.py/graph.py.
  • tct rejected: ... — the SDK's verify_tct failed. Look in the event log for the prior trust.established to confirm the jti/grants the caller actually holds.
  • Run hangs in running forever — usually an agent didn't bind its port within startupTimeoutMs (default 30s). Check the playground logs for the captured stdout/stderr from the child.
  • /runs/{id} returns outputs: {} — the run failed before reaching any workflow step. Check error and the event log; the failing step is usually right before run.failed.

When in doubt, the event log is authoritative — every state change in the runner produces a RunEvent.