Reflex

A local, ultra-fast "System 1" decision runtime for AI agents.
Agents use frontier models for hard reasoning, and also for hundreds of tiny decisions: which tool next, search or not, read another file, retry, which model tier, stop? Reflex makes those micro-decisions locally in microseconds to milliseconds, returns calibrated confidence, executes high-confidence low-risk actions immediately, and escalates everything else to Claude/GPT/Gemini or a human. It learns from outcomes, so each workload converges on its cheapest successful execution policy.
Stop using a hundreds-of-billions-of-parameters reasoning model to make a three-option decision.
npm install @reflex-ai/core # zero-dependency runtime
npx @reflex-ai/cli init # optional CLI: init · stats · train · serve · mcp · bench
Website: https://getreflex.pages.dev/ · Docs: Getting started · Concepts · Configuration · API · Integrations · Benchmarks · FAQ · Product spec (PRD)
agent state ──▶ REFLEX ladder (stops at the first confident tier)
0 kill switch / mode <0.1 ms
1 rules (force/deny/budget) <0.5 ms
2 exact decision cache <0.5 ms
3 trajectory pattern table <1 ms
4 hashed head + difficulty ~0.02–0.05 ms measured
6 full model (Laya sidecar) ~33–40 ms on GPU (0.8–2.7 s on a laptop CPU)
──▶ AUTO: execute or ESCALATE: frontier / human (+ hints)
──▶ traces ──▶ learn online + `reflex train` ──▶ versioned policy
Results so far (ReflexBench, simulated)
npx reflex bench, 200 tasks per suite, 8 seeds (1, 2, 3, 7, 42, 99, 123, 2026), against an always-frontier baseline on the same tasks:
| Suite | Task success Δ | $ / successful task | Frontier calls / task | Wall-clock / task | Auto-decision precision |
|---|
sim-coding (tests → locate → edit → tests → stop) | 0.0 pp on all seeds | −62.2% to −65.4% | ≈ −62% | ≈ −43% | 100% |
sim-support (FAQ cache / RAG / frontier / human) | 0.0 to −1.0 pp | −1.5% to −4.4% | ≈ −12% | ≈ −8% | 92–100% |
Local decision latency, measured by reflex doctor on a laptop CPU: p50 0.021 ms, p95 0.050 ms (rules → cache → patterns → head).
Honest caveat: these suites are seeded simulations with an always-correct simulated frontier model and modeled costs and latencies. They validate Reflex's mechanics at the agent level: learning from labels, calibration, safe escalation, and credit assignment. They are not evidence of real-world savings. Real-agent benchmarks (SWE-bench-style, τ-bench-style) are the next milestone.
Quickstart (2 minutes, no API key)
git clone https://github.com/1sakshm/reflex && cd reflex && npm install
cd examples
npm run quickstart # shadow mode: Reflex only watches
npm run stats # what it would have done
npm run train # learn + calibrate a policy, promote it if it clears the gate
npm run quickstart -- --auto # Reflex now takes the routine calls
Typical output: shadow mode would have auto-decided 63 of 117 labeled decisions at 100% precision. After train --promote, auto mode handles 89 of 120 decisions locally, with 100% task success. The rest are the genuine reasoning questions, which it correctly escalates, plus one audit sample.
Use it in an agent (TypeScript)
import { action, createReflex } from "@reflex-ai/core";
const reflex = createReflex({ workload: "coding-agent", mode: "shadow" }); // start safe
const actions = [
action.with(action.tool("read_file", { risk: "safe", readOnly: true }), { path: "src/date.ts" }),
action.tool("run_tests", { risk: "costly" }),
action.tool("write_file", { risk: "stateful" }), // never auto-executed unless allowStateful
action.frontier(), // "this step needs real reasoning"
action.stop(),
];