### Setup and Run Dashboard UI Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Installs dashboard dependencies, sets the API base URL in the environment, and starts the development server for the UI. Ensure you are in the 'ui' directory before running. ```bash cd ui pnpm install cat > .env <<'EOF' VITE_DASHBOARD_API_BASE_URL="http://localhost:2024" EOF pnpm run dev # vite dev --port 3000 -> http://localhost:3000 ``` -------------------------------- ### Install Dependencies Source: https://github.com/langchain-ai/open-swe/blob/main/AGENTS.md Installs project dependencies using uv. ```bash make install # uv pip install -e . ``` -------------------------------- ### Start ngrok with a specific URL Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Start ngrok to expose your local server. Using the --url flag ensures a consistent subdomain for webhook configurations. ```bash ngrok http 2024 --url https://some-url-you-configure.ngrok.dev ``` -------------------------------- ### Start Backend Development Server Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Starts the LangGraph development server which includes all graphs and the FastAPI app. This is the primary command for local backend development. ```bash make dev # uv run langgraph dev # or: uv run langgraph dev --no-browser ``` -------------------------------- ### Run Development Environment Source: https://github.com/langchain-ai/open-swe/blob/main/AGENTS.md Starts the development server serving all three graphs and the FastAPI app. ```bash make dev # uv run langgraph dev — serves all three graphs + the FastAPI app from langgraph.json ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Clone the Open SWE repository, navigate into the directory, create and activate a Python virtual environment using uv, and then install all project dependencies including extras. ```bash git clone https://github.com/langchain-ai/open-swe.git cd open-swe uv venv source .venv/bin/activate uv sync --all-extras ``` -------------------------------- ### Install Playwright Dependencies and Run Tests Source: https://github.com/langchain-ai/open-swe/blob/main/tests/e2e/README.md Installs necessary npm packages, downloads Playwright browser binaries, and executes the Playwright test suite. This command boots the langgraph dev server automatically before running tests. ```bash cd tests/e2e npm install npx playwright install chromium npx playwright test ``` -------------------------------- ### Example Default Prompt File Content Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Illustrates the markdown format for a `default_prompt.md` file, including instructions for default repositories and organization conventions. ```markdown # Default Prompt ## Default Repository When no repository is specified, work on the **my-app** repository under **my-org**. ## Organization Conventions - Use conventional commits: feat:, fix:, chore: - Always tag the requesting user when work is complete ``` -------------------------------- ### Run FastAPI Application Source: https://github.com/langchain-ai/open-swe/blob/main/AGENTS.md Starts the FastAPI application for agent-related services. ```bash make run # uvicorn agent.webapp:app --reload --port 8000 (FastAPI only, no LangGraph runtime) ``` -------------------------------- ### Pass Pre-configured Model Instance Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md For full control, pass a pre-configured model instance directly to `create_deep_agent`. This example shows how to use `ChatAnthropic`. ```python from langchain_anthropic import ChatAnthropic model = ChatAnthropic(model_name="claude-sonnet-5", temperature=0, max_tokens=16_000) return create_deep_agent( model=model, ... ) ``` -------------------------------- ### Run Langgraph Dev Server for E2E Testing Source: https://github.com/langchain-ai/open-swe/blob/main/tests/e2e/README.md Starts the langgraph development server with a specific configuration for E2E testing. It disables the browser launch, allows blocking operations, and prevents automatic reloading. This allows manual interaction with the mock Slack and GitHub interfaces. ```bash uv run langgraph dev --config tests/e2e/langgraph.e2e.json --port 2024 \ --no-browser --allow-blocking --no-reload # open http://127.0.0.1:2024/mock/slack and /mock/github ``` -------------------------------- ### Extracting GitHub App Installation ID Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md The Installation ID is found in the URL after installing the app on your GitHub repositories. This ID is crucial for the application's setup. ```text https://github.com/settings/installations/12345678 ``` ```text https://github.com/organizations/YOUR-ORG/settings/installations/12345678 ``` -------------------------------- ### Create Sandbox Snapshot using Helper Script Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Uses a helper script to create a sandbox snapshot. This command-line approach requires specifying the snapshot name and the Docker image. ```bash uv run python scripts/create_sandbox_snapshot.py \ --name open-swe-gh-cli-amd64 \ --image johanneslangchain/open-swe-sandbox:gh-cli-amd64 ``` -------------------------------- ### Build and Push Docker Image (Apple Silicon) Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Builds a Docker image for the sandbox environment, forcing the linux/amd64 platform. Use this command on Apple Silicon Macs. ```bash docker buildx build \ --platform linux/amd64 \ -t / \ --push . ``` -------------------------------- ### Fetch PR Comments Source: https://github.com/langchain-ai/open-swe/blob/main/agent/skills/bootstrap-repo-analysis/SKILL.md Get all comments made on a specific pull request. This can include both general comments and review-specific feedback. ```bash GH_TOKEN=dummy gh api repos///pulls//comments ``` -------------------------------- ### Build a Custom Sandbox Provider Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Implement the SandboxBackendProtocol by extending BaseSandbox. You primarily need to implement the execute method for shell operations. ```python from deepagents.backends.sandbox import BaseSandbox from deepagents.backends.protocol import ExecuteResponse class MySandbox(BaseSandbox): def __init__(self, connection): self._conn = connection @property def id(self) -> str: return self._conn.id def execute(self, command: str, *, timeout: int | None = None) -> ExecuteResponse: result = self._conn.run(command, timeout=timeout or 300) return ExecuteResponse( output=result.stdout + result.stderr, exit_code=result.exit_code, truncated=False, ) ``` -------------------------------- ### Add CI Check Middleware After Agent Completion Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Example of creating a custom middleware function using the `@after_agent` decorator to run CI checks after the agent completes its task. This function receives the agent's state and runtime information. ```python from langchain.agents.middleware import AgentState, after_agent from langgraph.runtime import Runtime @after_agent async def run_ci_check(state: AgentState, runtime: Runtime): """Run CI checks after the agent finishes.""" # Trigger your CI pipeline here ... ``` -------------------------------- ### Sandbox Environment Configuration Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Define the sandbox provider and its resource allocation, including storage, CPU, memory, and idle timeouts. ```shell SANDBOX_TYPE="langsmith" DEFAULT_SANDBOX_SNAPSHOT_ID="" DEFAULT_SANDBOX_SNAPSHOT_FS_CAPACITY_BYTES="" DEFAULT_SANDBOX_VCPUS="" DEFAULT_SANDBOX_MEM_BYTES="" DEFAULT_SANDBOX_IDLE_TTL_SECONDS="" DEFAULT_SANDBOX_DELETE_AFTER_STOP_SECONDS="" ``` -------------------------------- ### Initialize Models with make_model() Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Use the `make_model()` helper to initialize different language models. This function wraps `langchain.chat_models.init_chat_model` and automatically enables the Responses API for OpenAI models. ```python # Anthropic model=make_model("anthropic:claude-sonnet-5", temperature=0, max_tokens=16_000) ``` ```python # OpenAI (uses Responses API by default) model=make_model("openai:gpt-5.5", max_tokens=128_000, reasoning={"effort": "medium"}) ``` ```python # Google model=make_model("google_genai:gemini-2.5-pro", temperature=0, max_tokens=16_000) ``` -------------------------------- ### Build and Push Multi-Arch Docker Image Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Builds a multi-architecture Docker image that supports both linux/amd64 and linux/arm64 platforms. This allows the image to run locally on Apple Silicon and on other architectures. ```bash docker buildx build \ --platform linux/amd64,linux/arm64 \ -t / \ --push . ``` -------------------------------- ### Add shadcn/ui Component Source: https://github.com/langchain-ai/open-swe/blob/main/ui/README.md Run this command to add a new UI component, such as a button, to your project. The component will be placed in the `components` directory. ```bash pnpm dlx shadcn@latest add button ``` -------------------------------- ### Register a New Sandbox Provider Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Import your factory function and add it to the SANDBOX_FACTORIES dictionary in agent/utils/sandbox.py to make it available. ```python from agent.integrations.my_provider import create_my_provider_sandbox SANDBOX_FACTORIES = { ... "my_provider": create_my_provider_sandbox, } ``` -------------------------------- ### Integrate Custom Middleware into Agent Configuration Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Demonstrates how to add the newly created custom middleware (e.g., `run_ci_check`) to the existing list of middleware in the agent's configuration. This ensures the custom logic is executed during the agent loop. ```python middleware=[ ToolErrorMiddleware(), check_message_queue_before_model, ensure_no_empty_msg, notify_step_limit_reached, run_ci_check, # new middleware ] ``` -------------------------------- ### Exa Web Search Tool Configuration Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Provide your Exa API key to enable the web search tool functionality. ```shell EXA_API_KEY="" ``` -------------------------------- ### Create Deep Agent Configuration Source: https://github.com/langchain-ai/open-swe/blob/main/README.md Configure a Deep Agent with a specific model, system prompt, tools, backend, and middleware. Ensure all necessary imports are handled. ```python create_deep_agent( model="openai:gpt-5.5", system_prompt=construct_system_prompt(...), tools=[http_request, fetch_url, linear_comment, slack_thread_reply], backend=sandbox_backend, middleware=[ToolErrorMiddleware(), check_message_queue_before_model, ...], ) ``` -------------------------------- ### Add a Datadog Search Tool Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Define a new tool function in its own Python file and register it in agent/server.py. The function's docstring serves as the tool's description. ```python # agent/tools/datadog_search.py import requests from typing import Any def datadog_search(query: str, time_range: str = "1h") -> dict[str, Any]: """Search Datadog logs for debugging context. Args: query: Datadog log query string time_range: Time range to search (e.g. "1h", "24h", "7d") Returns: Dictionary with matching log entries """ # Your Datadog API integration here ... ``` ```python from .tools.datadog_search import datadog_search return create_deep_agent( ... tools=[ http_request, fetch_url, linear_comment, slack_thread_reply, datadog_search, # new tool ], ... ) ``` -------------------------------- ### Run Backend FastAPI App Only Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Serves the FastAPI application without the LangGraph runtime. Useful for specific backend tasks but not for full local development requiring LangGraph features. ```bash make run # uvicorn agent.webapp:app --port 8000 ``` -------------------------------- ### Create LangSmith Sandbox Snapshot via SDK Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Creates a sandbox snapshot in LangSmith using the Python SDK. This requires your LangSmith API key and the Docker image name. ```python from langsmith.sandbox import SandboxClient client = SandboxClient(api_key="") snapshot = client.create_snapshot( name="open-swe", docker_image="johanneslangchain/open-swe-sandbox:gh-cli-amd64", # built from ./Dockerfile fs_capacity_bytes=32 * 1024**3, ) print(snapshot.id) ``` -------------------------------- ### Configure Allowed GitHub Repositories Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Specify individual GitHub repositories (owner/repo format) that the agent is allowed to operate on. ```bash # Allow specific repos (owner/repo format) ALLOWED_GITHUB_REPOS="some-user/their-repo,another-org/specific-repo" ``` -------------------------------- ### Slack Integration Environment Variables Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Set these variables to enable Slack integration, including bot tokens and optional repository settings. ```shell SLACK_BOT_TOKEN="" SLACK_BOT_USER_ID="" SLACK_BOT_USERNAME="" SLACK_SIGNING_SECRET="" SLACK_REPO_OWNER="" SLACK_REPO_NAME="" SLACK_CLIENT_ID="" SLACK_CLIENT_SECRET="" SLACK_TEAM_ID="" ``` -------------------------------- ### Configure Sandbox Environment Variables Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Sets environment variables to configure the sandbox's behavior, including the default snapshot ID, filesystem capacity, vCPUs, memory, and idle/delete timeouts. ```bash DEFAULT_SANDBOX_SNAPSHOT_ID="" # Optional; overrides the sandbox's root FS size at sandbox boot. Default is 32 GiB. DEFAULT_SANDBOX_SNAPSHOT_FS_CAPACITY_BYTES="34359738368" # Optional; number of vCPUs per sandbox. Default is 4. DEFAULT_SANDBOX_VCPUS="4" # Optional; memory in bytes per sandbox. Default is 15 GiB. DEFAULT_SANDBOX_MEM_BYTES="16106127360" # Optional; auto-stop a sandbox after this many seconds of inactivity. Default is 7200 (2 hours). 0 disables. DEFAULT_SANDBOX_IDLE_TTL_SECONDS="7200" # Optional; delete a stopped sandbox after this many seconds. Default is 86400 (24 hours). 0 disables. DEFAULT_SANDBOX_DELETE_AFTER_STOP_SECONDS="86400" # Optional; required only for the admin Repository Snapshots page/template generator. REPO_SNAPSHOT_BASE_IMAGE="/" ``` -------------------------------- ### Upload Dataset for Evaluation Source: https://github.com/langchain-ai/open-swe/blob/main/evals/reviewer/README.md Execute the dataset building process and upload the generated dataset to LangSmith for evaluation. Ensure the dataset name is specified. ```bash uv run python -m evals.reviewer.build_dataset --dataset-name openswe-reviewer-v1 ``` -------------------------------- ### Set Model via Environment Variable Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Override the default model by setting the `LLM_MODEL_ID` environment variable. Use the `provider:model` format. ```bash # Set the model via environment variable (uses provider:model format) LLM_MODEL_ID="anthropic:claude-sonnet-5" ``` -------------------------------- ### Reviewer and Analyzer Configuration Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Configure the dataset for reviewer findings and optionally gate public repository access to a specific GitHub organization. ```shell REVIEWER_OUTCOMES_DATASET="" PUBLIC_REPO_ORG_GATE="" ``` -------------------------------- ### Run Reviewer Eval Locally Source: https://github.com/langchain-ai/open-swe/blob/main/evals/reviewer/README.md Execute the reviewer evaluation script from the command line. ```bash uv run python -m evals.reviewer.run_eval ``` -------------------------------- ### LangGraph Configuration for Open-SWE Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md This JSON configuration defines the graphs and the HTTP application for the Open-SWE project. It specifies the entry points for the agent, reviewer, and analyzer graphs, as well as the web application. ```json { "graphs": { "agent": "agent.server:traced_agent", "reviewer": "agent.reviewer:traced_reviewer_agent", "analyzer": "agent.analyzer:traced_analyzer" }, "http": { "app": "agent.webapp:app" } } ``` -------------------------------- ### Run Single Test Source: https://github.com/langchain-ai/open-swe/blob/main/AGENTS.md Executes a single specific test case. ```bash uv run pytest -vvv tests/test_open_pr_middleware.py::test_name # single test ``` -------------------------------- ### Route Models Based on Context Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Dynamically select models within the `get_agent` function based on configuration parameters like the `source`. This allows for using different models for different tasks or triggers. ```python async def get_agent(config: RunnableConfig) -> Pregel: source = config["configurable"].get("source") if source == "slack": # Faster model for Slack Q&A model = make_model("anthropic:claude-sonnet-5", temperature=0, max_tokens=16_000) else: # Full model for code changes from Linear model = make_model("openai:gpt-5.5", max_tokens=128_000, reasoning={"effort": "medium"}) return create_deep_agent(model=model, ...) ``` -------------------------------- ### Core Agent Assembly Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md The main agent is assembled in `get_agent()` within `agent/server.py`. This snippet shows key lines for model creation, system prompt construction, tool selection, and middleware configuration. ```python # agent/server.py — the key lines model_id = os.environ.get("LLM_MODEL_ID", DEFAULT_LLM_MODEL_ID) model_kwargs = {"max_tokens": DEFAULT_LLM_MAX_TOKENS} if model_id == DEFAULT_LLM_MODEL_ID: model_kwargs["reasoning"] = DEFAULT_LLM_REASONING return create_deep_agent( model=make_model(model_id, **model_kwargs), system_prompt=construct_system_prompt(...), tools=[http_request, fetch_url, linear_comment, slack_thread_reply], backend=sandbox_backend, middleware=[ ToolErrorMiddleware(), check_message_queue_before_model, ensure_no_empty_msg, notify_step_limit_reached, ], ) ``` -------------------------------- ### Load and Display Mock GitHub Pull Requests Source: https://github.com/langchain-ai/open-swe/blob/main/tests/e2e/static/github.html Fetches pull request data from a mock API and renders it into an HTML list. The data is refreshed every second. ```javascript async function load() { const res = await fetch("/mock/github/data"); const prs = await res.json(); const list = document.getElementById("list"); if (!prs.length) { list.innerHTML = "

No pull requests yet.

"; return; } list.innerHTML = prs .map( (p) => `
#${p.number} ${p.title}${p.draft ? " (draft)" : ""}
${p.head}${p.base} · ${p.state} · by ${p.author}
${p.files.map((f) => `${f.filename}`).join(" ")}
`, ) .join(""); } load(); setInterval(load, 1000); ``` -------------------------------- ### Token Encryption Key Rotation - Step 2 Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Prepend a new key to the existing TOKEN_ENCRYPTION_KEY for rotation, allowing new writes with the new key while old ciphertexts remain decryptable. ```shell TOKEN_ENCRYPTION_KEY="," ``` -------------------------------- ### Token Encryption Key Rotation - Step 3 Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md After active threads have re-authenticated and re-encrypted tokens, drop the old key to finalize rotation. ```shell TOKEN_ENCRYPTION_KEY="" ``` -------------------------------- ### Fetch PR Reviews Source: https://github.com/langchain-ai/open-swe/blob/main/agent/skills/bootstrap-repo-analysis/SKILL.md Retrieve all reviews for a specific pull request. This is useful for understanding the feedback provided by human reviewers. ```bash GH_TOKEN=dummy gh api repos///pulls//reviews ``` -------------------------------- ### Open-SWE Agent Environment Variables Configuration Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md This is a comprehensive list of environment variables required for the Open-SWE agent. Populate these variables based on your specific configuration for LangSmith, LLM providers, GitHub App, webhooks, and dashboard settings. ```bash # === LangSmith === LANGSMITH_API_KEY_PROD="" LANGCHAIN_TRACING_V2="true" LANGCHAIN_PROJECT="" LANGSMITH_TENANT_ID_PROD="" LANGSMITH_TRACING_PROJECT_ID_PROD="" LANGSMITH_URL_PROD="https://smith.langchain.com" # === LLM === ANTHROPIC_API_KEY="" OPENAI_API_KEY="" GOOGLE_API_KEY="" FIREWORKS_API_KEY="" # === GitHub App (required) === GITHUB_APP_ID="" GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY----- " GITHUB_APP_INSTALLATION_ID="" # === GitHub Webhook (required) === GITHUB_WEBHOOK_SECRET="" # === Dashboard GitHub OAuth (required for the dashboard) === # Direct GitHub OAuth used by the dashboard login flow (not via LangSmith). GITHUB_APP_CLIENT_ID="" GITHUB_APP_CLIENT_SECRET="" # === Agent-runtime GitHub OAuth via LangSmith (optional) === # Without these, all agent operations use the GitHub App's bot token. # With these, each agent run authenticates as the triggering user. GITHUB_OAUTH_PROVIDER_ID="" # Secret used to mint short-lived service JWTs that ask LangSmith to resolve a # specific user's GitHub token. Needed for per-user token resolution in deployed mode. X_SERVICE_AUTH_JWT_SECRET="" # === Repo Allowlist (optional) === # Comma-separated list of GitHub orgs the agent is allowed to operate on. # Also gates dashboard login to members of these orgs (requires the GitHub App's # Organization -> Members: Read-only permission; without it, all dashboard logins are rejected). # Leave empty to allow all orgs. ALLOWED_GITHUB_ORGS="" # Comma-separated list of specific owner/repo pairs the agent is allowed to operate on. # For GitHub/Linear webhooks, a repo is allowed if its org is in ALLOWED_GITHUB_ORGS OR its owner/repo is in ALLOWED_GITHUB_REPOS. # Slack mentions are not rejected from regex-inferred repository text; repository access is bounded by GitHub App installation permissions. # Leave both empty to allow all repos. ALLOWED_GITHUB_REPOS="" # === Default Repository === # Used across all triggers when no repo is specified. DEFAULT_REPO_OWNER="" DEFAULT_REPO_NAME="" # === Dashboard (required to run the web dashboard) === # Public URL that browsers use for /dashboard/api/* and OAuth callbacks. # Use the FastAPI backend URL for local/cross-origin direct API calls. # Use the dashboard frontend URL when a same-origin frontend rewrite proxies /dashboard/api/*. # Its scheme drives cookie security: http:// => SameSite=Lax (local); # https:// => Secure + SameSite=None (production). DASHBOARD_API_BASE_URL="http://localhost:2024" # Public base URL of the dashboard frontend (the ui/ app). Default post-login redirect. DASHBOARD_BASE_URL="http://localhost:3000" # HMAC secret for dashboard JWTs (session cookie and OAuth state). DASHBOARD_JWT_SECRET="" # Comma-separated origins allowed for credentialed CORS and post-login redirects. # Required whenever the frontend and API are on different origins — including local # dev (UI :3000 -> API :2024 is cross-origin). CORS is only enabled when this is set. DASHBOARD_ALLOWED_ORIGINS="http://localhost:3000" # Comma-separated GitHub login or email allowlist for admin dashboard endpoints. # Empty => nobody is an admin. CONFIGURED_ADMINS="" # URL of the LangGraph server the FastAPI side calls to trigger/stream runs. # Defaults to http://localhost:2024 locally; set to your deployment URL in prod. LANGGRAPH_URL="http://localhost:2024" # === Linear (if using Linear trigger) === LINEAR_API_KEY="" LINEAR_WEBHOOK_SECRET="" ``` -------------------------------- ### Slack App Manifest Configuration Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md This JSON manifest defines the configuration for a Slack application, including display information, features, OAuth scopes, and event subscriptions. Replace placeholder URLs with your specific provider ID and ngrok/deployment URL. ```json { "display_information": { "name": "Open SWE", "description": "Enables Open SWE to interact with your workspace", "background_color": "#000000" }, "features": { "app_home": { "home_tab_enabled": false, "messages_tab_enabled": true, "messages_tab_read_only_enabled": false }, "bot_user": { "display_name": "Open SWE", "always_online": true } }, "oauth_config": { "redirect_urls": [ "https://smith.langchain.com/host-oauth-callback/", "http://localhost:2024/dashboard/api/slack/callback" ], "scopes": { "bot": [ "reactions:write", "app_mentions:read", "channels:history", "channels:read", "chat:write", "groups:history", "groups:read", "im:history", "im:read", "im:write", "mpim:history", "mpim:read", "team:read", "users:read", "users:read.email" ] } }, "settings": { "event_subscriptions": { "request_url": "https:///webhooks/slack", "bot_events": [ "app_mention", "message.im", "message.mpim" ] }, "interactivity": { "is_enabled": true, "request_url": "https:///webhooks/slack/interactivity" }, "org_deploy_enabled": false, "socket_mode_enabled": false, "token_rotation_enabled": false } } ``` -------------------------------- ### JavaScript for Mock Slack Interface Source: https://github.com/langchain-ai/open-swe/blob/main/tests/e2e/static/slack.html This script handles the front-end logic for the mock Slack interface, including fetching users, rendering messages, sending messages, and polling for updates. It uses DOM manipulation and fetch API for asynchronous operations. ```javascript const $ = (id) => document.getElementById(id); const userNames = {}; // slack_id -> display name async function loadUsers() { try { const users = await (await fetch("/mock/users")).json(); $("user").innerHTML = users .map((u) => `") .join(""); for (const u of users) userNames[u.slack_id] = u.name; } catch (_) {} } function render(messages) { const html = messages .map((m) => { const who = m.is_bot ? "open-swe (bot)" : userNames[m.user] || m.user; const linked = m.text.replace(/<(https?:\/\/([^|>]+))\|([^>]+)>/g, '$3'); return `
${who}
${linked}
`; }) .join(""); $("thread").innerHTML = html || "

No messages yet.

"; } async function poll() { try { const res = await fetch("/mock/slack/messages"); render(await res.json()); } catch (_) {} } $("send").addEventListener("click", async () => { await fetch("/mock/slack/send", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ text: $("text").value, mention_bot: $("mention").checked, user: $("user").value, }), }); poll(); }); $("reset").addEventListener("click", async () => { await fetch("/control/reset", { method: "POST", }); render([]); }); loadUsers(); poll(); setInterval(poll, 1000); ``` -------------------------------- ### Run Tests Source: https://github.com/langchain-ai/open-swe/blob/main/AGENTS.md Executes all project tests using pytest. ```bash make test # uv run pytest -vvv tests/ ``` -------------------------------- ### Dry Run Dataset Build Source: https://github.com/langchain-ai/open-swe/blob/main/evals/reviewer/README.md Perform a dry run of the dataset building process to generate a local JSON file without uploading to LangSmith. This is useful for verification before a real upload. ```bash uv run python -m evals.reviewer.build_dataset --dry-run ``` -------------------------------- ### Format Code Source: https://github.com/langchain-ai/open-swe/blob/main/AGENTS.md Applies code formatting and fixes linting issues. ```bash make format # ruff format + ruff check --fix ``` -------------------------------- ### Generate Token Encryption Key Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Generate a secure 32-byte base64 encoded key for token encryption. ```shell openssl rand -base64 32 ``` -------------------------------- ### Run Specific Test File Source: https://github.com/langchain-ai/open-swe/blob/main/AGENTS.md Executes tests within a specific file. ```bash make test TEST_FILE=tests/test_open_pr_middleware.py # single test file ``` -------------------------------- ### Add Communication Tool for Agent Replies Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Optionally, create a tool that allows the agent to send replies back to the triggering service. This is useful for providing feedback or status updates. ```python # agent/tools/my_trigger_reply.py def my_trigger_reply(message: str) -> dict: """Post a reply to the triggering service.""" # Your API call here ... ``` -------------------------------- ### Set Custom Default Prompt Path Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Override the default location for the `default_prompt.md` file by setting the `DEFAULT_PROMPT_PATH` environment variable. ```bash DEFAULT_PROMPT_PATH="/path/to/my-org-prompt.md" ``` -------------------------------- ### Custom Sandbox Snapshot Configuration Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Environment variables for configuring a custom sandbox snapshot in LangSmith. These allow specifying snapshot UUID, capacity, vCPUs, memory, idle timeout, and deletion delay. ```bash DEFAULT_SANDBOX_SNAPSHOT_ID="" # Required DEFAULT_SANDBOX_SNAPSHOT_FS_CAPACITY_BYTES="34359738368" # Optional, default 32 GiB DEFAULT_SANDBOX_VCPUS="4" # Optional, default 4 DEFAULT_SANDBOX_MEM_BYTES="16106127360" # Optional, default 15 GiB DEFAULT_SANDBOX_IDLE_TTL_SECONDS="7200" # Optional, default 7200 (2 h); 0 disables DEFAULT_SANDBOX_DELETE_AFTER_STOP_SECONDS="86400" # Optional, default 86400 (24 h); 0 disables REPO_SNAPSHOT_BASE_IMAGE="/" # Optional; required for admin-generated repo snapshot templates ``` -------------------------------- ### Import and Use shadcn/ui Button Component Source: https://github.com/langchain-ai/open-swe/blob/main/ui/README.md Import the Button component from the specified path to use it in your React application. Ensure the component has been added using the shadcn CLI. ```tsx import { Button } from "@/components/ui/button"; ``` -------------------------------- ### Customize Linear Team to Repository Mapping Source: https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md Define a Python dictionary to map Linear teams and projects to specific GitHub repositories. This configuration is used for routing Linear issues to the correct repository. ```python LINEAR_TEAM_TO_REPO = { "Engineering": { "projects": { "backend": {"owner": "my-org", "name": "backend"}, "frontend": {"owner": "my-org", "name": "frontend"}, }, "default": {"owner": "my-org", "name": "monorepo"}, }, } ``` -------------------------------- ### Configure Allowed GitHub Organizations Source: https://github.com/langchain-ai/open-swe/blob/main/INSTALLATION.md Specify GitHub organizations that the agent is allowed to operate on. This also gates dashboard login. ```bash # Allow all repos in these orgs ALLOWED_GITHUB_ORGS="langchain-ai,anthropics" ```