Skip to Content
DocsWelcome

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_id partition no matter which one you pick. Pass an Agent as a Workflow node, or call wf.as_tool() and the workflow becomes a tool the agent can call.
  • user_id is a typed primitive. One Agent plus one Memory partitions 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_id rehydrates prior turns as real chat history. Reuse the same id across processes and the journal replays.
  • Twelve agent-loop architectures ship behind one Agent constructor. One kwarg flips the iteration pattern.

Where to start

Install

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