An intelligent agent framework with pluggable skills and LLM integrations
Project description
Agent-Matrix
A cognition-centric autonomous agent framework with pluggable skills and multi-backend LLM integrations.
Overview
Agent-Matrix is a multi-agent framework where agents act as independent "digital employees" that collaborate through asynchronous messaging (similar to email) rather than rigid API calls.
Designed for building robust, intelligent systems that can reason, negotiate, and handle ambiguity like humans do.
Core Philosophy
The core idea is really just common sense.
A lot of Agent frameworks compel powerful LLMs to "think" inside stiff, rigid formats like JSON. This isn't just prone to bugs; it actually stifles their ability to reason. An LLM has a limited attention span for every inference. We should minimize the amount of attention wasted on "watching the JSON syntax." Getting that syntax right takes a lot of "mental energy" and tokens—energy that should be spent on doing the actual work.
I have a theory: the smarter an LLM gets, the more it thinks like a human. Asking a human to count JSON brackets in their head and fill them in perfectly is incredibly hard. I believe forcing an LLM to do this kind of "mental gymnastics" hurts its performance on the main task (it’s like trying to shoot a target while reading a philosophy book). I don't have proof, just my intuition, but I believe this is how it works. Maybe future LLMs will be able to do everything effortlessly, but I doubt it.
That is the heart of AgentMatrix: Let the LLM communicate, think, and output in natural language, and keep its brain away from JSON conversion work.
Agent-Matrix solves this with a Brain + Cerebellum + Body architecture:
- 🧠 Brain (The LLM): Strategic thinker. Uses natural language for high-level reasoning and intent formation. Like a pilot in a cockpit deciding "where to go" without worrying about switch details.
- 🧠 Cerebellum (The SLM): Precise interface manager. Translates natural language intent into machine-executable commands (JSON). Understands intent and fills in JSON.
- 💪 Body: The Python program that executes functions based on JSON and provides feedback.
When the brain's intent is unclear (e.g., "send email" without specifying recipient), the cerebellum doesn't error or blindly execute. Instead, it initiates "negotiation" by sending an internal query back to the brain for clarification. This internal dialogue makes agents exceptionally robust and intelligent.
Core Concepts
- Agent: A digital employee with a specific persona and capability list
- PostOffice: Central communication hub for all inter-agent messages
- Runtime (the Matrix): Execution environment including memory structures and directory layout
- Signal: Information unit in the system - new emails, tool results, or cerebellum queries
- Email: How agents communicate. Email reply chains automatically maintain conversation context
How It Works: Turn-Based Loop
An agent's lifecycle is like a turn-based game:
- Awake: A
Signalarrives, waking the agent from sleep - Reasoning: Brain analyzes signal and history, reasoning in the
THOUGHTsection (internal monologue) - Decision: Brain makes a decision and outputs a clear
ACTION SIGNAL, e.g., "Send Coder an email with code review request" - Negotiation: Cerebellum intercepts the instruction
- If clear: Translate to JSON and let it through
- If unclear: Pause execution, generate an
[INTERNAL QUERY]signal back to brain, starting a "sub-turn" for clarification
- Execution: Agent's "body" executes the cerebellum-validated instruction
- Feedback & Rest: Action results immediately return as
[BODY FEEDBACK]signal, triggering next turn. This continues until brain explicitly decidesrest_n_waitaction
See docs/Design.md for detailed architecture.
Key Features & Advantages
- ✅ Exceptional Robustness: "Negotiation mechanism" fundamentally eliminates execution failures from format errors or unclear intent
- 🧠 Stronger Intelligence: Decouples "thinking" from "actioning", letting the brain (LLM) do complex reasoning unencumbered by formats
- 🌐 True Asynchronous Collaboration: Message passing through "post office" naturally supports complex, parallel social agent workflows
- 🧘 Explicit Will-Driven: Agents have "free will". Must actively decide when to rest (
rest_n_wait), making multi-step tasks simple and natural
The biggest advantage: Makes workflow design remarkably simple
Trade-offs
Everything has trade-offs. This architecture has two potential drawbacks:
- When brain and cerebellum negotiate clarification, multiple rounds of dialogue may consume more tokens
- Fully asynchronous mechanism with email communication means each agent processes emails serially. While beneficial, tasks may sit in queue longer before processing
However, these aren't major issues. What matters most for agents is intelligence and robustness - autonomously completing work correctly. Taking one hour vs two hours doesn't matter much. And token costs will only decrease long-term. Spending tokens to do things right is worth it.
Installation
pip install matrix-for-agents
Quick Start
Basic Usage
from agent_matrix import AgentMatrix
# Initialize the framework
matrix = AgentMatrix(
agent_profile_path="agent_profile_path",
matrix_path="matrix_path"
)
# Start the runtime (this will load all agents from profiles)
await matrix.run()
Using the CLI Runner (Recommended for First-Time Users)
The package includes cli_runner.py as a practical example for interacting with agents:
# Run the CLI runner
python cli_runner.py
The CLI runner provides:
- 📥 Interactive command-line interface
- 💬 Real-time agent communication
- 🔄 Multi-session support
- 📝 Message reply tracking
Usage Example:
# Start the CLI
$ python cli_runner.py
>>> 系统启动。可以在下面输入指令。
>>> 例如: Planner: 帮我分析数据
# Send a message to an agent
>> Planner: 请帮我爬取网页数据
# Start a new session
>> new session
✅ 新会话开始 ID: a1b2c3d4-...
# Reply to a specific message
>> reply: msg-123: 谢谢你的分析
# Exit and save
>> exit
The CLI runner demonstrates:
- How to initialize the AgentMatrix framework
- How to set up event callbacks
- How to communicate with agents through the User proxy
- How to handle multi-session conversations
For full source code, see cli_runner.py in the package installation directory.
Project Structure
agent-matrix/
├── agents/ # Agent implementations
│ ├── base.py # Base agent class
│ └── post_office.py # Message routing system
├── core/ # Core framework
│ ├── runtime.py # Main runtime
│ ├── message.py # Email/Signal definitions
│ └── browser/ # Browser automation
├── skills/ # Built-in skills
│ ├── data_crawler.py # Web scraping
│ ├── web_searcher.py # Web search
│ └── filesystem.py # File operations
├── backends/ # LLM integrations
├── db/ # Database layer
├── profiles/ # Agent configurations (YAML)
└── docs/ # Documentation
Usage Examples
Agent Communication
from agent_matrix import Email
email = Email(
sender="researcher",
recipient="analyst",
subject="Data Analysis Request",
body="Please analyze the crawled data...",
user_session_id="session_123"
)
# Send through post office
await matrix.post_office.dispatch(email)
Built-in Skills
Agents automatically load skills based on their profiles:
# profiles/analyst.yaml
name: "analyst"
description: "Data analysis specialist"
skills:
- filesystem
- web_searcher
Requirements
- Python 3.8 or higher
- See
requirements.txtfor full dependency list
License
Apache License 2.0 - see LICENSE file for details
Contributing
Contributions welcome! Please feel free to submit a Pull Request.
Roadmap
- Enhanced multi-agent collaboration patterns
- More built-in skills
- Improved documentation and tutorials
- Performance optimizations
- Additional backend integrations
Acknowledgments
- Built with FastAPI (Not really used, will use later)
- Browser automation powered by DrissionPage
- Vector search with ChromaDB
Note: Agent-Matrix is currently in alpha release (v0.1.2). APIs and features may evolve as we develop the framework.
For Chinese documentation, see readme_zh.md
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 matrix_for_agents-0.1.3.tar.gz.
File metadata
- Download URL: matrix_for_agents-0.1.3.tar.gz
- Upload date:
- Size: 141.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42242e4c65da0853751b0dd48293f529751be171be62644e0e8ad83ee7afff8f
|
|
| MD5 |
f6e895123e2659e0311c57327b1a3041
|
|
| BLAKE2b-256 |
9aaa2bec216aa38c555aed6d9a8b16d94bf93f79f069cd236f0270952f7adbd1
|
Provenance
The following attestation bundles were made for matrix_for_agents-0.1.3.tar.gz:
Publisher:
publish.yml on webdkt/agentmatrix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrix_for_agents-0.1.3.tar.gz -
Subject digest:
42242e4c65da0853751b0dd48293f529751be171be62644e0e8ad83ee7afff8f - Sigstore transparency entry: 790458368
- Sigstore integration time:
-
Permalink:
webdkt/agentmatrix@e7acc04b846b6f7be6d6b2d014bfe3573cc6da47 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/webdkt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e7acc04b846b6f7be6d6b2d014bfe3573cc6da47 -
Trigger Event:
release
-
Statement type:
File details
Details for the file matrix_for_agents-0.1.3-py3-none-any.whl.
File metadata
- Download URL: matrix_for_agents-0.1.3-py3-none-any.whl
- Upload date:
- Size: 163.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72e5bc165c814cff6d3eab6e9cb42e65ca4fc46833ea870a2b2709d6196ae5ba
|
|
| MD5 |
f17f4ba1f5ed70ec02186c640f187728
|
|
| BLAKE2b-256 |
f552097db9c497e74396d40f8a10bab61226c131068627723b44775595b429f5
|
Provenance
The following attestation bundles were made for matrix_for_agents-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on webdkt/agentmatrix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrix_for_agents-0.1.3-py3-none-any.whl -
Subject digest:
72e5bc165c814cff6d3eab6e9cb42e65ca4fc46833ea870a2b2709d6196ae5ba - Sigstore transparency entry: 790458373
- Sigstore integration time:
-
Permalink:
webdkt/agentmatrix@e7acc04b846b6f7be6d6b2d014bfe3573cc6da47 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/webdkt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e7acc04b846b6f7be6d6b2d014bfe3573cc6da47 -
Trigger Event:
release
-
Statement type: