agent runtime · completion-driven

Replan on every completion.
Not on the barrier.

LoopKernel is an agentic AI runtime built as a dynamically patched task graph. The planner wakes on the first durable completion — while sibling tasks are still running — and mutates the graph with one auditable GraphPatch at a time.

loopkernel · run 7f3a — live graph

// the one-sentence version

A dynamically patched task graph whose materialized SQLite state is paired with a durable outcome-and-patch journal — replanned one completion at a time. No supersteps. No shared-state barriers. Every decision journaled.

// architecture

Four choices worth internalizing

01 first_completed

No barriers

Execution wakes on asyncio.wait(FIRST_COMPLETED) — the planner runs after each durable completion while siblings are still active. No wave-wide synchronization, no waiting for the slowest branch before reacting.

02 graph_patch

Emergent topology

Per-run topology isn't compiled up front — it emerges. For each event the planner returns a GraphPatch: add · connect · cancel · wait · resume · finish. The store rejects duplicate IDs, invalid transitions, and cycles.

03 evidence_scope

Scoped evidence

Results stay attached to the task that produced them. Tasks marked evidence_scope: "ancestors" see only their transitive graph ancestors — so a cancelled speculation can never leak into the final answer.

04 journaled

Durable by design

SQLite materializes runs, nodes, and edges alongside ordered events and idempotent patch records. On resume, terminal events without a patch are replayed and planned exactly once. Finished work stays finished.

// capabilities

Application guarantees, not framework homework

Behaviors most graph frameworks leave to workflow authors are built into the runtime and tested there.

speculation

Quorum with in-flight cancellation

Run three researchers; when two stable winners land, the loser is durably cancelled — while still running — and its late result is discarded.

hitl

Waits between attempts

A pending node enters WAITING; the executor exits cleanly. A trusted external event applies a resume patch — no node restarts, no re-run side effects.

control flow

Deterministic by default

A deterministic planner drives routing. An opt-in LLM planner may propose patches — strictly parsed, allowlisted roles only, deterministic fallback on invalid output.

memory

Provenance-first memory

Typed, bounded evidence with source attribution. User facts keep their SourceRef; external pages are never represented as user statements.

authority

Closed skill registry

Every task's skill must resolve in the worker registry. The graph can grow dynamically, but the authority surface stays closed.

credentials

Gateway model boundary

All model access flows through a separate gateway. The runtime never owns provider credentials — a tested boundary, not a convention.

// the loop

One event in, one patch out

The planner receives (snapshot, event) and emits the next graph mutation. Each patch is idempotent and journaled against its triggering event — replay-safe by construction.

journal · run 7f3a
# event → planner → patch (illustrative trace)
event  task_completed plan_0
patch  add spec_1 spec_2 spec_3
       connect plan_0spec_*

event  task_completed spec_2   # siblings still running
patch  wait

event  task_completed spec_1   # quorum 2/2
patch  add distill
       connect spec_1 spec_2distill
       cancel spec_3            # in flight

event  task_completed distill
patch  finish

Illustrative trace of LoopKernel's patch semantics — public API docs are on the way.

// positioning

Not a smaller LangGraph

The two runtimes solve the same broad problem and make substantially different architectural choices. The honest version, side by side:

DimensionLangGraphLoopKernel
Execution Pregel supersteps — updates visible at the next barrier Replans on first completion, siblings still active
Topology Compiled StateGraph with runtime routing Emergent — planner patches the graph per event
History Checkpointed shared-state snapshots Materialized state + outcome/patch journal
See the full comparison →