Potential Use Cases for Open SWE: Building Internal Coding Agents with Modular Architecture

Open SWE is an open-source framework for building internal coding agents that automate development workflows through modular components including sandboxed execution, custom tool suites, and multi-platform integrations.

The langchain-ai/open-swe repository provides a production-ready foundation for organizations seeking to deploy AI-powered coding assistants. By combining LangGraph orchestration with isolated sandbox environments, Open SWE enables teams to automate everything from issue triage to pull request reviews while maintaining strict security boundaries.

Core Architecture Enabling Diverse Use Cases

Open SWE's potential use cases stem from eight independent architectural blocks that can be mixed, matched, or extended. Understanding these components reveals how the framework adapts to different organizational needs.

Agent Harness and Orchestration

The agent harness in agent/webapp.py builds on Deep Agents and LangGraph to orchestrate LLM calls, tools, and middleware. This provides a composable LLM-driven agent that can be extended with custom tools without modifying core logic.

Sandboxed Execution Environments

The framework abstracts execution through agent/utils/sandbox.py, supporting multiple backends including Modal, Daytona, Runloop, and LangSmith. This guarantees that arbitrary code runs in isolated containers with no side-effects on production resources.

Comprehensive Tool Suite

Located in agent/tools/__init__.py, the default tool suite includes execute for shell commands, fetch_url and http_request for external APIs, commit_and_open_pr for version control, and integrations like linear_comment and slack_thread_reply.

Context Engineering

The system pulls AGENTS.md from target repositories and aggregates issue or thread history through functions like select_slack_context_messages in agent/utils/slack.py. This supplies the LLM with rich, domain-specific context before reasoning begins.

Deterministic Middleware

Safety mechanisms in agent/middleware/check_message_queue.py include check_message_queue_before_model, open_pr_if_needed, and ToolErrorMiddleware. These guarantee safety nets—such as automatically opening a PR if the agent forgets—and handle tool errors gracefully.

Multi-Platform Invocation Surfaces

Engineers interact with the agent through existing workflows: Slack app mentions, Linear comments, or GitHub issue/PR comments. The webhook handlers in agent/webapp.py route these invocations through process_slack_mention, process_linear_issue, and process_github_pr_comment.

Security and Authentication

The agent/utils/auth.py module handles GitHub App token management and encrypted per-thread GitHub token storage, ensuring actions execute with correct permissions without exposing secrets.

Practical Use Cases for Open SWE

These architectural blocks enable specific, high-value automation scenarios for development teams.

Automated Issue Triage and Resolution

When a developer mentions @open-swe in a Slack thread with a bug description, the agent executes a complete resolution pipeline. The process_slack_mention function in agent/webapp.py verifies the request via verify_slack_signature, resolves the repository context, and creates a deterministic thread ID through generate_thread_id_from_slack_thread.

The agent then synthesizes a plan, writes a fix in the sandboxed environment, and calls the commit_and_open_pr tool from agent/tools/commit_and_open_pr.py to open a draft PR. Finally, it replies in the same Slack thread with the PR link.

Linear Ticket Integration

For teams using Linear, Open SWE transforms ticket comments into automated development workflows. When a Linear comment contains directives like "please fix repo:my-org/my-repo", the process_linear_issue webhook extracts the repository identifier, generates a thread ID via generate_thread_id_from_issue, and creates a LangGraph thread.

The agent runs its reasoning loop and posts status updates back to Linear using the linear_comment tool, maintaining visibility throughout the automation process.

GitHub PR Review Assistance

Open SWE acts as an autonomous contributor during code review cycles. When a reviewer tags @open-swe in a PR comment requesting changes, the process_github_pr_comment handler activates. It fetches all comments since the last tag via fetch_pr_comments_since_last_tag, aggregates the requirements, and generates the necessary code changes in the sandbox.

The agent then pushes a new commit to the same branch using the GitHub tool suite, effectively acting as a responsive team member that never forgets to address feedback.

Custom CI-Style Validation

Organizations can extend Open SWE to enforce quality gates before any code reaches production. By adding custom middleware in agent/middleware/, teams can invoke validation tools—such as linters, type checkers, or security scanners—before the final commit_and_open_pr execution.

For example, extending the middleware chain to include a run_linter tool ensures that every agent-generated change passes style guidelines before opening a pull request.

Multimodal Issue Handling

Modern development often involves visual context such as UI mockups or screenshots. Open SWE handles multimodal inputs through the extract_image_urls and fetch_image_block functions within process_slack_mention and process_linear_issue.

When an issue description contains image URLs, the agent downloads these resources, creates image blocks compatible with the LLM, and feeds them into the reasoning prompt—enabling the agent to generate code that matches visual specifications.

Self-Service Internal CLI

Beyond webhooks, Open SWE supports local invocation through the agent/integrations/local.py module. Engineers can run the openswe CLI locally to trigger the same server-side logic used by Slack or Linear integrations.

This self-service approach allows developers to request features, generate documentation, or refactor code directly from their terminals, reusing the sandbox and tool set without requiring external webhook infrastructure.

Implementation Examples

Starting the Server

Deploy Open SWE using Docker for production environments:


# Build and run with Docker (recommended for production)

docker build -t openswe .
docker run -e SLACK_BOT_TOKEN=… -e SLACK_SIGNING_SECRET=… \
    -e LINEAR_API_KEY=… -e GITHUB_WEBHOOK_SECRET=… \
    -p 8000:8000 openswe

The Dockerfile is located at Dockerfile.

Triggering Tasks from Slack

Interact with the agent through natural language mentions:


@open-swe please add a unit test for `utils/slack.py` covering `select_slack_context_messages`

The execution flow involves:

  1. Verification: verify_slack_signature in [agent/utils/slack.py](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/slack.py#L69) validates the request.
  2. Repository Resolution: Defaults to langchain-ai/open-swe unless overridden.
  3. Thread Management: generate_thread_id_from_slack_thread in [agent/webapp.py](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py#L66) creates deterministic IDs.
  4. Tool Execution: The commit_and_open_pr tool in [agent/tools/commit_and_open_pr.py](https://github.com/langchain-ai/open-swe/blob/main/agent/tools/commit_and_open_pr.py) creates the draft PR.
  5. Response: The agent replies in the Slack thread with the PR link.

Adding Custom Tools

Extend functionality by creating new tools. For example, adding database query capabilities:

Create agent/tools/run_sql.py:

import os
import asyncpg

async def run_sql(query: str) -> str:
    """Execute a SQL query against the configured DB and return results."""
    conn_str = os.getenv("POSTGRES_URI", "")
    if not conn_str:
        return "DB not configured."
    async with asyncpg.connect(conn_str) as conn:
        rows = await conn.fetch(query)
        return "\n".join(str(r) for r in rows)

Register the tool in the agent creation (see create_deep_agent examples in the README). After restarting the server, the LLM can invoke run_sql during its reasoning process.

Manual SDK Invocation

Trigger agent runs programmatically using the LangGraph SDK:

from langgraph_sdk import get_client

client = get_client(url="http://localhost:2024")
thread_id = "my-manual-run"

prompt = """
Please add a README file that explains how to set up the sandbox on Modal.
"""

client.runs.create(
    thread_id,
    "agent",
    input={"messages": [{"role": "user", "content": prompt}]},
    config={"configurable": {"source": "manual", "repo": {"owner": "my-org", "name": "my-repo"}}},
    if_not_exists="create",
)

This run appears in LangSmith (if configured) and follows the same middleware pipeline as webhook-triggered executions.

Key Files and Extension Points

Understanding the repository structure enables effective customization of Open SWE for specific organizational needs.

File Role Link
agent/webapp.py FastAPI entry point; webhook routing, thread ID generation, repo resolution. [webapp.py](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py)
agent/utils/slack.py Slack API wrappers, signature verification, message formatting, context selection. [slack.py](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/slack.py)
agent/utils/github.py GitHub token handling, comment extraction, PR utilities. [github.py](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/github.py)
agent/utils/sandbox.py Abstract sandbox interface; concrete back-ends (Modal, Daytona, etc.). [sandbox.py](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/sandbox.py)
agent/tools/commit_and_open_pr.py Implements the commit_and_open_pr tool that creates a draft PR. [commit_and_open_pr.py](https://github.com/langchain-ai/open-swe/blob/main/agent/tools/commit_and_open_pr.py)
agent/middleware/*.py Deterministic middleware (error handling, PR safety net, message queue). [middleware/check_message_queue.py](https://github.com/langchain-ai/open-swe/blob/main/agent/middleware/check_message_queue.py)
README.md High-level overview, installation, and usage instructions. [README.md](https://github.com/langchain-ai/open-swe/blob/main/README.md)
CUSTOMIZATION.md Guide for swapping sandboxes, adding tools, or changing prompts. [CUSTOMIZATION.md](https://github.com/langchain-ai/open-swe/blob/main/CUSTOMIZATION.md)
agent/prompt.py System prompts that embed AGENTS.md and define the agent's persona. [prompt.py](https://github.com/langchain-ai/open-swe/blob/main/agent/prompt.py)

Summary

Open SWE delivers a comprehensive framework for automating software engineering workflows through these key capabilities:

  • Modular agent architecture built on LangGraph and Deep Agents in agent/webapp.py, enabling customizable LLM-driven automation
  • Secure sandboxed execution via agent/utils/sandbox.py with support for Modal, Daytona, and Runloop to isolate code changes
  • Multi-platform integration through webhooks for Slack, Linear, and GitHub, allowing agents to operate within existing developer workflows
  • Extensible tool system defined in agent/tools/__init__.py and agent/tools/commit_and_open_pr.py, supporting custom operations from database queries to PR creation
  • Deterministic safety middleware in agent/middleware/check_message_queue.py ensuring reliable execution and automatic error recovery

Frequently Asked Questions

What is Open SWE and how does it differ from other coding assistants?

Open SWE is an open-source framework specifically designed for building internal coding agents that integrate with your existing infrastructure. Unlike closed-source alternatives, Open SWE provides full access to the agent harness in agent/webapp.py, sandbox abstractions in agent/utils/sandbox.py, and middleware layers, allowing organizations to customize security policies, tool access, and execution environments according to internal requirements.

Can Open SWE handle visual inputs like UI mockups or screenshots?

Yes, Open SWE supports multimodal issue handling through the extract_image_urls and fetch_image_block functions implemented in process_slack_mention and process_linear_issue. When issue descriptions contain image URLs, the agent downloads these resources, creates image blocks compatible with the LLM, and incorporates visual context into its reasoning process—enabling generation of code that matches specific UI specifications or design mockups.

How does Open SWE ensure security when executing arbitrary code?

Security is enforced through multiple layers: sandboxed execution environments in agent/utils/sandbox.py isolate all code in containers (supporting Modal, Daytona, or Runloop backends) with no access to production resources. Encrypted token storage in agent/utils/auth.py manages GitHub App credentials per-thread. Deterministic middleware in agent/middleware/check_message_queue.py provides safety nets like open_pr_if_needed to ensure changes are reviewed before merging.

Can I integrate Open SWE with custom internal tools or databases?

Absolutely. Open SWE's modular tool system allows extension through the agent/tools/ directory. You can create new Python modules defining async functions (like the run_sql example for database queries) and register them in the agent creation configuration. The framework reuses the same sandbox and middleware pipeline for custom tools, ensuring consistent security and error handling across standard and custom operations.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →