Skip to Content
Welcome

Loomflow

Loomflow is a Python framework for building AI agents and the workflows around them. It gives you two building blocks:

  • An Agent is a loop the model drives: it reads the task, calls tools, checks memory and decides when it’s done.
  • A Workflow is a set of steps you lay out: plain functions, agents or other workflows, connected the way you choose.

Use either one, or put one inside the other. Both share the same memory, budgets, audit log and tracing, and all of it is kept separate per user when you pass a user_id. (The name comes from weaving: a workflow is the fixed warp, the agent is the weft passing through it.)

Install

pip install loomflow # the core pip install 'loomflow[anthropic,openai]' # with provider SDKs

The core is enough to try it: model="echo" runs the whole loop with no API key. Python 3.11 or newer.

A first look

A small model sorts each support message, then the right specialist agent answers it:

import asyncio from loomflow import Agent, Workflow billing = Agent("You handle billing questions.", model="gpt-4.1-mini") tech = Agent("You handle technical questions.", model="gpt-4.1-mini") async def classify(text: str) -> str: reply = (await Agent( "Reply with one word: billing or tech.", model="gpt-4.1-mini", ).run(text)).output return "billing" if "billing" in reply.lower() else "tech" support = Workflow.route(classify, {"billing": billing, "tech": tech}) async def main(): result = await support.run("My card was charged twice.", user_id="alice") print(result.output) print(result.visited) # ['classify', 'route_billing'] asyncio.run(main())

The Quickstart builds up to this one step at a time, starting with an agent that needs no API key.

What you get

  • Agents and workflows that compose. Pass an agent as a workflow step, or turn a workflow into a tool an agent can call with wf.as_tool().
  • Twelve agent loop styles, from ReAct to Tree of Thoughts and multi-agent teams, chosen with one argument (Architectures).
  • Typed results. Pass a Pydantic model as output_schema= and get a validated object back; if the model misses, it is asked again.
  • Per-user isolation. user_id partitions memory, budgets, permissions and the audit log with no extra code.
  • Any model. Anthropic, OpenAI and DeepSeek directly, gateways such as OpenRouter, about 100 more through LiteLLM, with retries on rate limits and network errors.
  • Production pieces built in. Durable runs that resume after a crash, guardrails, approvals, budgets, rate limits, OpenTelemetry tracing and HTTP serving. The Production tour shows each in a few lines.

New in recent releases

  • 0.20: run evals from Studio. Start it with loom studio --agent app.agents:billing, then run an eval on a dataset from its page, with a spending limit, and compare it with the last run. EvalHarness.run(max_cost_usd=) caps what an eval spends, and loom eval / loom serve import your module from the folder you run them in.
  • 0.19.1: Studio’s trace page fits on one screen: a Scores bar with one-click Good / Bad, the diagram under the timeline, and the selected step’s details kept in view.
  • 0.19: in Studio, score a run on its page and add a bad one to a dataset with the answer it should have given, then run your evals on it with loomflow.studio.dataset("name"). keep_days= deletes old runs, and search uses a full-text index, so it stays fast on big files.
  • 0.18: Loomflow Studio. Turn on recording once (loomflow.studio.enable() or LOOMFLOW_STUDIO=1) and every run is saved to a local SQLite file; loom studio browses it: traces with model messages and tool calls, agent versions with what changed, architecture diagrams that highlight the path a run took, and eval runs compared case by case. Also Agent(name=), RunResult.run_id, and build_graph for workflows.
  • 0.17.3: fixes for regressions in 0.17.0 to 0.17.2. agent.memory.forget() stops a running background extraction, so erased facts can’t come back. Under SubprocessSandbox and OSSandbox, the workspace and living-plan tools work again, a skill’s tools.py runs in the sandbox, and a Seatbelt child starts in its first root. An interrupted branch stops Workflow.parallel, a role model given as an OpenAI or DeepSeek id can take its key from secrets=, and ReWOO’s default prompt teaches the step-reference syntax its executor reads.
  • 0.17.2: await agent.aclose() waits for the background fact extraction a run leaves behind, so you can read the facts it produced or shut down without losing them. Gateway ids such as anthropic/claude-haiku-5.5 now get the vendor model’s capabilities too: native structured output, effort, the right output-token parameter, tokenizer and context window.
  • 0.17.1: gateway ids (OpenRouter’s anthropic/claude-haiku-5.5, openai/gpt-5-mini) are priced as the vendor’s model, so max_cost_usd budgets trip; :free variants cost nothing.
  • 0.17: every subsystem checked against its reference (provider SDKs, the MCP / A2A / OpenTelemetry specs, the papers, the Agent Skills spec). Durable runs replay only into a resumed run, journals are JSON, the audit log is a verifiable hash chain, spans follow the GenAI conventions, guardrails cover streamed text, and A2A speaks v1.0. Several defaults changed (ACCEPT_EDITS, MCP tool names, retry jitter, budget wall clock, hooks that time out deny, config files reject unknown keys); see Migrating from 0.16.
  • 0.16: Swarm handoffs work like the reference swarms: a handoff ends the agent’s turn, the next agent sees earlier tool results, follow-ups go to the last agent, and handoffs= limits who can hand off to whom. Plus @tool(ends_turn=True).
  • 0.15: decisions can look at images, and the new Box question returns a bounding box.
  • 0.14: Decisions. Instead of generating text for internal judgments (which route? is the goal met? is this tool call risky?), ask typed questions and get calibrated answers in a fraction of a second, from TypeSafe’s Jev or any LLM.
  • 0.13: hybrid search on PostgresVectorStore, mixing keyword and vector ranking.
  • 0.12: direct DeepSeek support.

Before that: checkpoints, signals for long human-in-the-loop flows, guardrails, rate limiting, serving over HTTP, A2A, evals, a fact graph, tool search and code mode, model fallbacks and per-role model routing. The changelog  has every change.

Where to go next

Last updated on