Runtime Python is the internal execution engine of Harness AI. It lives exclusively on the private Docker network and is never reachable from the public internet. Its job is to do all the heavy lifting that Harness Core deliberately refuses to do: running agents, orchestrating LangGraph workflows, performing RAG retrieval, generating embeddings, dispatching CLI tools, and persisting audit records. The BFF’s only contact with this service is aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/joseluis-dev/harness-ai/llms.txt
Use this file to discover all available pages before exploring further.
fetch() over the private network — the runtime never calls back to the BFF, and the BFF never opens a Postgres or Redis connection of its own.
Architecture
The runtime ships as a single container that supervises two processes viaentrypoint.sh:
uvicorn runtime.api.main:appon port8000(the FastAPI HTTP surface)rq worker executions(the in-process RQ execution worker)
harness_db PostgreSQL instance. The dual-process design avoids the overhead of a separate worker container while keeping the HTTP surface and the job queue cleanly separated in code.
workers=1 is intentional in the uvicorn invocation. A second uvicorn worker process would compete with the RQ worker for the Redis connection and could double-enqueue jobs. The entrypoint supervises both processes and restarts either on failure.Internal Module Structure
API Schemas
The runtime’s FastAPI surface uses Pydantic v2 models withextra="forbid" throughout, ensuring the contract is enforced at the boundary.
The Execution Lifecycle
Every execution travels through four states. Only the runtime may advance or terminal-ise an execution — the BFF never writes to theexecutions table.
QUEUED
POST /internal/executions inserts the row with status=queued and commits the transaction. The enqueue to Redis/RQ happens after the commit so a broker outage cannot roll back the row. The BFF receives 201 { id, status: "queued" }.RUNNING
The RQ worker picks up the job, performs a pre-flight check (execution must still be
queued), and transitions to running. An execution.running audit event is emitted.COMPLETED
On successful completion the worker transitions to
completed, sets completed_at, and emits an execution.completed audit event.Idempotency
The worker is idempotent on the execution UUID. If a broker re-delivers a job whose execution is already in a terminal state (completed or failed), the pre-flight check detects it and returns without writing any rows.
ORM Models
The Audit Invariant
This invariant is preserved even for cross-service audit events originating outside the runtime. The model-gateway, for example, emitsmodel.call JSON log lines but never touches Postgres directly. Instead, it forwards those events to the runtime via POST /internal/audit/ingest, which writes the rows through the existing record_transition_async writer.
POST /internal/audit/ingest
This Phase 2 endpoint accepts batches of forwarded audit events (today:model.call events from the model-gateway). Each event becomes one audit_events row with execution_id=NULL.
execution_id=NULL on cross-service rows is intentional. The foreign key constraint is preserved — a non-NULL value still references executions.id — but model calls are decoupled from the RQ execution lifecycle. The Phase 2 migration 0004_audit_optional_execution makes execution_id nullable while keeping the FK in place.Internal API Surface
All endpoints are reachable only on the private Docker network. There is no public Swagger UI (docs_url=None).
| Method | Path | Description |
|---|---|---|
GET | /healthz | Liveness probe. Returns { status, service, version }. |
POST | /internal/executions | Insert execution row + enqueue RQ job. Returns 201 { id, status }. |
GET | /internal/executions | List executions, ordered created_at desc. Supports limit (≤200) and offset. |
GET | /internal/executions/{id} | Fetch one execution. Returns 404 for unknown ids. |
GET | /internal/executions/{id}/events | Fetch audit events for one execution, created_at asc. Returns 200 [] for unknown ids. |
POST | /internal/audit/ingest | Accept forwarded audit events from the model-gateway. 422 on empty events. |