Loom
A Python framework for building agents and workflows that ship.
Two primitives. Agent hands the loop to the LLM.
Workflow keeps you in charge of the graph. They share one spine
for telemetry, audit, and user_id partitioning. Typed outputs,
MCP support, swap models with one kwarg.
import asyncio
from loomflow import Agent, Workflow
# 1) Agent — LLM-controlled loop
billing = Agent("Handle billing.", model="gpt-4.1-mini", tools=[...])
tech = Agent("Handle tech.", model="gpt-4.1-mini", tools=[...])
# 2) Workflow — developer-controlled DAG
async def classify(text: str) -> str:
return (await Agent(
"Reply 'billing' or 'tech'.", model="gpt-4.1-mini",
).run(text)).output
support = Workflow.route(
classify,
{"billing": billing, "tech": tech},
)
async def main():
r = await support.run("My card was charged twice.", user_id="alice")
print(r.output)
print(r.visited) # ['classify', 'route_billing']
asyncio.run(main())Why pick this
- Two primitives, one spine. Agent and Workflow are siblings.
Same telemetry, same audit log, same
user_idpartition no matter which one you pick. Pass an Agent as a Workflow node, or callwf.as_tool()and the workflow becomes a tool the agent can call. user_idis a typed primitive. OneAgentplus oneMemorypartitions cleanly across N tenants. No more “forgot to namespace” data leaks.output_schema=accepts any Pydantic model. The framework appends the schema directive to the prompt, parses the response, validates it, and retries with feedback if the model misses. You get a typed instance back.- Network model adapters get wrapped with a typed error taxonomy and a retry policy. Rate limits, 5xx, network blips don’t blow up your run.
session_idrehydrates prior turns as real chat history. Reuse the same id across processes and the journal replays.- Twelve agent-loop architectures ship behind one
Agentconstructor. One kwarg flips the iteration pattern.
Where to start
15 sections from “hello agent” to a production-shaped 25-line example.QuickstartThe mental model. Read these once and the rest of the docs make sense.ConceptsDeveloper-controlled DAGs. Sugar constructors for chain / route / parallel, plus an explicit graph builder with cycle support.WorkflowThe twelve agent loops. ReAct, Plan-and-Execute, Supervisor, Debate, Swarm, and recursive composition.ArchitecturesAnthropic-format SKILL.md packages with multi-source layering and progressive disclosure.SkillsDocument loaders + vector stores. End-to-end RAG without LangChain.RAGThe @tool decorator, the built-in filesystem and shell tools, and the TodoWrite-style living plan.ToolsA shared notebook for multi-agent teams. Notes, not transcripts. Versioning, semantic search, citation-aware retention.WorkspaceFive backends. Bi-temporal facts. GDPR ops by default.MemoryPer-user budgets, approval handlers, bounded state, secrets, audit log.ProductionCopy-paste patterns for support bots, coding assistants, research agents, and more.RecipesNineteen runnable end-to-end scripts: RAG, debate, memory, six workflow patterns, the effort dial, TOML config, shared workspace, prompt caching, and the living plan.ExamplesSide-by-side translations of the patterns LangGraph users hit most.Migrate from LangGraphEvery public export from
loomflow, grouped by purpose.API referenceInstall
pip install loomflow
# With provider SDKs
pip install 'loomflow[anthropic,openai]'For zero-key local development, the bare install ships an EchoModel
that lets you exercise the full loop without burning tokens.
Last updated on