Warpra server
warpra-server is an HTTP server for graphs built with warpra. It serves Warpra’s HTTP API (assistants, threads, runs, crons, store) over REST and SSE. The official Python client and RemoteGraph can call it. See Python and JavaScript clients.
Register a graph in code
Section titled “Register a graph in code”use warpra::{CompileOpts, NodeCtx, NodeError, StateGraph, END, START};use warpra_server::{GraphContext, Server};use serde_json::{json, Value};
#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> { Server::builder() .graph("echo", |ctx: GraphContext| async move { let mut g = StateGraph::new().last_value("text"); g.add_node_fn("echo", |s: Value, _c: NodeCtx| async move { Ok::<Value, NodeError>(json!({"text": format!("{} echoed", s["text"].as_str().unwrap_or(""))})) })?; g.add_edge(START, "echo")?; g.add_edge("echo", END)?; g.compile(CompileOpts::new().checkpointer(ctx.checkpointer.clone()).store(ctx.store.clone())) }) .build()? .serve() .await?; Ok(())}The factory receives a GraphContext with the server’s checkpointer and store. Compile with them so threads persist in the server’s backend. The factory runs per run and per state or introspection request, so it can build a graph per assistant.
The server reads its settings from the environment. Auth is on by default, so set an API key of at least 24 characters before you start it:
export WARPRA_API_KEYS=dev-key-0123456789abcdefghijcargo runWithout a database URL the server uses the in-memory backend and logs a warning. It listens on 127.0.0.1:8000 by default.
Other builder methods: graph_description, schemas, message_keys, wire_messages, model_registry, config_file, config_json and env.
The binary
Section titled “The binary”The warpra-server binary serves graphs declared in warpra.json (declarative ReAct agents). Subcommands:
| Command | What it does |
|---|---|
serve (default) |
Run until SIGTERM or Ctrl-C |
healthcheck |
GET /ok on the local port; exit 0 on 200, else 1 |
migrate |
Apply database migrations and exit |
check-config |
Validate the configuration, print the resolved graphs and exit |
The released image contains no code graphs. For code graphs, build your own binary on the library as above.
What it serves
Section titled “What it serves”- Assistants: create, get, update (new version), delete, search, count, versions, set latest, graph drawing (
xray), schemas, subgraphs. Each registered graph gets a default assistant whose id isuuid5of the graph id. - Threads: create, get, update, delete, search, count, copy, prune, TTL, state (latest, by checkpoint id, by checkpoint), state update, history, thread stream.
- Runs: stateful and stateless; create, stream, wait, batch, list, get, delete, join, join stream, cancel, cancel many. Multitask strategies
reject,enqueue(default),interruptandrollback. Resumable streams withLast-Event-IDreplay. Delayed runs (after_seconds). Interrupts andcommand.resume, by value or by interrupt id.interrupt_beforeandinterrupt_after. - Crons: 5-field schedules and aliases such as
@daily, in an IANA timezone, withend_time, enable and disable, search and count. - Store: put, get, delete, search (with semantic search when an index is configured), list namespaces, TTL.
- Webhooks: sent once per finished run, signed with
X-Nexura-Signature(HMAC-SHA256) when a signing secret is set, with up to 3 retries. Private, loopback and metadata addresses are rejected. - Auth: API keys (
x-api-keyorAuthorization: Bearer), CORS. - Persistence: memory, SQLite or Postgres. One database holds checkpoints, the store and the server’s tables.
- Process lifecycle: startup recovery, run leases and heartbeats, SIGTERM drain, TTL and event-log sweepers.
- Meta:
GET /ok(public health check) andGET /info.
Stream modes
Section titled “Stream modes”Runs stream these modes over SSE: values, updates, messages, messages-tuple, custom, checkpoints, tasks, debug and tools. messages is accumulated on the server into messages/metadata, messages/partial and messages/complete events. Subgraph events carry |ns suffixes.
Replicas
Section titled “Replicas”With Postgres, run several replicas. Any replica serves any request. Runs are claimed from the database (SKIP LOCKED), streams and cancels reach other replicas through LISTEN/NOTIFY with a polling fallback, and crons and sweepers take advisory locks. Tests cover two worker pools that never run a run twice, and a stream and cancel on an API-only replica for a run another replica executes. Set WARPRA_N_JOBS_PER_WORKER=0 for an API-only replica.
SQLite and memory support exactly one replica. SQLite takes a file lock and refuses to start when it is held.
These are not yet supported, or are limited by design:
- v3 protocol:
threads.stream(),RemoteGraph.stream_events(version="v3"), the/threads/{id}/commandsand/threads/{id}/stream/eventsroutes, and the WebSocket transport answer 501. - Stream modes:
eventsandlifecyclereturn 422unsupported_stream_mode.lifecyclebelongs to v3. - Ids: thread and assistant ids must be UUIDs. A non-UUID id, such as
RemoteGraphwiththread_id="1", returns 422invalid_uuid. - Reserved keys:
__*keys inconfigurablereturn 422, except__pregel_resuming,__pregel_resume_mapand__pregel_durability, whichRemoteGraphforwards when it runs as a node of a local graph. - Credentials in config: keys that look like credentials or endpoints (
api_key,base_url,*_token,*_secret, …) inconfigurableorcontextreturn 422. Model credentials come only from server config and environment. - Thread stream: the event names of
threads.join_streamare a design guess. - Python graphs: Python import paths in the config are refused. Custom auth handlers, per-user resource isolation,
/docs,/openapi.jsonand/metricsare not available. All authenticated keys see all resources. - Thread stream scope on Postgres: the thread stream only sees runs executed and state updates handled by the same replica.
- Graph caching: not implemented. Graphs are built per request.
- MCP servers: wired in the config, but only exercised through configuration errors in tests.
- Web UI: not yet available. Warpra Studio is planned.
Verified
Section titled “Verified”- In-process HTTP tests over memory and SQLite for every route, every stream mode’s event names and payload keys, interrupts and resume, multitask strategies, cancel, resumable streams, crons, webhooks, lease recovery and SIGTERM drain.
- The same suite against Postgres, plus live multi-replica tests.
- Tested with the official Python client and
RemoteGraph: 58/58 suite tests and 22/22 client integration tests, on the memory and Postgres backends. See Python and JavaScript clients.
Warpra is open source under Apache-2.0. Made by Liceron.