Skip to content

Patterns

Complete runnable examples in examples/. Each demonstrates a different combination of core concepts.

Reflection Loop

Generate, critique, and revise in a loop with automatic revision caps. Demonstrates multi-subscription (@on(WriteRequested, CritiqueReceived)) for revision cycles, union return types for branching, and the Auditable trait for automatic logging.

ReAct Agent with Message Reducer

Tool-calling agent with incremental message history. Demonstrates message_reducer() for automatic LangChain message accumulation, MessageEvent for typed message wrapping, and a multi-subscription loop (@on(UserMessageReceived, ToolsExecuted)) that drives the ReAct cycle.

Multi-Agent Supervisor

Supervisor routes tasks to specialist agents and aggregates context. Demonstrates a custom Reducer for cross-agent context accumulation, tool-calling for structured routing decisions, and typed events for supervisor-to-specialist communication — no manual subgraph wiring.

Fan-Out / Fan-In (Map-Reduce)

Parallel document summarization with batch splitting and completion detection. Demonstrates Scatter for fan-out to multiple work items and EventLog.filter() for gather/completion detection with a duplicate-harmless pattern.

Human-in-the-Loop Approval

Pause execution for human approval and resume with typed events. Demonstrates Interrupted for pausing the graph, graph.resume() with domain events, and revision cycles driven by human feedback. Requires a checkpointer (MemorySaver).

Content Pipeline

Safety gates with early termination and live event streaming. Demonstrates Halted for safety-based graph termination, async streaming with astream_events(), EventLog.has() for existence checks, and keyword-based classification (no LLM required).