Skip to main content

Modus

Modus — Modular AI agents. Composable by design.

Status Python CI PyPI Tests Downloads MIT

Modus is an open-source modular AI agent framework that provides reusable components
for building, orchestrating, and deploying autonomous AI systems.

Memory systems. Planning loops. Safety guards. Tool execution. MCP integration.
All packaged as swappable modules with clear protocol boundaries.

Docs Memory Actions Roadmap

Why Modus?

Building AI agents today means reinventing the same infrastructure every time: memory systems, planning loops, safety guards, tool execution, perception pipelines. Every framework forces you into a monolithic agent runtime where swapping one piece means rewriting half the system.

Modus takes the opposite approach.

Each capability is a self-contained module with a well-defined protocol interface. Swap memory backends without touching the planner. Change planning strategies without rewriting the action layer. Add safety policies without forking the codebase.

No vendor lock-in. No monolithic runtimes. Just composable building blocks.

Quick start

pip install modus-ai

Install options

The core install is fully functional — chat, memory with keyword search, tools, MCP, workflows, deploy, and observability (without OTel). Heavy optional pieces are extras:

Install Includes Use when
pip install modus-ai Everything above Most cases
pip install "modus-ai[vector]" + LanceDB vector index (lancedb, pyarrow) Hybrid (semantic + keyword) memory search
pip install "modus-ai[vector-pg]" + pgvector backend (psycopg) PostgreSQL vector search (MODUS_PGVECTOR_DSN)
pip install "modus-ai[vector-chroma]" + Chroma backend (chromadb) Local persistent collections
pip install "modus-ai[documents]" + PDF/DOCX loading (pypdf, python-docx) store_file on real documents
pip install "modus-ai[observability]" + OpenTelemetry SDK export (opentelemetry-api) You run a collector (Jaeger, etc.)
pip install "modus-ai[all]" All of the above The whole surface

Embedding calls (OpenAI/Gemini/Ollama) work without any extra — the SDKs are core. Without vector, Memory(embedding=...) falls back to keyword search and logs the missing index — it never raises. CI enforces that import modus and the full test suite pass in a core-only install.

Providers & integrations

15+ providers out of the box — pass a string to Agent(provider=...):

Provider String Key env
OpenAI "openai" / "openai/<model>" OPENAI_API_KEY
Anthropic "anthropic" ANTHROPIC_API_KEY
Gemini "gemini" GEMINI_API_KEY
Groq "groq" GROQ_API_KEY
OpenRouter "openrouter" OPENROUTER_API_KEY
Together "together" TOGETHER_API_KEY
Mistral "mistral" MISTRAL_API_KEY
DeepSeek "deepseek" DEEPSEEK_API_KEY
xAI (Grok) "xai" XAI_API_KEY
Fireworks "fireworks" FIREWORKS_API_KEY
Cerebras "cerebras" CEREBRAS_API_KEY
SambaNova "sambanova" SAMBANOVA_API_KEY
Azure OpenAI "azure/<deployment>" AZURE_OPENAI_ENDPOINT + AZURE_OPENAI_API_KEY
Ollama (local) "ollama" none
vLLM / TGI (local) "vllm" none

Embeddings: OpenAIEmbedding, GeminiEmbedding, OllamaEmbedding, VoyageEmbedding, MistralEmbedding, AzureEmbedding, NoopEmbedding — or Memory(embedding="voyage") with the new string shortcuts. Full reference: the providers guide.

from modus import Agent
from modus.memory import Memory
from modus.memory.embeddings import GeminiEmbedding, OpenAIEmbedding

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
    provider="openai",
    memory=Memory("./data", embedding=OpenAIEmbedding()),
)

# Memory context auto-injected, Chat auto-managed
response = agent.run("What do I know about Project Phoenix?")

# Gemini embeddings (uses the GEMINI_API_KEY env var)
gemini_memory = Memory("./data", embedding=GeminiEmbedding(model="gemini-embedding-001"))

What's built

Module Features Status
Agent ReAct loop, Chat history, Memory injection, Tool calling, Event hooks, session persistence, trace IDs, dry-run, structured outputs (output_schema=) ✅
Memory OKF .md files, PyYAML frontmatter, FTS5 keyword search, pluggable vector backends (LanceDB / pgvector / Chroma), Hybrid scoring, PDF/DOCX/HTML document loaders, LLM analysis, entity extraction, TTL + importance eviction, dedup gate, Dreaming, consolidation, tenant isolation, concurrent + cross-process safe writes ✅
Actions Local tool registry, @tool decorator (Pydantic parameters_model typing), MCP stdio/HTTP transport with handshake + auth headers, argument validation, result compaction, caching, transient-only retry, timeout, parallel execution, middleware, authorization ✅
Safety 3-tier interceptor (deterministic rules, HITL, LLM review), per-iteration and global call limits ✅
Planner SHORT_CIRCUIT, REACT, TREE_OF_THOUGHT with parallel branch execution ✅
Vision OpenAI, Anthropic, Gemini, Ollama, Tesseract providers; SSRF guard, thumbnailing, caching, multi-modal memory ✅
Speech OpenAI Whisper/TTS, Gemini, ElevenLabs, local whisper.cpp/Piper; path/bytes/URL audio; capability flags + shared retry ✅
Skills Package registry (tools + prompts + concepts), path-traversal protection ✅
Providers OpenAI (incl. Groq/OpenRouter/Together/Ollama), Anthropic, Gemini with tool calling; retry/backoff with jitter + Retry-After ✅
Orchestration Workflow graph engine, dependency resolution, conditional routing, loops, HITL, state persistence, validation, hooks, async, sub-workflows, Mermaid export, context isolation, Team ✅
Deploy FastAPI webhook server (Bearer auth, CORS, rate limit, body caps), APScheduler (cron + interval) ✅
Observability Trace IDs, JSON logs, SQLite trace store (runs/spans/cost), evals, modus ui dashboard, optional OTel export ✅
Structured outputs to_structured(prompt, schema, provider), Agent.run(output_schema=...), typed tool args — validated Pydantic models with error-feedback retries ✅

Key architecture

  • Monorepo, single package: pip install modus-ai
  • Memory: OKF .md files + YAML frontmatter → FTS5 + pluggable vector search (LanceDB / pgvector / Chroma)
  • Actions: Plugin local tools or connect MCP servers (stdio or HTTP)
  • ReAct loop: Agent detects LLM tool calls, executes in parallel, feeds results back
  • Chat: Token-budget conversation history, auto-summarized overflow
  • All modules are standalone: from modus.memory import Memory — works without Agent

Example: Tools

from modus import Agent
from modus.actions import tool

@tool(name="get_weather", description="Get weather for a city", parameters={
    "type": "object",
    "properties": {"city": {"type": "string"}},
    "required": ["city"],
})
def get_weather(city: str) -> str:
    return f"Sunny, 25°C in {city}"

agent = Agent(name="WeatherBot", instructions="Use tools to answer questions.")
agent.actions.register(get_weather)

response = agent.run("What is the weather in Tokyo?")

Example: MCP server

agent.actions.connect(
    "filesystem",
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem", "."],
)
# Tools auto-discovered and available in the ReAct loop

Example: Workflow with multiple agents

from modus.orchestration import Workflow, Step

workflow = Workflow(steps={
    "classify": Step(agent=classifier, next={"billing": "resolve", "tech": "escalate"}),
    "resolve": Step(agent=resolver, retry=2, timeout=30),
    "respond": Step(agent=responder, depends_on=["resolve", "escalate"]),
})

result = workflow.run("I was charged twice")

Documentation

Section Description
Architecture Block architecture and lifecycle
Memory Guide OKF concepts, storage, retrieval, API reference
Actions Guide MCP servers, tool execution, ReAct loop
Speech Guide STT/TTS batch + SpeechStream sessions, audio input, local binaries
Orchestration Guide Workflows, durable runs, crash recovery
Structured Outputs Typed responses and tool args with Pydantic
Deploying with Workers Multi-worker memory patterns, lock tuning
Live Integration Tests Real-API verification process and results
Logging & Observability Trace IDs, structured logs, per-module tuning
Security Model Trust boundaries, subprocess isolation
Versioning Policy Stability tiers, deprecation cycle
RFCs Proposal process for contract changes
Protocol Reference Module interface contracts
Contributing Development guide and RFC process
Roadmap Upcoming milestones

Current status

Alpha → v0.3.0. Agent, memory, actions, safety, planner, vision, speech, skills, providers (15+), orchestration, deploy, observability, structured outputs, and durable workflows are implemented and tested — 785 offline tests + 34 real-API live tests, ~86.5% coverage, mypy-clean, ruff-clean.

License

MIT

Metadata

Release files for modus-ai 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modus-ai 0.4.0
File Size Uploaded
modus_ai-0.4.0.tar.gz 187.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modus-ai 0.4.0
File Interpreter ABI Platform
modus_ai-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 422.2 kB

Release files / modus_ai-0.4.0.tar.gz

Download URL modus_ai-0.4.0.tar.gz
Size 187.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7251046cb36ff943220ac7a02c4a2137d40dfed773d743ce43e1dfdb5fdc3936
BLAKE2b-256 checksum
How to use checksums
33eee5319ca59c7dfde0bb3ed0c0b4d80d26c6ba87326e16948eafa0cc1df4f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / modus_ai-0.4.0-py3-none-any.whl

Download URL modus_ai-0.4.0-py3-none-any.whl
Size 234.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f20f7a3d1ca6e716202cd7d483224f7acee0181cea239c00c040645a5d3ec905
BLAKE2b-256 checksum
How to use checksums
6d36cbc4597726b4834f6a6f02f8816ff3a147c5b71d9d28dc13b3837cb5eff7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page