Skip to main content

A lightweight multi-agent framework with ReAct reasoning, tool dispatch, and MCP integration

Project description

All Agent

A lightweight multi-agent framework with ReAct reasoning, tool dispatch, and MCP integration.

Features

  • ReAct Agent — ReAct (Reasoning + Acting) loop with multi-turn tool calling
  • Chat Agent — simple conversational agent with multi-turn history support
  • Tool Dispatch — convention-over-configuration: define do_{tool_name} methods, auto-routed via reflection
  • MCP Integration — pluggable MCP server manager for external tool providers
  • Skill System — skill-based prompt injection for domain-specific behaviors
  • Built-in Bash Executor — async sandboxed bash execution with timeout, output truncation, and blacklist filtering
  • Stateless Execution — each runtime() call starts with a clean context; history is caller-managed
  • OpenAI-compatible — works with any OpenAI-compatible API (DeepSeek, etc.)

Installation

pip install all-agent

Or with uv:

uv pip install all-agent

Quick Start

Set up your environment variables (.env):

CHAT_MODEL=deepseek-chat
MODEL_API_KEY=sk-xxxxxxxx
MODEL_URL=https://api.deepseek.com
LLM_TIMEOUT=30

Chat Agent

from allagent import ChatLoop

loop = ChatLoop()
result = await loop.runtime(task="介绍一下你自己")

# With multi-turn history
history = [
    {"role": "user", "content": "今天天气不错"},
    {"role": "assistant", "content": "是啊,适合出去走走"},
]
result = await loop.runtime(task="我们去哪", history=history)

ReAct Agent

from allagent import ReactLoop

loop = ReactLoop()
result = await loop.runtime(task="帮我写一个Python脚本打印当前时间")

The ReAct agent supports built-in tools (like bash_run) and any MCP tools configured in mcp_config.json.

MCP Configuration

Place an mcp_config.json alongside your ReactLoop:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@anthropic/mcp-playwright"]
    }
  }
}

Architecture

LLMConfig (BaseHandler, ABC)
├── ChatLoop         — stateless conversational agent
├── ReactLoop        — ReAct reasoning + tool dispatch
│   ├── MCP tools    — external tools via MCP protocol
│   ├── Skill system — domain-specific prompt injection
│   └── Local tools  — built-in bash_run, extensible
└── (future) PlanLoop / ExecuteLoop

Tool Dispatch Flow

LLM calls "bash_run"
    → BaseHandler.dispatch("bash_run", args)
        → hasattr(self, "do_bash_run")?  YES
            → await self.do_bash_run(args)  ← local tool
        → NO
            → "未知工具" → MCP fallback  ← external tool

Adding a Local Tool

  1. Define the tool schema in tool_schema.py:
LOCAL_TOOLS = [
    {
        "type": "function",
        "function": {
            "name": "calculator",
            "description": "Evaluate a math expression",
            "parameters": {
                "type": "object",
                "properties": {
                    "expression": {"type": "string", "description": "Math expression"}
                },
                "required": ["expression"]
            }
        }
    }
]
  1. Add the do_calculator method in LLMConfig:
async def do_calculator(self, args: dict) -> StepOutcome:
    result = eval(args["expression"])
    return StepOutcome(data=result, next_prompt="\n")

All agents automatically inherit the new tool.

API

ChatLoop

loop = ChatLoop(temperature=0.7)
await loop.runtime(*, task, system_prompt=None, history=None) -> str | None

ReactLoop

loop = ReactLoop()
await loop.runtime(*, task, system_prompt=None, history=None) -> str | None

StepOutcome

@dataclass
class StepOutcome:
    data: Any              # tool return value
    next_prompt: str | None  # None = task complete
    should_exit: bool      # True = force exit

Requirements

  • Python >= 3.12
  • fastmcp >= 3.4.2
  • openai >= 2.41.0
  • python-dotenv >= 1.2.2

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simagentplg-0.1.0.tar.gz (81.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simagentplg-0.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file simagentplg-0.1.0.tar.gz.

File metadata

  • Download URL: simagentplg-0.1.0.tar.gz
  • Upload date:
  • Size: 81.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for simagentplg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f42f3e0336b13a8409bc4747ff41da3956db3abf95b26ff3f060ac71a0ff06ff
MD5 8eb508ef6cba0837d55ed61f59578beb
BLAKE2b-256 2c146cc222bbb11295f807b4fe83c5b6c6f26f2048f6589dc4307f5699b1b882

See more details on using hashes here.

File details

Details for the file simagentplg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: simagentplg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for simagentplg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15a99a6a8cc2302ea635cacf6e125e4958c825cdd5b13013f367dfe82aee7f43
MD5 c5b4f4966b6803a5a4fbcfab61a81687
BLAKE2b-256 393c9fbfe77e706ba5636c017b880138ce0a8d1f57e5c47cd0acb4aeea0b7433

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page