How marlenezw/open-swe-python works
Project Type and Purpose
• This is an open-source Python tool (“Open-SWE Python”), not a traditional full-stack web app.
• Purpose: provide a multi-agent workflow (Manager, Planner, Programmer) that automates coding tasks by interacting with Large Language Models (LLMs).
• Supports two clients: a standalone CLI (open-swe-cli.py) and an MCP server endpoint for VS Code Copilot (open-swe-copilot.py + .vscode/mcp.json).
File-Structure Analysis
• Top-level scripts:
• open-swe-cli.py – CLI entry point
• open-swe-copilot.py – MCP server for VS Code integration
• src/ – core library
• agents/ – contains three roles:
– manager.py (workflow orchestrator)
– planner.py (requirements → plan)
– programmer.py (plan → code)
• enhanced_graph.py – graph-based workflow engine (built on LangGraph)
• state.py – tracks task state across agents
• llm.py – LLM provider abstraction
• config.py – configuration loader
• tools/ – utility tools the agents can invoke
• Tests: tests/
• Config: pyproject.toml, .vscode/mcp.json
Architecture Insights from README
• Three-agent pipeline
• Graph-based orchestration
• Extensible tool-integration layer
• Two usage modes: CLI vs. MCP server (for VS Code)
a. Main Components
1. Clients
• CLI Interface (open-swe-cli.py)
• MCP Server (open-swe-copilot.py + .vscode/mcp.json)
2. Orchestrator
• Manager Agent
3. Agent Pipeline
• Planner Agent
• Programmer Agent
4. Workflow Engine
• Enhanced Graph (LangGraph core)
• State Manager
• Tools registry (src/tools)
5. LLM Integration
• llm.py abstracts calls to OpenAI/other providers
6. Configuration
• config.py (env vars, file-based)
7. External Systems
• VS Code Copilot Chat
• Python environment
• Third-party LLM API
b. Relationships & Data Flow
• User Request → Client (CLI or MCP server) → Manager Agent
• Manager submits subtasks to the Graph Engine, which spins up Planner & Programmer in sequence
• Planner queries llm.py for plan generation → outputs a plan node in the graph → State updated
• Programmer reads plan node → calls llm.py to generate code → writes to workspace or returns result
• Manager collates results, updates State, returns final output to client
c. Architectural Patterns
• Multi-agent pipeline (separation of concerns: orchestration, planning, coding)
• Graph-driven workflow (LangGraph)
• Adapter pattern for LLM providers (llm.py)
• Plugin/Tool registry (tools/) for extensibility
d. Key Technologies & Libraries
• Python 3.12+
• LangGraph (graph orchestration)
• Rich (console UI)
• MCP protocol (VS Code integration)
• pytest, black, ruff for dev workflow