Reactive Agents uses a layered, composable architecture built on Effect-TS.
Kernel structure
Section titled βKernel structureβThe reasoning kernel was reorganized in v0.10 to group code by capability. If youβre contributing or reading the source, this is the layout:
Directorypackages/reasoning/src/kernel/
Directorycapabilities/
Directoryact/ tool execution, gating, parsing, healing pipeline
- β¦
Directoryattend/ context utils + tool formatting
- β¦
Directorycomprehend/ task intent
- β¦
Directorydecide/ arbitrator (single-owner termination)
- β¦
Directoryreason/ think Β· think-guards Β· stream parser
- β¦
Directoryreflect/ loop detector Β· reactive observer Β· strategy evaluator
- β¦
Directorysense/ step utils
- β¦
Directoryverify/ evidence grounding Β· quality utils Β· verifier
- β¦
Directoryloop/
- runner.ts main 12-phase orchestrator
- react-kernel.ts ReAct strategy kernel
- terminate.ts single-owner termination helper
- auto-checkpoint.ts
- output-assembly.ts
- output-synthesis.ts
Directorystate/ kernel-state Β· kernel-hooks Β· kernel-constants
- β¦
Directoryutils/ diagnostics Β· ICS coordinator Β· lane controller
- β¦
The single-owner termination invariant (M9 mechanism, 100% path coverage) is enforced by kernel/loop/terminate.ts plus a CI lint guard at scripts/check-termination-paths.sh β no path bypasses the arbitrator.
The meta-loop
Section titled βThe meta-loopβInternally the reasoning harness is a one-directional loop β a small DAG where each stage reads only from the stage before it, with no back-edges. This is what makes a runβs decisions replayable: given the same ledger, every downstream read is a pure function.
Contract β Ledger β Assessment β Control β Actuators β Projector| Stage | Role |
|---|---|
| Contract | The typed goal β βwhat does DONE mean for this run?β Compiled once at run start from the task (plus any declared .withContract()) and then frozen: requirements, deliverables, constraints, horizon, acceptance policy. |
| Ledger | The append-only event store everything else projects from β tool invocations, artifacts (path + content digest), verifier verdicts, evidence claims (twelve fact families). It is the single source of run history and rides crash-resume. Full entry taxonomy + honest-compaction rules: The evidence ledger. |
| Assessment | A pure, per-iteration read of where the run stands, derived from contract Γ ledger: requirements satisfied/outstanding, deliverables produced/missing, evidence delta, run phase (orient / gather / execute / synthesize / verify), pace band, health. Emitted as an AssessmentEmitted trace event every iteration. Default-on; opt-in levers (.withLongHorizon() / .withAdaptiveHarness()) only react to it. Field-by-field: Run assessment. |
| Control | One proposal β resolver that picks a single action per iteration from a documented total order (continue, nudge, switch strategy, redirect, escalate, terminate). No two subsystems race to steer the loop. |
| Actuators | The effects that carry out the chosen action β guards, strategy switch, the terminal gate (which consults contract requirement satisfaction against the ledger). |
| Projector | The single authority that renders the prompt window each turn β deciding what context, references, and outstanding requirements the model sees. One reference grammar is shared by the projector, the recall gate, and step references, so every reference rendered into the prompt is resolvable via recall(...). |
Each subsystem is fenced by a grep-able enforcement script in scripts/, so a change that reintroduces a back-edge (e.g. Assessment reading loop state directly, or a second termination owner) fails CI rather than drifting silently. The receiptβs deliverables[] and the rax diagnose replay view are both projections of this same ledger.
Layer Stack
Section titled βLayer Stackβ βββββββββββββββββββββββββββ β ReactiveAgentBuilder β Public API ββββββββββββββ¬βββββββββββββ β ββββββββββββββΌβββββββββββββ β ExecutionEngine β 12-phase lifecycle ββββββββββββββ¬βββββββββββββ β βββββββββββββββββββββββββΌββββββββββββββββββββββββ β β β ββββββΌβββββ βββββββΌββββββ βββββββΌββββββ β Memory β β Reasoning β β Tools β β (L2) β β (L3) β β (L8) β ββββββ¬βββββ βββββββ¬ββββββ βββββββ¬ββββββ β β β ββββββΌβββββββββββββββββββββββββΌββββββββββββββββββββββββΌβββββ β LLM Provider (L1.5) β ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ β ββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββ β Core Services (L1) β β EventBus Β· AgentService Β· TaskService β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββOptional Layers
Section titled βOptional LayersβThese can be enabled independently:
| Layer | Package | What It Does |
|---|---|---|
| Guardrails | @reactive-agents/guardrails | Input/output safety |
| Verification | @reactive-agents/verification | Fact-checking, semantic entropy |
| Cost | @reactive-agents/cost | Model routing, budget enforcement |
| Identity | @reactive-agents/identity | Agent certificates, RBAC |
| Observability | @reactive-agents/observability | Tracing, metrics, logging |
| Interaction | @reactive-agents/interaction | 5 autonomy modes |
| Prompts | @reactive-agents/prompts | Template engine |
| A2A | @reactive-agents/a2a | Agent-to-Agent protocol (JSON-RPC, Agent Cards, SSE) |
| Gateway | @reactive-agents/gateway | Persistent autonomous harness: heartbeats, crons, webhooks, policy engine |
| Reactive Intelligence | @reactive-agents/reactive-intelligence | Entropy sensor, reactive controller, local learning, optional telemetry; integrates with kernel + EventBus |
Dependency Graph
Section titled βDependency GraphβCore β LLM Provider β Memory β Reasoning β Tools
Core β Guardrails (standalone) β Verification (standalone) β Cost (standalone) β Identity (standalone) β Observability (standalone) β Interaction (needs EventBus) β Orchestration (standalone) β Prompts (standalone) β A2A (needs Core + Tools) β Gateway (needs Core EventBus)How Layers Compose
Section titled βHow Layers ComposeβEvery layer is an Effect Layer β a recipe for building a service. Layers compose through Layer.merge and Layer.provide:
import { createRuntime } from "@reactive-agents/runtime";
// The runtime composes all enabled layers into a single Layerconst runtime = createRuntime({ agentId: "my-agent", provider: "anthropic", enableGuardrails: true, enableReasoning: true, enableCostTracking: true,});
// This Layer provides ALL services needed by the ExecutionEngineThis means:
- No singletons β Each agent gets its own service instances
- No global state β Everything is scoped to the Layer
- Testable β Swap any layer with a test implementation
- Tree-shakeable β Disabled layers arenβt loaded