An open-source autonomous AI agent implementation inspired by Cursor Agent, built on top of Swarms - the enterprise-grade production-ready multi-agent orchestration framework. This production-grade agent can autonomously plan, execute, and complete complex tasks using a combination of Large Language Model reasoning and tool execution.
Built with Swarms Framework - Leveraging the power of Swarms, the leading open-source framework for building production-ready multi-agent systems. Swarms provides the robust infrastructure, agent orchestration, and enterprise-grade reliability that makes this agent possible.
Open Cursor Agent is a sophisticated AI agent capable of:
- Autonomous Task Planning: Breaking down complex tasks into manageable, sequential subtasks
- Multi-Tool Execution: Leveraging various tools including file operations, command execution, and web search
- Intelligent Reasoning: Using LLM-powered thinking to analyze situations and decide next actions
- State Management: Tracking task progress through well-defined execution states
- Error Handling: Robust error detection and recovery mechanisms
| Feature | Description |
|---|---|
| File system operations | Read, write, search, and manage files |
| Command execution | Execute commands with timeout and security controls |
| Web search integration | Access real-time information via web search |
| Task dependency management | Manage tasks with priority awareness |
| Execution history tracking and logging | Record and monitor action history and logs |
| Workspace isolation | Ensure security-first approach to isolate workspace |
| Custom tool selection | Restrict agent to specific tools (search, code, etc.) |
- Python 3.8 or higher
- API key for your chosen LLM provider (e.g., OpenAI)
pip3 install -U open-cursor-agentWORKSPACE_DIR=""
OPENAI_API_KEY=""
ANTHROPIC_API_KEY=""from open_cursor.main import OpenCursorAgent
# Initialize the agent
agent = OpenCursorAgent(
model_name="gpt-4o",
workspace_path=".",
)
# Example task
task_description = """
Create a transformer model in pytorch in a file called transformer.py"
"""
result = agent.run(task_description)
print(result)You can customize which tools the agent has access to by specifying the allowed_tools parameter:
from open_cursor.main import OpenCursorAgent
# Agent with only search and file reading capabilities
search_agent = OpenCursorAgent(
model_name="gpt-4o",
workspace_path="./workspace",
allowed_tools=["web_search", "read_file"],
)
# Agent with only code/file operation capabilities
code_agent = OpenCursorAgent(
model_name="gpt-4o",
workspace_path="./workspace",
allowed_tools=["read_file", "write_file", "list_directory", "search_files"],
)
# Agent with command execution capabilities
command_agent = OpenCursorAgent(
model_name="gpt-4o",
workspace_path="./workspace",
allowed_tools=["execute_command", "read_file"],
)
# Agent with ALL tools - multiple ways to enable all tools:
# Method 1: Don't specify allowed_tools (default is None)
full_agent = OpenCursorAgent(
model_name="gpt-4o",
workspace_path="./workspace",
)
# Method 2: Explicitly pass "all"
full_agent_explicit = OpenCursorAgent(
model_name="gpt-4o",
workspace_path="./workspace",
allowed_tools=["all"],
)
# Method 3: Pass empty list
full_agent_empty = OpenCursorAgent(
model_name="gpt-4o",
workspace_path="./workspace",
allowed_tools=[],
)Available Tools:
read_file: Read contents of fileswrite_file: Write content to filessearch_files: Search for files matching patternslist_directory: List directory contentsexecute_command: Execute shell commandsweb_search: Search the web for informationcreate_directory: Create new directoriesdelete_file: Delete files or directories
Special Values for allowed_tools:
None(default): All tools are available[](empty list): All tools are available["all"]: All tools are available["tool1", "tool2", ...]: Only specified tools are available
Note: Planning and control tools (create_plan, think, complete_task, subtask_done) are always available regardless of the allowed_tools setting, as they are essential for agent operation.
graph LR
A[User Task] --> B[Initialize]
B --> C[Planning]
C --> D[Execution]
D --> E[Thinking]
E --> F{Complete?}
F -->|No| D
F -->|Yes| G[Results]
C -.-> H[LLM]
D -.-> H
E -.-> H
D -.-> I[Tools]
style B fill:#4a90e2,color:#fff
style C fill:#9b59b6,color:#fff
style D fill:#e74c3c,color:#fff
style E fill:#f39c12,color:#fff
style G fill:#27ae60,color:#fff
The agent operates through a state machine with the following phases:
- Initialization: Task context is created and main task is registered
- Planning Phase: LLM generates a detailed execution plan with subtasks
- Execution Phase: Each subtask is executed using appropriate tools
- Thinking Phase: Results are analyzed and next actions determined
- Completion: All tasks are finalized and results are returned
INITIALIZING: Setting up the task contextPLANNING: Creating a detailed execution planEXECUTING: Performing planned actionsTHINKING: Analyzing results and determining next stepsCOMPLETED: Task successfully finishedERROR: Error encountered during executionPAUSED: Execution temporarily halted
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Make your changes with appropriate tests
- Submit a pull request with a clear description
This project is licensed under the terms specified in the LICENSE file.
Special Thanks: To Swarms Team and the entire Swarms community for building the infrastructure that makes advanced AI agents accessible to everyone. This project stands on the shoulders of giants.