Skip to content
Agent Algebra

Agent Algebra

An agent is a compositional computational process.

A 5-part series and a reference implementation give agents one algebra: sequencing, choice, parallel composition, recursion, supervision, checkpointing and human approval, each a well-defined operator with laws proved in the papers and checked against a deterministic code layer.

5 parts · 37 laws and counterexamples checked in code

Papers

An Algebra of Agents preview
Synthesis28 pages

An Algebra of Agents

Agent systems are assembled from a small vocabulary of loops, handoffs, retries, supervisors, approval steps and policies, and each item in that vocabulary has a mature theory in a different field. The five Parts of this series give all of them one mathematical object and prove, for each construc...

Agents as Effectful Mealy Coalgebras preview
Part I25 pages

Agents as Effectful Mealy Coalgebras

An agent, in the sense used by actor systems, workflow engines, control loops and language-model tool loops, is usually specified by a diagram and a runtime rather than by a mathematical object. This Part fixes the object. An agent is a coalgebra of the functor F(S) = (Y + E + 1) times (T(Sigma t...

Laws of Agent Composition preview
Part II28 pages

Laws of Agent Composition

We give an equational account of how agents compose. Fixing the agent object of Part I, an effectful Mealy coalgebra with typed termination and with failure as a terminal outcome, we define the composition signature: sequential composition with its unit and its diverging zero, immediate failure,...

Channels, Actors, and Shared State preview
Part III29 pages

Channels, Actors, and Shared State

Agents that interact do so through wires: feedback loops, message queues, shared stores, and the approval channel that connects a system to a person. This Part fixes the wiring layer of an algebra of agents whose object and operators are settled in Parts I and II. A single feedback operator with...

Failure, Supervision, and Durable Execution preview
Part IV28 pages

Failure, Supervision, and Durable Execution

Agent runtimes crash, retry, checkpoint and replay, and their behaviour is usually described by an implementation rather than by an algebra. This Part supplies the execution layer for the agent algebra of the preceding Parts. An execution model is a class of scheduler agents together with a fail-...

Policies, Planning, and Feedback Control preview
Part V25 pages

Policies, Planning, and Feedback Control

Artificial intelligence and control present decision making in separate formalisms: Markov decision processes for reinforcement learning, AND/OR transition systems for planning under nondeterminism, belief states for partial observability, safety games for shields, and difference equations for fe...

One term, built from Parts I through IV

Every operator in the running example is introduced by exactly one Part and composes with every operator introduced elsewhere.

Gate_H(Sup(μX.(A ⊕ X)) ; (B ⊗ C)), the running example composed from Parts I through IVGate_H;SupμAXBC
Part I — agent, leavesPart II — ; ⊕ ⊗ μPart III — Gate_HPart IV — Sup

Laws checked in code

Each row cites the paper's claim, the Part that proves it, the kind of check, and the test that runs it.

37 laws and counterexamples, checked by the reference implementation in code/agent-algebra
LawPartCheckTest
thm:agent-object:quotient (decidability half)Part Ifinite-model checkpartition refinement agrees with brute-force bisimulation on random Id, P and D agents
thm:agent-object:bisim-implies-tracePart Ifinite-model checkbisimilar random pairs are finite-trace equivalent
thm:agent-object:greatest-invariantPart Iexhaustive bounded checkthe gfp iteration returns an invariant containing every enumerated invariant inside Phi
thm:agent-object:quotient (minimality half)Part Ifinite-model checkA/~ is bisimilar to A and has no two bisimilar states
prop:agent-object:closed-loop-markovPart Iexhaustive bounded checkRun(A,E) for T = D is row-stochastic and equals the product-kernel formula
thm:agent-object:final-mealy-idPart Ifinite-model checkfor T = Id the bisimulation and trace-equivalence decisions agree on random Mealy machines
prop:agent-object:refinement-preorderPart Ifinite-model checkinserting random stutter ticks gives A refines A' and A' refines A
thm:composition-laws:sequential-categoryPart IIfinite-model checkseq is associative and skip is a two-sided unit up to bisimilarity
thm:composition-laws:gkat-bisimPart IIfinite-model checkevery GKAT axiom holds up to bisimilarity on random deterministic agents
thm:composition-laws:kat-acceptedPart IIexhaustive bounded check (one designed witness)left distributivity of seq over nondeterministic choice fails up to bisimilarity on the fixed witness
thm:composition-laws:monoidalPart IIfinite-model checktensor is associative, commutative and unital up to bisimilarity
cex:composition-laws:exchange-failsPart IIexhaustive bounded checkthe one-tick versus two-tick exchange witness gives different traces
thm:composition-laws:unique-solutionsPart IIfinite-model checkk-fold unrolling of a guarded recursion is bisimilar to the loop-state implementation
prop:composition-laws:recover-lawsPart IIfinite-model checkrecover is associative with skip and fail units, and race is associative and commutative up to bisimilarity
thm:interaction-coordination:delayed-tracePart IIIfinite-model checknaturality, vanishing and superposing hold up to bisimilarity on random agents
prop:interaction-coordination:closed-loop-is-tracePart IIIfinite-model checkRun(A,E) is bisimilar to Tr((A tensor E) ; swap) on random pairs
thm:interaction-coordination:shufflePart IIIfinite-model check (100 random component pairs and quadruples) plus one fixed strictness witnessthe bounded trace set of asyncPar equals the shuffle of the component trace sets
thm:interaction-coordination:actor-localityPart IIIfinite-model checkactor state is a function of init and the dequeued message sequence across 1000 schedules
prop:interaction-coordination:blackboard-linearizablePart IIIexhaustive bounded checkthe linearizability checker accepts every blackboard history and rejects a replicated-blackboard history
prop:interaction-coordination:tuplespace-nondeterministicPart IIIexhaustive bounded checktuple-space competition yields at least two outcomes while a FIFO link yields exactly one
thm:interaction-coordination:binary-deadlock-freedomPart IIIfinite-model checkrandom dual-typed pairs never deadlock within the tick budget and an ill-typed pair does
thm:interaction-coordination:gate-refinementPart IIIexhaustive bounded checkGate with an always-ok oracle equals A modulo stutters and a rejected action never appears
thm:execution-semantics:replay-determinismPart IVfinite-model check (1000 seeds)replay of a logged stochastic run reproduces the state trajectory and outputs on 1000 seeds
thm:execution-semantics:kahn-determinismPart IVfinite-model check, bounded fragment only (finite-capacity channels with `k` ≥ the tick budgetrandom DAG workflows give identical outputs under 100 fair schedulers
thm:execution-semantics:supervision-refinementPart IVexhaustive bounded checksupervision with Persist every tick refines the crash-free run up to stuttering after erasing crash and restart markers
thm:execution-semantics:effectively-oncePart IVexhaustive bounded checkretry against an environment idempotent on the dedup key ends in the crash-free environment state
prop:execution-semantics:timeoutPart IVfinite-model checktimeout_t(A) halts or fails by tick t+1 for every A
prop:execution-semantics:persist-commutesPart IVfinite-model checkPersist commutes with seq up to bisimilarity on small agents
prop:execution-semantics:series-parallel-shapePart IVfinite-model checkthe recognizer accepts every tensor/seq term DAG and rejects the N-DAG
prop:execution-semantics:restart-budgetPart IVfinite-model checkdead-state entry coincides with budget exhaustion under random crash sequences
prop:decision-control:llm-is-agentPart Vfinite-model check (100 random kernels)the seeded mock-LLM ReAct mu-term is bisimilar to a hand-written loop
thm:decision-control:closed-loop-valuePart Vfinite-model check (Monte Carlo, stated tolerance)Monte-Carlo value of A ; B matches the option-level Bellman computation within tolerance
thm:decision-control:belief-agentPart Vexhaustive bounded check (Bayes)belief update equals brute-force Bayes and DP value equals Monte-Carlo closed-loop value
thm:decision-control:shield-adversarialPart Vfinite-model checkshielded random policies produce 0 gridworld violations while unshielded produce more than 0
prop:decision-control:planning-solution-notionsPart Vexhaustive bounded checka strong-cyclic mu-plan reaches the goal under all fair schedulers and a weak plan fails on some
prop:decision-control:linear-stability | src/linear.ts spectralRadiusPart VOn over 300 random real triples (the borderline band where `ρ − 1
prop:decision-control:gate-is-shieldPart Vexhaustive bounded checkGate with a safety-oracle human and the shielded agent have the same marker-erased, stutter-collapsed traces