agentmw — Lightweight middleware for reliable, context-efficient AI agents (open source)
Hi everyone,
I’ve open-sourced agentmw, a framework-agnostic middleware that sits between your LLM client and agent logic to make agents more reliable on long runs.
Key features:
• Real-time failure detection (loops, redundant calls, contradictions, hallucinations)
• Smart context compression (keeps recent tool results, drops stale stuff)
• Persistent reasoning library (SQLite + embeddings) that learns reusable patterns across sessions
• Time-travel debugging CLI
• Works with any provider (OpenAI, Anthropic, Ollama, etc.) and any agent framework
• Async, circuit breaker, MCP server support, TOML config
Demo: pip install -e '.[all]' && agentmw demo
It’s still early but already helping me keep agents from spiraling and wasting tokens. Would love honest feedback, bug reports, or ideas for additional middleware features the community would find useful.
Thanks!