Python agent runtime framework — context management, multi-agent orchestration, and self-improvement for autonomous AI agents
Project description
Loom — Python Agent Runtime Framework
Build autonomous AI agents that run, observe, and improve themselves.
English | 中文
Wiki | Quick Start | API Reference | PyPI
Loom is a production-grade Python framework for building autonomous AI agents. Unlike prompt wrappers or simple LangChain pipelines, Loom provides a complete agent runtime: structured context management, parallel background sensing, multi-agent orchestration, safety controls, and self-improvement strategies.
Why Loom?
| LangChain | AutoGen | CrewAI | Loom | |
|---|---|---|---|---|
| Context pressure management | ❌ | ❌ | ❌ | ✅ |
| Background heartbeat sensing | ❌ | ❌ | ❌ | ✅ |
| Structured Reason→Act→Observe→Δ loop | ❌ | partial | ❌ | ✅ |
| Veto authority (Harness) | ❌ | ❌ | ❌ | ✅ |
| Self-improvement strategies (E1–E4) | ❌ | ❌ | ❌ | ✅ |
| Multi-provider (Anthropic/OpenAI/Gemini) | ✅ | ✅ | ✅ | ✅ |
Quick Start
pip install loom-agent
import asyncio
from loom.api import AgentRuntime, AgentProfile
from loom.providers import AnthropicProvider
async def main():
runtime = AgentRuntime(
profile=AgentProfile.from_preset("default"),
provider=AnthropicProvider(api_key="sk-ant-..."),
)
session = runtime.create_session()
task = session.create_task("Summarize the latest commits in this repo")
run = task.start()
result = await run.wait()
print(result.output)
asyncio.run(main())
How It Works
Every Loom agent is defined by six components:
Agent = ⟨C, M, L*, H_b, S, Ψ⟩
| Component | What it does | Module |
|---|---|---|
| C — Context | Five-partition context window with five compression levels | loom/context/ |
| M — Memory | Session, working, semantic, and persistent memory | loom/memory/ |
| L* — Loop | Reason → Act → Observe → Δ execution engine | loom/runtime/loop.py |
| H_b — Heartbeat | Background thread sensing filesystem/process/resources in parallel | loom/runtime/heartbeat.py |
| S — Skills | Progressively loaded tools, plugins, MCP servers | loom/ecosystem/ |
| Ψ — Harness | Safety layer with veto authority — sets boundaries, never replaces model decisions | loom/safety/ |
Key Features
Context Management
- Five partitions:
system / working / memory / skill / history - Five compression levels triggered by context pressure ρ: Snip → Micro → Collapse → Auto → Reactive
- Context renewal (disk paging) when ρ = 1.0 — agent continues without losing working state
Multi-Agent Orchestration
TaskPlannerbuilds dependency-ordered task graphsCoordinatorexecutes plans with timeout and error handlingSubAgentManagerspawns specialist agents with depth limit (d_max)
Safety & Control (Harness Ψ)
- Three-tier protection: Speculative Classifier → Hook Policy → Permission Decision
VetoAuthorityblocks any tool call — the safety valve- Modes:
DEFAULT/PLAN/AUTO
Self-Improvement
- E1 Tool Learning — tracks reliability per tool
- E2 Policy Optimization — turns blocks into recommendations
- E3 Constraint Hardening — solidifies failure root causes into permanent constraints
- E4 Amoeba Split — detects when to spawn a specialist sub-agent
LLM Providers
All providers include built-in retry and circuit breaker:
from loom.providers import AnthropicProvider, OpenAIProvider, GeminiProvider
Architecture
loom/api/ ← Public entry point: AgentRuntime → Session → Task → Run
loom/runtime/ ← L* loop + H_b heartbeat + monitors
loom/context/ ← Context partitions, compression, renewal, dashboard
loom/memory/ ← Session, working, semantic, persistent memory
loom/tools/ ← Tool registry, executor, governance pipeline
loom/orchestration/ ← TaskPlanner, Coordinator, SubAgentManager
loom/safety/ ← PermissionManager, HookManager, VetoAuthority
loom/ecosystem/ ← Skills, plugins, MCP bridge
loom/evolution/ ← Self-improvement strategies E1–E4
loom/providers/ ← Anthropic, OpenAI, Gemini
Use Cases
Loom is the right choice when a task doesn't fit in a single prompt:
- Coding agents — multi-step refactoring with persistent context and tool use
- Research agents — evidence gathering, memory, and structured continuation
- Agent backends — sessions, tasks, runs, events, approvals, and artifacts
- Extensible products — skills, plugins, or MCP-style capability integration
Documentation
| Quick Start | Get running in 5 minutes |
| Core Concepts | How Loom works |
| Multi-Agent | Orchestration patterns |
| API Reference | Full API docs |
| Comparison | vs LangChain / AutoGen / CrewAI |
| Design Spec | Internal architecture reference |
License
Apache 2.0 with Commons Clause. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loom_agent-0.7.1.tar.gz.
File metadata
- Download URL: loom_agent-0.7.1.tar.gz
- Upload date:
- Size: 83.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.11.15 Linux/6.17.0-1008-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63deff975dac71e2f1f67ee843f107cb2d02f92299954fa4250ee78458ed6eba
|
|
| MD5 |
03d3a6f6187c2770871ffdb47c8195b5
|
|
| BLAKE2b-256 |
c72f850e646e5c8f43759f14f65a68227b3d363e6ce12c0bdbd0ac01351ff826
|
File details
Details for the file loom_agent-0.7.1-py3-none-any.whl.
File metadata
- Download URL: loom_agent-0.7.1-py3-none-any.whl
- Upload date:
- Size: 121.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.11.15 Linux/6.17.0-1008-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e6249f45223844ad99ae38acc618f1a6c1c5ed058e9e6a43f48bcd2a96ad09e
|
|
| MD5 |
d411bce282c007be78897196b4e5f4d8
|
|
| BLAKE2b-256 |
4dc83ec88f0dff58720f5a5d74ed54f9ad358f49c6c4e7ce9dc2e04832678e7f
|