General Introduction
Cooragent is an open source AI agent collaboration framework developed by LeapLab at Tsinghua University and hosted on GitHub, which allows users to create intelligent AI agents with a one-sentence description and supports multiple agents to collaborate on complex tasks. The framework provides two modes: Agent Factory automatically generates customized agents, Agent Workflow Cooragent is deeply compatible with the Langchain toolchain, and supports MCP protocol to ensure efficient communication between agents. Developers can quickly build, edit and manage agents through CLI tools or APIs.
Function List
- Agent Factory Mode The system automatically analyzes the requirements and generates customized AI agents without the need for complex Prompt design.
- Agent Workflow Mode : Supports multi-agent collaboration, automatically breaking down tasks, assigning roles, and accomplishing complex goals.
- Deep compatibility with Langchain : Support for Langchain's Prompt, Chain, Memory, Document Loaders and other components to simplify development.
- MCP Protocol Support : Standardized inter-agent information exchange, support for multiple rounds of interaction and efficient context management.
- CLI tools : Provides a command line interface to quickly create, edit, delete and list agents.
- API Support : Automate agent creation, task submission, and status monitoring through APIs.
- Tool Call : Extended agent capabilities with support for web crawlers, code execution, file manipulation, and more.
- community sharing : Users can publish agents to the community for use or optimization by other developers.
- observability : Provide agent operation status and performance logs for easy monitoring and debugging.
- local deployment : Supports local operation to protect data privacy.
Using Help
Installation process
Cooragent supports Python 3.12+ environments, and offers both conda and venv installations. Here are the steps:
Installation with conda
- clone warehouse
Run the following command in the terminal to download the Cooragent code:git clone https://github.com/LeapLabTHU/cooragent.git cd cooragent
- Creating a Virtual Environment
Create and activate a Python 3.12 environment:conda create -n cooragent python=3.12 conda activate cooragent
- Installation of dependencies
Install project dependencies:pip install -e .
- Optional: Installation of browser tools
For features such as web crawlers, install Playwright:playwright install
- Configuring Environment Variables
Copy the sample configuration file and edit it:cp .env.example .env
Open with a text editor
.env
file, fill in the API key (e.g. OpenAI or another model). To enable the MCP protocol, setMCP_AGENT=True
. If you need to enable browser tools, setUSE_BROWSER=True
The - Verify Installation
Run the CLI tool to check if the installation was successful:python cli.py
Installation with venv
- clone warehouse
Same way as conda, run:git clone https://github.com/LeapLabTHU/cooragent.git cd cooragent
- Creating a Virtual Environment
Use the uv tool to install Python 3.12 and create a virtual environment:uv python install 3.12 uv venv --python 3.12 source .venv/bin/activate # Windows: .venv\Scripts\activate
- Installation of dependencies
Synchronization dependencies:uv sync
- Optional: Installation of browser tools
Same way as conda, run:playwright install
- Configuring Environment Variables
Same as conda, copy and edit.env
Documentation. - Running Projects
Run the CLI tool with uv:uv run cli.py
Windows Installation Notes
Windows users will need to install additional dependencies, see the official documentation for details. Windows Platform Support. Ensure that environment variables are properly configured and all dependencies are installed.
Usage
Cooragent provides Agent Factory and Agent Workflow modes, combining CLI tools and APIs for simple and efficient operation.
Agent Factory Mode
This pattern quickly generates an AI agent with a one-sentence description. For example, create a stock analysis agent:
python cli.py run -t agent_factory -u test -m 'Create a stock analysis expert agent to analyze the Xiaomi stock trend, today is 22 April, 2025, look over the past month, analyze the big news about Xiaomi, then predict the stock price trend for the next trading day, and provide buy or sell recommendations.'
- procedure ::
- Run the command, specifying the task type as
agent_factory
The - parameters
-u
Set the user ID (e.g.test
).-m
Enter a description of the task. - The system analyzes requirements by remembering and extending them, selecting tools, automatically optimizing Prompt, and generating agents.
- The agent runs and outputs results (e.g. stock analysis reports).
- transferring entity
edit-agent -n <agent_name> -i
Edit agents to optimize behavior.
- Run the command, specifying the task type as
- Featured Functions : No need for complex Prompt design, the system automatically understands the requirements and generates efficient agents.
Agent Workflow Mode
This model supports multi-agent collaboration and is suitable for complex tasks. For example, planning a trip to Yunnan on May 1, 2025:
python cli.py run -t agent_workflow -u test -m 'Use the task planning agent, web crawler agent, code execution agent, browser operation agent, report writing agent, and file operation agent to plan a trip to Yunnan for the May Day holiday in 2025. First, run the web crawler agent to fetch information about Yunnan tourist attractions, use the browser operation agent to browse the attraction information and select the top 10 most worthwhile attractions. Then, plan a 5-day itinerary, use the report writing agent to generate a travel report, and finally use the file operation agent to save the report as a PDF file.'
- procedure ::
- Run the command, specifying the task type as
agent_workflow
The - Enter a task description that lists the required agents.
- System Planner analyzes the task, breaks down the steps, and assigns them to the appropriate agents.
- Agents collaborate through the MCP protocol to accomplish tasks (e.g., generating trip reports).
- Output results (e.g. PDF file).
- Run the command, specifying the task type as
- Featured Functions : Planner automatically optimizes task allocation and the MCP protocol ensures efficient communication to support complex tasks.
CLI Tool Usage
Common CLI commands include:
- Creating a Proxy ::
python cli.py create -n <agent_name>
- Editorial agent ::
python cli.py edit-agent -n <agent_name> -i
- List Agents ::
python cli.py list-agents -u <user-id> -m <regex>
- Delete Proxy ::
python cli.py remove-agent -n <agent_name> -u <user-id>
- View Status ::
python cli.py status
API Usage
The API supports automated management of agents. For example, submitting tasks:
import requests
url = "http://localhost:8000/task"
payload = {"task": "Analyze stock trend", "user_id": "test"}
response = requests.post(url, json=payload)
print(response.json())
- functionality : Support for agent creation, task submission, result acquisition and status monitoring.
- use : Integrate into scripts or applications to build custom interfaces.
MCP Protocol Usage
The MCP protocol supports efficient communication between agents. For example, to create an agent for Excel operations:
server_params = StdioServerParameters(
command="python",
args=[str(get_project_root()) + "/src/mcp/excel_mcp/server.py"]
)
async def excel_agent():
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await load_mcp_tools(session)
agent = create_react_agent(model, tools)
return agent
agent = asyncio.run(excel_agent())
agent_obj = Agent(user_id="share",
agent_name="mcp_excel_agent",
nick_name="mcp_excel_agent",
description="The agent is good at manipulating excel files, which includes creating, reading, writing, and analyzing excel files",
llm_type=LLMType.BASIC,
selected_tools=[],
prompt="")
MCPManager.register_agent("mcp_excel_agent", agent, agent_obj)
- Enable MCP : in
.env
Setting in the fileMCP_AGENT=True
The - use : Support for multi-agent collaboration and cross-platform interaction.
caveat
- assure
.env
The file is configured correctly and the API key is valid. - Browser tools are disabled by default and need to be set
USE_BROWSER=True
Enable. - Windows users should refer to Windows Platform Support Install additional dependencies.
- Regularly update the code:
git pull origin main
The
application scenario
- Task automation
Cooragent automates repetitive tasks. For example, employees in an organization use Agent Workflow to collect market data, generate reports, and save time. - project management
Developers use Agent Factory to create project management agents that automatically assign tasks and track progress, making it ideal for team collaboration. - data analysis
Researchers use Cooragent to analyze stock or news data to generate trend forecasts or industry reports. - Education and learning
Students create learning assistant agents to organize course materials, answer questions, and improve efficiency. - Documents processing
Create Excel agents using the MCP protocol to automatically process tabular data for financial or data analysis scenarios.
QA
- What language models does Cooragent support?
Supports multiple language models (e.g. OpenAI, other open source models) as determined by Langchain compatibility, API key configuration required. - How do I share an agent?
(of a computer) runpython cli.py publish -n <agent_name>
, publish the agent to the community for other developers to use. - What if the mission fails?
probe.env
file's API key and network connection, view the log (logs/
directory). Help is available by submitting an issue on GitHub. - Does it support local deployment?
Yes, Cooragent supports local deployment, protects data privacy, and is suitable for enterprise use. - How do I contribute code?
consultation Contribution Guidelines, commit fixes, documentation improvements, or new features.