Coordination infrastructure
for multi-agent AI

Like threading libraries for concurrent programming — but for AI agents. State Contracts, Circuit Breakers, and Pipeline orchestration that make multi-agent systems reliable.

$ npm install @heybeaux/lattice-core

95%

Benchmark accuracy (real L3)

0

Workflow failures

627ms

L2 mean latency

50

Real topics benchmarked

The Problem

Multi-agent AI systems fail at alarming rates — not because the models are bad, but because there's no infrastructure for coordination.

41–87%
Failure rates across multi-agent frameworks
(UC Berkeley MAST, 1,600+ traces)
40%
Of agentic AI projects predicted cancelled by 2027
(Gartner, 2026)
15%
Of enterprises prepared for agentic AI in production
(Fivetran Readiness Index, May 2026)

The Primitives

Lattice provides the coordination primitives that make multi-agent systems reliable. Structural solutions for structural problems.

State Contracts

Typed envelopes that travel between every agent handoff — carrying inputs, decisions, outputs, constraints, and assumptions. Full lineage for every action.

Circuit Breakers

Tiered validation: L1 (structural), L2 (semantic similarity), L3 (LLM-as-judge). Catches failures before they cascade downstream.

Pipeline Builder

Compose sequential agent handoffs with built-in coordination. Abort, retry, or degrade on failure — your choice.

Redaction

Automatic PII scrubbing before logging. API keys, tokens, emails, phone numbers — cleaned while preserving audit structure.

EventEmitter

Typed coordination events for every contract emission, validation, and circuit state change. Hook into your monitoring stack.

wrapAgent()

Wrap any agent function — sync or async — to get State Contracts and validation for free. No framework changes needed.

How It Works

Three lines to wrap an agent. Full coordination from there.

pipeline.ts TypeScript
import { pipeline, HandoffFailure } from '@heybeaux/lattice-core';

const p = pipeline()
  .agent('researcher', researchFn, { breaker: { tier: 'L1+L3' } })
  .agent('writer', writeFn, { breaker: { tier: 'L1' } })
  .agent('editor', editFn, { breaker: { tier: 'L1' } })
  .onReject('retry', { maxRetries: 2 })
  .build();

try {
  const result = await p.execute({ query: 'AI coordination' });
  console.log(result.output);       // final editor output
  console.log(result.contracts);    // State Contracts from each agent
  console.log(result.hadRejected);  // any rejections?
} catch (err) {
  if (err instanceof HandoffFailure) {
    console.error(err.validation.reason);  // why it failed
    console.error(err.contract);           // full audit trail
  }
}

Benchmark Results

16 fault scenarios across a 4-agent research pipeline. No API keys needed.

═══ Results ═══ ✅ agent_throws [L1] Agent threw exception ✅ agent_throws_extract [L1] Agent threw exception ✅ agent_throws_validate [L1] Agent threw exception ✅ api_key_leak_summarize [redaction] ✅ api_key_leak_extract [redaction] ✅ api_key_leak_format [redaction] ⚪ hallucination_summary (needs L3) ⚪ hallucination_citations (needs L3) ⚪ hallucination_conclusion (needs L3) ⚪ hallucination_data (needs L3) ⚪ empty_output (needs L3) ⚪ missing_field (needs L3) ⚪ wrong_shape (valid contract, bad content) ⚪ null_output (valid contract, bad content) ⚪ extra_field (valid contract, bad content) ⚪ wrong_type (valid contract, bad content) L1 detection: 100% (structural — 400/400) Redaction: 100% (PII scrubbing — all topics) L3 detection: 92.1% (222/241 — gpt-4o-mini, REAL API) False positive: 0% (0 pipelines crashed) L2 latency: 627ms mean, 9.0s p95 (only 100 runs — 150 skipped) Avg latency: 25.4s L3 mean, 627ms L2 mean (escalation working)

Packages

Three packages, one ecosystem. Start with core, add providers and adapters as needed.

@heybeaux/lattice-core
State Contracts, Circuit Breakers, Pipeline builder, EventEmitter, Redaction. The foundation.
npm →
@heybeaux/lattice-provider-openai
L2 embeddings via text-embedding-3-small. L3 LLM-as-judge via gpt-4o-mini. Out of the box.
npm →
@heybeaux/lattice-adapter-mastra
Wrap Mastra workflow steps with Lattice coordination. Bridge to the heybeaux/Forge ecosystem.
GitHub →

Build reliable agent systems

Install Lattice, wrap your agents, and see failures before they cascade.