Warp and weft
for agent systems.
A Python framework with two primitives held in tension. Workflow is the warp — the graph you hold taut. Agent is the weft — the loop you hand to the model. Thread either through the other; memory, budgets and audit follow the user_id across every pass.
You hold the graph.
A developer-controlled DAG. Nodes are functions, Agents, or other Workflows. Edges are decisions. Cycles are allowed, with a visit cap so a refinement loop can't spin forever.
The model threads across.
An LLM-controlled loop: it reasons, calls tools, reads memory, and decides when it's done. Twelve architectures from ReAct to Tree-of-Thoughts, swapped with one argument.
Draw the flow, or hand it over.
from loomflow import Agent, Workflow
# two LLM-controlled specialists (the weft)
billing = Agent("Handle billing.", model="gpt-4.1-mini")
tech = Agent("Handle tech.", model="gpt-4.1-mini")
async def classify(text: str) -> str:
return (await Agent(
"Reply 'billing' or 'tech'.", model="claude-haiku-4-5",
).run(text)).output
# developer-controlled DAG (the warp)
support = Workflow.route(classify, {
"billing": billing, "tech": tech,
})
r = await support.run(
"My card was charged twice.", user_id="alice",
)
print(r.visited) # ['classify', 'route_billing']Compose both directions
Pass an Agent as a workflow node. Or call wf.as_tool() and the whole workflow becomes a tool the agent can call. The trace reads the same either way.
Branches and cycles
add_router branches on whatever the last node returned. Loops are first-class, bounded by max_visits_per_node.
Replay after a crash
Wrap with SqliteRuntime or PostgresRuntime. Completed steps are journaled; a resumed run picks up where it stopped.
Built for the second draft.
How a run is woven.
loom-code. A coding agent, cut from this cloth.
A terminal coding agent built entirely on loomflow — living plans, memory, sub-agents, and the approval gate, composed into a daily-driver CLI. Works with any model, including free ones. It is both a product and the reference for the framework in production.