Global first
Write the coordination once as a protocol instead of scattering it across agent prompts and callbacks.
Global protocols for multi-agent LLM systems
ZipperGen is a Python DSL and runtime for structured multi-agent LLM coordination. Write one global protocol describing messages, actions, and decisions; ZipperGen projects it onto each agent and runs the result concurrently.
Core projection theorems machine-checked in Lean 4.
Write the coordination once as a protocol instead of scattering it across agent prompts and callbacks.
Each lifeline receives the local program it needs: sends, receives, owned decisions, tool calls, and optional human control points.
If the workflow compiles, the coordination layer is structurally deadlock-free by construction.
Tiny workflow
The annotation @ Editor says that Editor owns the decision. ZipperGen
generates the control communication needed by the other lifelines.
@workflow
def write_tweet(topic: str @ User) -> str:
User(topic) >> Writer(topic)
Writer: tweet = draft(topic)
Writer(tweet) >> Editor(tweet)
Editor: approved = approve(tweet)
if approved @ Editor:
Editor(tweet) >> User(tweet)
else:
Editor(tweet) >> Writer(tweet)
Writer: tweet = revise(tweet)
Writer(tweet) >> User(tweet)
return tweet @ User When locally received data can be stale, guards can read the latest causally visible state instead of a sequential log. Vector clocks and message-carried views make the guard result depend on the asynchronous communication structure.
latest_device_on = Y[Device](
atom(lambda env: env.get("on", False), src="on")
)
if latest_device_on @ Indicator:
... Co-regions let a receiver accept independent messages in whichever order they arrive, while preserving FIFO order on each channel.
with coregion:
Analyst_A(a) >> Collector(a_report)
Analyst_B(b) >> Collector(b_report) Try it locally
The built-in mock backend returns placeholder model outputs, so examples can be run without API keys. Switch to OpenAI, Mistral, or Claude with one configuration line when you want real model calls. ZipperGen can also use OpenAI-compatible local model servers such as vLLM; the repository includes a small local Qwen/vLLM example.
git clone https://github.com/zippergen-io/zippergen.git
cd zippergen
pip install -e .
python examples/coregion.py
python examples/cpl_test.py
python examples/write_tweet.py Formal foundation
The projection from a global protocol to per-agent local programs is syntax-directed, and deadlock-freedom follows by structural induction; no runtime checking required. The core theorems are in the paper and machine-checked in Lean 4.
Bollig, Függer, Nowak. Provable Coordination for LLM Agents via Message Sequence Charts. arXiv:2604.17612 [cs.PL]
Start from the examples, inspect the generated message sequence chart, and decide whether global protocols fit your agent system.