An Open-Source Asynchronous Coding Agent
Find a file
Brace Sproul fd0d50be26
fix: Docs and scripts (#15)
* fix: Docs and scripts

* cr

* fix: better err handling

* cr
2025-05-23 16:43:14 -07:00
.github/workflows init commit 2025-05-21 14:47:56 -07:00
scripts fix: Docs and scripts (#15) 2025-05-23 16:43:14 -07:00
src fix: Docs and scripts (#15) 2025-05-23 16:43:14 -07:00
.codespellignore init commit 2025-05-21 14:47:56 -07:00
.dockerignore init commit 2025-05-21 14:47:56 -07:00
.env.example fix: Docs and scripts (#15) 2025-05-23 16:43:14 -07:00
.gitignore init commit 2025-05-21 14:47:56 -07:00
.prettierrc init commit 2025-05-21 14:47:56 -07:00
e2b.Dockerfile feat: Commit changes after writing (#14) 2025-05-23 15:56:06 -07:00
e2b.toml feat: Commit changes after writing (#14) 2025-05-23 15:56:06 -07:00
eslint.config.js feat: Implement planning nodes (#4) 2025-05-22 11:07:21 -07:00
jest.config.js init commit 2025-05-21 14:47:56 -07:00
langgraph.json fix: Docs and scripts (#15) 2025-05-23 16:43:14 -07:00
LICENSE init commit 2025-05-21 14:47:56 -07:00
package.json fix: Docs and scripts (#15) 2025-05-23 16:43:14 -07:00
README.md fix: Docs and scripts (#15) 2025-05-23 16:43:14 -07:00
tsconfig.json init commit 2025-05-21 14:47:56 -07:00
yarn.lock feat: Commit changes after writing (#14) 2025-05-23 15:56:06 -07:00

Open SWE

Open SWE is an open-source cloud based coding agent.

Usage

First, clone the repository:

git clone https://github.com/langchain-ai/open-swe.git
cd open-swe

Next, install dependencies:

yarn install

Copy the .env.example file to .env and fill in the values:

cp .env.example .env
# ------------------LangSmith tracing------------------
LANGCHAIN_PROJECT="default"
LANGCHAIN_API_KEY=""
LANGCHAIN_TRACING_V2=true
# -----------------------------------------------------

# Defaults to Anthropic models, OpenAI & Google keys are optional, unless using those models
ANTHROPIC_API_KEY=""
OPENAI_API_KEY=""
GOOGLE_API_KEY=""

# E2B API key for accessing and modifying the code in the cloud sandbox.
E2B_API_KEY=""

# Your GitHub PAT with access to the repositories you want to modify.
GITHUB_PAT=""

Your GitHub personal access token should have access to only the repositories you want to modify. It must have the following Repository permissions:

  • Read access to metadata
  • Read and Write access to code and pull requests

You can generate a personal access token in GitHub settings.

Running the graph

To run the graph, first modify the e2e.ts file to set the userRequest along with the target repository information.

The userRequest should contain the task description for Open SWE to execute.

The target_repository object should contain the information for the repository Open SWE should clone and make changes to. You're required to set the owner and repo properties. The branch property is optional, and defaults to whatever the base branch of the repository is.

After setting the userRequest and target_repository, run the following command on a terminal session:

yarn dev

This will start the LangGraph server running locally. The server will be available at http://localhost:2024 by default.

Then, run the following command on a second terminal session:

yarn run:e2e

This will start the graph with the inputs you specified in the file. The graph always runs a planning sub-graph first, and once it's finished planning it will interrupt with the plan. To interact with the interrupt, you should add Open SWE to Agent Inbox.

Once you've added the graph to the inbox, you can inspect the interrupt with the generated plan. It will allow you to:

  1. Accept the plan as is.
  2. Edit, and submit the plan.
  3. Respond with natural language to have the plan modified. This step will not rerun the planning subgraph, it will only modify the plan.
  4. Reject the plan by clicking the Ignore button.

If you want to accept the plan as is, you should re-invoke the graph from the terminal with the yarn run:e2e --threadId <threadId> command. Replace <threadId> with the thread ID of the interrupt you want to accept. This will resume the graph, and log the updates to the terminal. You may also resume from Agent Inbox, however this will not show you the outputs of the graph.

Accessing Changes

Open SWE will automatically create a branch whenever you create a new thread with a naming format of open-swe/<threadId>. Every time a file is created, modified, or deleted, the changes will be committed to this branch. You can access the changes in the repository by checking out this branch.