This project implements an AI agent architecture inspired by the Manus system, using LangGraph for workflow management and Claude 3.7 as the foundational language model. The agent follows an iterative loop pattern for task execution, with tool selection and execution capabilities.
- Agent Loop Architecture: Implements the Manus agent loop pattern (analyze, select tools, execute, iterate)
- Tool Integration: Includes tools for messaging, file operations, shell commands, web browsing, and deployment
- Claude 3.7 Integration: Leverages Anthropic's Claude 3.7 model for reasoning and tool selection
- LangGraph Workflow: Uses LangGraph for state management and execution flow control
- Interactive CLI: Simple command-line interface for interacting with the agent
- Python 3.8+
- An Anthropic API key
- Clone this repository:
git clone https://github.com/yourusername/manus-inspired-agent.git
cd manus-inspired-agent- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install the required packages:
pip install -r requirements.txt- Create a
.envfile in the project root and add your Anthropic API key:
ANTHROPIC_API_KEY=your_api_key_here
Run the agent:
python agent.pyThe agent provides a command-line interface with these commands:
- Type your requests to interact with the agent
- Type
resetto start a new conversation - Type
exitto quit
The agent implementation includes the following tool categories:
- message_notify_user: Send a message to the user without requiring a response
- message_ask_user: Ask the user a question and wait for a response
- file_read: Read file content
- file_write: Overwrite or append content to a file
- shell_exec: Execute commands in a specified shell session
- browser_navigate: Navigate browser to a specified URL
- info_search_web: Search web pages using a search engine
- deploy_expose_port: Expose a specified local port for temporary public access
The agent follows a loop-based architecture:
- Analyze Events: Understand user needs and current state
- Select Tools: Choose the next tool call based on current state
- Wait for Execution: Let the tool execute and return results
- Iterate: Choose one tool call per iteration and repeat steps
- Submit Results: Send results to the user
- Enter Standby: Enter idle state when tasks are completed
The agent state consists of:
- Messages (conversation history)
- Current tool calls (tools selected for execution)
- Tool results (results from executed tools)
- Status (running or complete)
- Metadata (additional information)
Tools are called using a specific format:
<tool_call>
tool: tool_name
params: {
"parameter1": "value1",
"parameter2": "value2"
}
</tool_call>
The LangGraph workflow includes these nodes:
- agent: Calls Claude to get the next action
- tools: Executes the selected tools
- complete: Marks the task as complete
To add a new tool:
- Define the tool input schema using Pydantic:
class NewToolInput(BaseModel):
"""Parameters for the new_tool."""
parameter1: str = Field(..., description="Description of parameter1")
parameter2: Optional[int] = Field(None, description="Description of parameter2")- Implement the tool function:
@tool
def new_tool(input: NewToolInput) -> str:
"""Description of what the new tool does."""
# Tool implementation
return f"Result from using the tool with {input.parameter1}"- Add the tool to the tools list:
tools = [
# Existing tools
new_tool, # Add your new tool here
]The system prompt can be modified in the SYSTEM_PROMPT variable to adjust the agent's behavior or add specific instructions.
- This implementation includes simulated tool execution for demonstration purposes
- In a real-world implementation, tools would interact with actual systems
- Future enhancements could include:
- Web UI for easier interaction
- More robust tool execution with error handling
- Persistent storage for conversation history and state
- Integration with additional LLMs or embedding models
- Enhanced security measures for tool execution
This implementation is inspired by the Manus agent architecture and builds upon:
- LangGraph by LangChain
- Claude API by Anthropic