Architectures
The agent loop is a strategy. The default is ReAct. Observe / think /
act. And works for most things. When it doesn’t fit, swap it with one
kwarg; everything else (model, memory, tools, budget, telemetry,
runtime) stays exactly the same.
from loomflow import Agent
agent = Agent("...", model="claude-opus-4-7") # ReAct (default)
agent = Agent("...", model="...", architecture="self-refine") # iterate until critic happy
agent = Agent("...", model="...", architecture="reflexion") # verbal RL with lessons
agent = Agent("...", model="...", architecture="plan-and-execute") # plan once, execute steps
agent = Agent("...", model="...", architecture="rewoo") # plan + parallel tools, 30-50% cheaper
agent = Agent("...", model="...", architecture="tree-of-thoughts") # BFS beam over candidate thoughtsFor multi-agent shapes (Supervisor, Swarm, Router, Debate,
ActorCritic, Blackboard) use the Team facade
or pass the architecture instance directly:
from loomflow import Agent
from loomflow.architecture import Supervisor
agent = Agent(
"manage the pipeline",
model="claude-opus-4-7",
architecture=Supervisor(workers={
"researcher": researcher,
"writer": writer,
}),
)Single-agent loops
{En} placeholders. 2 LLM calls + N tools.ReWOOMulti-agent teams
delegate tool. Parallel delegation.SupervisorN debaters argue across rounds; optional judge synthesizes.Multi-Agent DebatePeer agents handing off via a handoff tool. No central coordinator.SwarmShared workspace; coordinator picks who acts next; decider says when done.BlackboardHigher-order
name, run, declared_workers. Three methods.Custom architecturesWhen to use what
| You need… | Use | Cost relative to ReAct |
|---|---|---|
| The default that just works | ReAct | 1× |
| Cheaper multi-step that knows the plan upfront | Plan-and-Execute | 0.5–0.7× |
| Cheaper tool-heavy with parallelizable steps | ReWOO | 0.4–0.6× |
| Iterative quality improvement, single model | Self-Refine | 1.5–3× |
| Cross-attempt learning (“don’t repeat that mistake”) | Reflexion | 1.5–3× |
| Best-of-N with a different-model critic | ActorCritic | 2–4× |
| Combinatorial / puzzle / planning | Tree of Thoughts | 5–10× |
| Cheapest classify-and-dispatch | Router | 1.2× |
| Hierarchical worker delegation | Supervisor | 2–4× |
| High-stakes contested questions | Multi-Agent Debate | 3–5× |
| Exploratory / research-mode handoffs | Swarm | 2–4× |
| Shared-workspace collaboration | Blackboard | 3–5× |
The architecture protocol. Every architecture implements three
methods: name, run, declared_workers. The Agent calls
architecture.run(session, dependencies) and consumes the events it
yields. Setup and teardown stay in Agent; architectures focus on
their own iteration. See Custom architectures.
Standalone testing
run_architecture(arch, prompt, model=...) builds a minimal Agent
shell around any Architecture and runs it. Useful for testing
orchestrators in isolation:
from loomflow.architecture import Supervisor
from loomflow.team import run_architecture
sup = Supervisor(workers={"a": agent_a})
result = await run_architecture(sup, "do the thing", model="claude-opus-4-7")