Project overview
Install graphrt, run the example workflows, and see what each part of the runtime does.
Why graphrt
Section titled “Why graphrt”- Small. Core-only binary ≈ 3 MB, everything included ≈ 12–14 MB, a trimmed server build ≈ 6 MB that runs in 16 MiB of RAM. No Python, no Node, no database.
- Fast. About 0.4 µs of scheduling per node, ~6 µs from a model’s first token to your stream, a few milliseconds for
graphrt runfrom process start to exit, and well over 10k requests/s per core fromgraphrt serve(see Performance). One task per run polls node futures concurrently; nothing is spawned per node, and variable pools are reference-counted, so loops and parallel iterations don’t deep-copy state. - Portable. The core is executor-agnostic (bring your own clock) and compiles to
wasm32-unknown-unknown. - Agent-native. First-class
agentnode with a tool-calling loop that streams its answer token by token, parallel tool calls, MCP servers, human approval of tool calls, retries with backoff, per-node timeouts and step/time budgets. - Durable. Pause anywhere (human input, tool approval, API call), get a JSON snapshot, resume later — even inside loops and iterations.
- Safe by default. Secrets never leave the process in logs, events or snapshots. HTTP egress blocks private networks (SSRF). Templates run with fuel limits. Code runs in an interpreter with memory/time limits and no I/O.
Install
Section titled “Install”# Linux / macOS: prebuilt static binary (verifies SHA256SUMS)curl -fsSL https://raw.githubusercontent.com/Graphrt/graphrt/main/install.sh | sh# the gateway build: the same CLI plus `graphrt gateway` / `graphrt deploy`, every providercurl -fsSL https://raw.githubusercontent.com/Graphrt/graphrt/main/install.sh | sh -s -- --gateway
# Homebrew (macOS, Linux)brew install graphrt/graphrt/graphrt
# with Rust (1.89+)cargo install graphrt-cli # installs the `graphrt` binarycargo install graphrt-cli --features eval,online-eval # + `graphrt eval` and `serve --evaluators`cargo install graphrt-cli --features gateway-all # + `graphrt gateway` and `graphrt deploy`
# container (linux/amd64, linux/arm64)docker run --rm -p 8080:8080 -v "$PWD/flows:/workflows" ghcr.io/bimapangestu28/graphrtdocker run --rm ghcr.io/bimapangestu28/graphrt:gateway gateway --help # gateway buildLinux (x86_64, aarch64; static musl), macOS (x86_64, aarch64) and Windows (x86_64,
.zip, no Visual C++ runtime needed) archives with SHA256SUMS are on the
releases page. Two builds per
platform: graphrt-<target> (the agent: run, serve, eval) and, on Linux and macOS,
graphrt-gateway-<target> (the same CLI plus the gateway and graphrt deploy with every
provider; it links mimalloc, which agents leave out). The gateway is Unix-only, so Windows
has the agent archive only. The release workflow builds them on each OS after the test suite
passed on Linux, macOS and Windows.
Libraries are on crates.io: graphrt-core (runtime) plus integration crates such as
graphrt-llm, graphrt-http, graphrt-rag.
Quick start
Section titled “Quick start”cargo install graphrt-cli # or, from a checkout: cargo install --path crates/graphrt-cli
graphrt run examples/hello.yaml --input name=Ada# {"greeting": "Hello, Ada."}
graphrt run examples/branching.yaml --input priority:=9 --input subject="DB down"# URGENT: paging on-call for 'DB down' (priority 9)
OPENAI_API_KEY=sk-... graphrt run examples/chatbot.yaml --sys query="What is a DAG?"# (tokens stream to your terminal)Human in the loop:
graphrt run examples/approval.yaml --input amount:=1200 --input reason="New laptop"# exit code 3: paused, snapshot written to examples/approval.snapshot.jsongraphrt run examples/approval.yaml --resume examples/approval.snapshot.json \ --resume-input 'review={"action":"approve","values":{"note":"ok"}}'Serve workflows over HTTP with Server-Sent Events:
GRAPHRT_API_KEY=change-me graphrt serve examples/ --addr 0.0.0.0:8080curl -N -H 'Authorization: Bearer change-me' \ -d '{"inputs":{"name":"Ada"},"stream":true}' \ http://localhost:8080/v1/workflows/hello/runsEach run event is one SSE message; response events carry the ordered answer
text token by token, from llm and agent nodes alike (see
docs/serving.md). Every event has an id: (its
index in the run’s log), so a client that reconnects to
/v1/runs/{id}/events with Last-Event-ID gets exactly the rest of the run.
On SIGTERM or SIGINT the server drains: new runs get 503, active runs pause
and are stored (nodes still running near --drain-timeout are cancelled and
run again on resume), then it exits, also as PID 1 of a container. Async runs
resume when the next server starts on the same store; see the grace periods
per platform in docs/deploy.md.
graphrt serve --trust-gateway --deployment shop --listen unix:/run/shop.sock
runs the server as an agent behind a graphrt gateway: a signed (HMAC-SHA256)
/internal/v1 API for starting, resuming, reattaching to and draining runs,
where a lost gateway connection pauses the run for reclaim instead of losing
it. See docs/gateway-protocol.md.
Per-user credentials (a Supabase or OAuth JWT from a mobile app) can travel in
their own header and reach the workflow as a masked secret input, while
Authorization stays the server’s API key:
graphrt serve flows/ --input-header user_jwt=X-User-Authorizationcurl -H "X-User-Authorization: Bearer $USER_JWT" -d '{"stream":true}' \ http://localhost:8080/v1/workflows/chat/runsWith --verify-jwt user_jwt the server verifies that token itself (JWKS or
HS256, exp, iss, aud), so the app needs no API key, and
--user-rate-limit caps runs per user. A full Supabase chatbot backend (schema
with RLS, agent, container, deploy notes, end-to-end security tests) is in
examples/supabase-chatbot, with Flutter and React
Native clients in graphrt-examples;
the guide is docs/chatbot-supabase.md.
See docs/serving.md and docs/cli.md for every command and flag, and the docs index for everything else.
A workflow
Section titled “A workflow”version: "1"name: support-triageenv: - { name: CRM_TOKEN, type: secret }graph: nodes: - id: start type: start variables: [{ variable: ticket, type: paragraph, required: true }]
- id: classify type: question-classifier model: { provider: openai, name: gpt-4o-mini } query_variable_selector: [start, ticket] classes: [{ id: billing, name: Billing }, { id: bug, name: Bug report }]
- id: lookup type: http-request method: get url: "https://crm.example.com/api/tickets?q={{#start.ticket#}}" authorization: { type: api-key, config: { type: bearer, api_key: "{{#env.CRM_TOKEN#}}" } } retry: { max_retries: 3, interval_ms: 500, backoff: 2.0 } timeout_ms: 10000 on_error: { strategy: fail-branch }
- id: reply type: answer answer: "Category: {{#classify.class_name#}}" edges: - { source: start, target: classify } - { source: classify, target: lookup, handle: billing } - { source: classify, target: reply, handle: bug } - { source: lookup, target: reply }Values are referenced as {{#node.output.path#}}. The full format is in
docs/workflow-format.md.
| Kind | What it does | Crate |
|---|---|---|
start / end / answer |
Typed inputs; final outputs; streamed answer text | core |
if-else |
Multi-case conditions (20+ operators, file attributes) | core |
template-transform |
Jinja2 templates (sandboxed, fuel-limited) | core |
variable-aggregator |
First non-null of several branches | core |
assigner |
Write conversation / loop variables (set, append, +=…) |
core |
list-operator |
Filter, sort, slice and pick list items | core |
iteration |
Map a sub-graph over a list, optionally in parallel | core |
loop |
Repeat a sub-graph with loop variables and break conditions | core |
human-input |
Pause for a form / decision, resume with the answer | core |
tool |
Call a native or MCP tool | core |
llm |
Chat completion with streaming, memory, vision, structured output | llm |
agent |
Tool-calling loop with approvals and parallel tool calls; streams every turn per token; per-run tool context (e.g. the user’s JWT, never shown to the model) | llm |
question-classifier |
Route by LLM classification | llm |
parameter-extractor |
Extract typed parameters from text | llm |
http-request |
HTTP with SSRF-safe egress, auth, JSON/form/multipart bodies | http |
code |
JavaScript in QuickJS with memory/time limits; Python via a sandbox service or a local subprocess (trusted code) | code |
document-extractor |
Text from PDF, Office, spreadsheets, HTML, EPUB, CSV, e-mail and subtitles | doc |
knowledge-retrieval |
Search one or more knowledge bases (vector, keyword or hybrid, rerank, metadata filters) | rag |
Every kind publishes a catalog descriptor with a config JSON Schema
(graphrt nodes, GET /v1/nodes), so visual builders can render palettes and
forms and validate documents (POST /v1/validate) before deploying them.
Model providers: any OpenAI-compatible API (OpenAI, Azure OpenAI, Ollama, vLLM,
Groq, OpenRouter, DeepSeek…) and Anthropic, configured from the environment or a
providers file (--providers); --model ollama/qwen2.5:14b points every model
node at another model. Tools: native Rust closures and
MCP servers (stdio and streamable HTTP). Opt-in live tests send tiny chat,
streaming and tool-calling requests to OpenAI, Anthropic, Gemini, Bedrock and
TypeSafe, nightly in CI behind repository secrets
(docs/providers.md).
Knowledge bases
Section titled “Knowledge bases”knowledge-retrieval searches datasets described in a knowledge config
(--knowledge kb.yaml), and graphrt kb ingest|query fills and tests them from
the command line.
- Stores: in memory (optionally a JSON file), a single SQLite file (incremental writes, shared by several processes), or Qdrant.
- Embeddings: computed in-process on the CPU (BERT-family models such as
all-MiniLM-L6-v2or the multilingualmultilingual-e5-small, downloaded once, then offline — no server or API key), Ollama, or any OpenAI-compatible API. - Retrieval: vector, BM25 keyword or weighted hybrid search, rerankers (Cohere, Jina, Voyage), score thresholds, metadata filters, and parent-child chunking (search small chunks, answer with their section).
- Management API for knowledge base UIs:
graphrt serve --knowledgeexposes/v1/knowledgeto create and delete datasets, list documents, upload files (PDF, Office, Markdown…), inspect chunks, enable or disable and delete documents, and test retrieval — on the same knowledge base the workflows use. See docs/serving.md.
embedders: { local: { type: local } } # in-process, offline after first usestores: { local: { type: sqlite, path: kb.db } }datasets: - { id: handbook, store: local, embedder: local, chunking: { max_chars: 400, parent_max_chars: 1600 } }In-process embeddings, the SQLite store, parent-child chunking and the management API (including creating and deleting datasets) are available since 0.2.0.
Evaluate
Section titled “Evaluate”graphrt eval checks a workflow against test cases and gates CI on the pass
rate (exit code 5 when the gate fails). Eval files use Promptfoo’s
tests / assert shape; assertions cover answers, JSON outputs, latency and
token budgets, the tools an agent called (and in what order, with which
arguments), retrieval recall / precision / MRR, and LLM judges that are
themselves graphrt workflows (versioned by fingerprint, calibrated against
human labels with TPR / TNR / Cohen’s kappa). --trials reports pass@k and
pass^k, and --baseline fails CI on regressions beyond a tolerance. Model
responses can be replayed from recorded cassettes (kind: replay providers),
so agent and judge suites run offline, free and deterministically.
# support.eval.yamlworkflow: support-agent.yamlproviders: providers.replay.yaml # recorded model responsestests: - vars: { question: "Please refund order 456." } assert: - { type: icontains, value: refunded } - { type: trajectory:tool-sequence, value: [search_orders, refund_order] } - { type: judge, workflow: judges/goal-success.yaml, inputs: { goal: "Order 456 is refunded." } } - { type: tokens, threshold: 4000, weight: 0 } # reported, never fails the testgate: { pass_rate: 0.95, pass_hat_k: 0.8 }graphrt eval support.eval.yaml -j 8 --trials 3 --baseline main.json --output results.json --junit junit.xmlThe same harness is a library (graphrt-eval) for
cargo test. See docs/evals.md and the offline
examples.
In production, graphrt serve --evaluators evaluators.yaml scores a sample of
finished runs with the same judges and checks in a bounded background pool,
POST /v1/runs/{id}/feedback records human feedback, and every score is a
gen_ai.evaluation.result span event in the run’s trace. --otel-preset langfuse (or langsmith, braintrust, opik, phoenix, mlflow) sends the
traces to a vendor configured from its own environment variables, and
--langfuse-scores uploads the scores.
Plugins: write a node in 20 lines
Section titled “Plugins: write a node in 20 lines”Add node kinds (and agent tools) in Python, TypeScript/JavaScript, Rust or WebAssembly, without recompiling graphrt. A plugin is a directory with a manifest; graphrt starts it on first use and talks JSON-RPC over stdio.
# plugin.py — scaffold with: graphrt plugin new acme --lang pythonfrom graphrt_plugin import Plugin, PluginError
plugin = Plugin("acme")
@plugin.node("acme.shout")async def shout(ctx, req): text = req.config.get("text") # `{{#start.msg#}}` already resolved if not isinstance(text, str): raise PluginError("`text` must be a string", kind="invalid_input") await ctx.chunk("text", text.upper()) # streams like LLM tokens return {"outputs": {"text": text.upper()}}
if __name__ == "__main__": plugin.run()graphrt plugin new acme --lang python # or typescript, rustgraphrt run acme/example.yaml --plugins acme --input who=Worldgraphrt plugin install ./acme # or a git URL; lands in ~/.graphrt/pluginsgraphrt plugin install open-meteo # or a name from the plugin catalog (`graphrt plugin search`)graphrt nodes # plugin kinds show up next to built-insPlugin nodes stream, branch, pause for approval, report errors with retry hints,
and expose tools to agent nodes; graphrt serve --plugin-pool keeps process
plugins warm so no run waits for their start. WebAssembly plugins run sandboxed in-process
(fuel and memory limits, no system access) — drop a .wasm file into a plugin
directory; with a manifest they can also offer agent tools (with the per-call
tool_context) and make HTTP requests through graphrt’s SSRF-safe egress. See docs/plugins.md, the
manifest specification,
docs/wasm-plugins.md and
plugins/examples.
Embed it
Section titled “Embed it”use std::sync::Arc;use futures::StreamExt;use graphrt_core::{Engine, Event, Graph, Registry, RunInput};
#[tokio::main(flavor = "current_thread")]async fn main() -> Result<(), Box<dyn std::error::Error>> { let mut registry = Registry::with_builtins(); graphrt_llm::register(&mut registry);
let graph = Arc::new(Graph::from_text(include_str!("workflow.yaml"), ®istry)?); let services = graphrt_core::Services::new().with(graphrt_llm::ModelRegistry::from_env()?); let engine = Engine::new(graph).with_services(services);
let mut run = engine.run(RunInput::new().input("name", "Ada")); while let Some(event) = run.next().await { match event { Event::NodeChunk { chunk, .. } => print!("{chunk}"), Event::RunSucceeded { outputs, .. } => println!("\n{outputs:?}"), Event::RunPaused { snapshot, .. } => { /* persist snapshot.to_json()? and resume later */ } _ => {} } } Ok(())}Custom nodes, services, model providers and native tools are covered in docs/embedding.md.
Security model
Section titled “Security model”| Concern | Default |
|---|---|
| Secrets | secret values are masked in events, logs, Debug and templates; env.* is never written to snapshots. Plaintext is only exposed to nodes that must transmit it (HTTP auth, code inputs). Node error messages are scrubbed of every secret the run knows (and provider errors of the request’s credentials); strings a code node returns that contain a secret become secrets again. |
| Network egress | Every workflow-controlled URL (http-request, file downloads) resolves DNS itself, rejects loopback/private/link-local/unique-local/CGNAT/cloud-metadata addresses (in any IP notation, including IPv4-embedding IPv6 forms), connects only to the checked addresses and re-checks every redirect. --allow-private-network opts out. |
| Templates | {{#…#}} placeholders are parsed once; resolved values are never re-parsed (no prompt/template injection). Jinja runs without filesystem access, with a fuel budget and output cap. |
| Code | QuickJS on its own stack-sized thread with memory, stack and time limits that workflows can only lower (and never switch off), no filesystem, network, environment, timers or modules; a fresh runtime per execution. |
| MCP | stdio servers start with an empty environment plus an explicit allow-list; every call has a timeout; tools can be allow-listed. |
| Plugins | Process plugins start lazily with an empty environment plus the variables their manifest lists, optional checksums verified before every start, per-request timeouts and message size caps; secrets are masked unless the manifest asks for them. WebAssembly plugins run in an interpreter with fuel and memory limits and no system imports; outbound HTTP only when the manifest asks for network, through the egress policy above, without redirects. A plugin can never replace a built-in or another plugin’s node kind. |
| Server | Optional bearer auth (constant-time comparison); without a key, a loopback server only accepts loopback Host names (DNS rebinding). Body and upload limits, a cap on concurrently executing runs (--max-active-runs), no CORS, env values cannot be set by requests. Per-user credentials mapped from headers (--input-header) are secrets, never stored or logged in plaintext; --verify-jwt verifies them as JWTs (a valid token may only start runs and rate its own runs) and --user-rate-limit limits each user. Webhooks verify HMAC-SHA256 signatures in constant time with a replay window; completion callbacks are signed and go through the egress policy. |
| Limits | Step budget, run duration, per-node timeouts, container depth, iteration/loop caps. |
The threat model, sandbox limits, egress rules and deployment knobs are in docs/security.md; how to report a vulnerability is in SECURITY.md.
Privacy: usage telemetry
Section titled “Privacy: usage telemetry”The graphrt binary has opt-in anonymous usage telemetry, off by
default. Nothing is sent unless you run graphrt telemetry enable (or set
GRAPHRT_TELEMETRY=1), and never when DO_NOT_TRACK is set, in CI, or when
the build has no telemetry endpoint. graphrt telemetry status prints exactly
what would be sent; graphrt telemetry disable turns it off and deletes the
local id and counts.
When on, at most one report a day contains only: a random install id, the
graphrt version, OS and CPU architecture, the compiled features, the build
(cli or docker), and per-day counts of runs and serve requests. It never
contains workflows, inputs, outputs, file paths, host names or IP addresses.
The embedded and FFI libraries contain no telemetry, and builds without the
telemetry feature (such as the small-device server build) contain none
either. Details: docs/telemetry.md.
Binary size
Section titled “Binary size”Measured with cargo build -p graphrt-cli --profile min-size (opt-level z, LTO, stripped, unwinding kept so a panicking node fails only that node) on x86_64 Linux:
| Features | Size |
|---|---|
core only (--no-default-features) |
2.9 MiB |
llm, http, code, python, mcp, serve |
8.2 MiB |
+ plugins, wasm |
9.7 MiB |
default (+ doc, rag) |
12.2 MiB |
In-process embedding models (local-embed, on by default since 0.2.0) add
about 2.1 MiB (measured on macOS arm64: 10.3 MiB → 12.4 MiB);
models themselves are downloaded on first use, not bundled. A server build for
small devices, --no-default-features --features llm,http,wasm,serve, is
6.3 MiB as a static aarch64 musl binary (6.2 MiB for 32-bit ARMv7).
End-user JWT verification for serve (jwt, on by default) adds about
33 KiB: it reuses the ring and reqwest crates already linked for TLS.
Evaluation (eval for graphrt eval, online-eval for serve --evaluators)
is opt-in: cargo install graphrt-cli --features eval,online-eval. The release
binaries, Homebrew formula and GHCR image are built with both.
Every feature is optional: build only what a deployment needs.
Performance
Section titled “Performance”Runtime overhead only: every model call goes to an in-process mock, so these
numbers exclude providers and the network. Apple M-series laptop (11 cores),
bench/run.sh; raw data in bench/results (2026-11-19-Bima-Pangestu
for 0.2.0, 2026-11-19-Bima-Pangestu-0.3.0 for 0.3.0). The server and CLI rows
compare the two release binaries side by side in one session (static musl,
Linux arm64 container, 1 CPU, median of 3 rounds); absolute numbers move with
machine load, the ratio is what to read.
docs/benchmarks.md has the methodology and Linux x86_64 numbers.
| What | 0.2.0 | 0.3.0 |
|---|---|---|
| Scheduling per node, 1,000-node chain | 0.80 µs | 0.35 µs |
| Scheduling per node, 1,000-way fan-out / fan-in | 1.04 µs | 0.47 µs |
| Template node, per node (100-node chain) | 1.39 µs | 0.80 µs |
| Allocations per node, noop chain | 12.2 | 4.1 |
| First streamed chunk, engine overhead | 9.7 µs | 5.8 µs |
| 1,000 concurrent instant runs | 205k runs/s | 289k runs/s |
graphrt run hello.yaml, start to exit |
7.5 ms | 7.3 ms |
graphrt serve, synchronous runs, 1 CPU |
13,837 req/s | 15,540 req/s |
graphrt serve, streaming (SSE) runs, 1 CPU |
2,996 req/s | 7,639 req/s |
Behind graphrt gateway (Linux arm64, static musl): ~0.24 ms added to the
first byte of a warm run, a cold local agent in 5–13 ms (p95), 1,000 concurrent
streams in ~45 MiB of gateway memory; bench/targets.sh checks every gateway
target against bench/budgets.toml
(numbers).
On small devices (Linux arm64, cgroup limits), the 6.3 MiB server build serves a 3-node workflow at ~600 requests/s on a quarter of a core with ~3.4 MiB of steady memory, and stays up under a 16 MiB limit at a tenth of a core (details).
Against LangGraph 1.2 (CPython 3.11, async, tracing off) on the same laptop, both calling one local OpenAI-compatible test server: a 3-node LLM workflow cold-starts in 5 ms vs 728 ms with 13 vs 101 MiB peak RSS, orchestration costs ~0.4 µs vs ~100–200 µs per node, and with 50 ms model latency 1,000 concurrent runs reach ~17k vs ~210 runs/s. With one run in flight against a slow model the stacks are within ~20% of each other, since model latency dominates (methodology and caveats).
Architecture
Section titled “Architecture”graphrt-core graph model, variable pool, templates, conditions, engine, events, snapshots, built-in control nodes, tool contract (wasm-friendly)graphrt-llm chat model abstraction, OpenAI-compatible, Anthropic, Gemini, Bedrock, llm / agent / classifier / extractor nodesgraphrt-http http-request node and egress policygraphrt-code code node (QuickJS) and remote sandbox hookgraphrt-mcp MCP tool providergraphrt-doc document-extractor node (PDF, Office, HTML, EPUB, e-mail...)graphrt-rag knowledge-retrieval node, stores, embedders, ingestiongraphrt-plugin process / HTTP plugin host; graphrt-wasm: sandboxed WebAssembly pluginsgraphrt-bundle portable .grt bundles; graphrt-otel: OpenTelemetry exportgraphrt-eval eval harness: test suites, assertions, trajectories, retrieval metrics, CI gategraphrt-ffi Kotlin / Swift bindings for Android and iOSgraphrt-gateway always-on front of scale-to-zero agents: run store, auth, limits, wakegraphrt-provider-api Provider / DeployDriver traits, shared provider HTTP, conformancegraphrt-provider-k8s Kubernetes; graphrt-provider-aws: ECS, Lambda; graphrt-provider-fly: Flygraphrt-provider-azure Azure Container Apps; graphrt-gcp: GCP auth, Cloud Rungraphrt-cli `graphrt` binary: run, validate, inspect, serve, eval, kb, plugin, bundle, gateway, deployRead docs/architecture.md for the scheduling rules, failure policies, containers and pause/resume design.