# Open SWE Examples: Real-World Integrations with Slack, Linear, and GitHub

> Explore Open SWE examples integrating Slack Linear and GitHub. See how it automates pull requests using webhook parsing LangGraph agents and sandboxed environments. Discover real-world applications.

- Repository: [LangChain/open-swe](https://github.com/langchain-ai/open-swe)
- Tags: examples
- Published: 2026-03-19

---

**Open SWE transforms @mentions in Slack, Linear, and GitHub into automated pull requests by parsing webhooks, generating deterministic thread IDs, and orchestrating LangGraph agents in isolated sandboxes.**

The `langchain-ai/open-swe` repository provides concrete **open swe examples** that demonstrate how AI agents integrate directly into existing engineering workflows. By examining the webhook handlers in [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) and supporting utilities, developers can implement autonomous coding assistants that respond to natural language requests from the tools teams already use.

## How Open SWE Processes Real-World Requests

When a user tags `@openswe` (or the legacy `@open-swe`) in a connected platform, the framework executes a deterministic pipeline:

1. **Detects the trigger** via platform-specific webhooks (Slack app-mention, Linear comment, or GitHub issue/PR comment).
2. **Resolves a deterministic thread ID** using `generate_thread_id_from_slack_thread` or `generate_thread_id_from_github_issue` in [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) (lines 66-71) to maintain conversation state across multiple turns.
3. **Collects contextual information** including full issue descriptions, prior comment history, Slack thread messages, or Linear ticket details.
4. **Builds a structured prompt** that injects repository configuration, user requests, and any attached images.
5. **Executes the LangGraph agent** in an isolated sandbox environment (Modal, Daytona, Runloop, etc.) and automatically creates a draft PR with the generated changes.

## Platform-Specific Integration Examples

### Slack Integration Workflow

When a user mentions the bot in a thread, the `slack_webhook` handler (POST `/webhooks/slack`) at lines 665-680 of [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) receives the payload. The system then invokes `process_slack_mention` (lines 1055-1083) to resolve repository configuration via `get_slack_repo_config` and select relevant context using `select_slack_context_messages`.

**Key code paths:**

- **Entry point:** [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) → `slack_webhook` (lines 665-680)
- **Processing logic:** [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) → `process_slack_mention` (lines 1055-1083)
- **Context selection:** [`agent/utils/slack.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/slack.py) → `select_slack_context_messages` (lines 140-180)

### Linear Integration Workflow

For Linear tickets, the `linear_webhook` handler (POST `/webhooks/linear`) at lines 441-466 triggers `process_linear_issue` (lines 823-894). The system pulls the full Linear issue via GraphQL, constructs a prompt with ticket context, and initiates a LangGraph run with the deterministic thread ID derived from the Linear issue identifier.

**Key code paths:**

- **Entry point:** [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) → `linear_webhook` (lines 441-466)
- **Processing logic:** [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) → `process_linear_issue` (lines 823-894)

### GitHub Integration Workflow

GitHub comments or issues containing `@openswe` trigger the `github_webhook` handler (POST `/webhooks/github`) at lines 997-1020. The `process_github_issue` function (lines 1281-1329) resolves per-user GitHub tokens via the auth utilities, reacts with a 👀 emoji to acknowledge receipt, fetches issue context including previous comments, and builds a prompt using `build_github_issue_prompt`.

**Key code paths:**

- **Entry point:** [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) → `github_webhook` (lines 997-1020)
- **Processing logic:** [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) → `process_github_issue` (lines 1281-1329)
- **Prompt construction:** `build_github_issue_prompt` (lines 1104-1119)

## Deep Dive: Slack Mention Processing

The following walkthrough demonstrates the exact code flow when processing a Slack mention, based on the implementation in [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py):

```python

# 1️⃣ Slack request arrives (see test for a concrete payload)

client.post(
    "/webhooks/slack",
    json={
        "type": "event_callback",
        "event": {
            "type": "app_mention",
            "channel": "C12345",
            "thread_ts": "1730900000.123456",
            "user": "U42",
            "text": "<@UBOT> list all .py files"
        },
    },
    headers={...},
)

# 2️⃣ `process_slack_mention` extracts the thread ID

thread_id = generate_thread_id_from_slack_thread("C12345", "1730900000.123456")

# → UUID based on MD5 of "C12345:1730900000.123456" (see lines 66-70)

# 3️⃣ Repo resolution (`get_slack_repo_config`)

#    – respects explicit `repo:owner/name` syntax,

#    – falls back to thread‑metadata or defaults (SLACK_REPO_OWNER/NAME)

repo = await get_slack_repo_config(message, "C12345", "1730900000.123456")

# Example outcome: {"owner": "langchain-ai", "name": "open-swe"}

# 4️⃣ Context selection (`select_slack_context_messages`)

#    – if a prior bot mention exists, it starts from that point;

#    – otherwise it uses the entire thread up to the current event.

context, mode = select_slack_context_messages(messages, event_ts, bot_user_id)

# 5️⃣ Prompt construction (embedded in `process_slack_mention`)

prompt = f"""You were mentioned in Slack.

## Repository

{repo['owner']}/{repo['name']}

## Slack Thread

- Channel: {channel_id}
- Thread TS: {thread_ts}
- Context starts at: {context_source}

## Conversation Context

{format_slack_messages_for_prompt(context, user_names_by_id, bot_user_id, bot_username)}

## Latest Mention Request

{clean_text}
"""

# 6️⃣ LangGraph run is created (or queued if the thread is busy)

await langgraph_client.runs.create(
    thread_id, "agent",
    input={"messages": [{"role": "user", "content": [create_text_block(prompt)]}]},
    config={"configurable": configurable, "metadata": _AGENT_VERSION_METADATA},
    if_not_exists="create",
)

```

The same orchestration pattern applies to Linear and GitHub integrations, differing only in webhook parsing and token resolution mechanisms.

## Standalone Code Examples

The following snippets demonstrate core utilities that developers can run locally to understand Open SWE's internal mechanics.

### Generating Deterministic Thread IDs

The `generate_thread_id_from_slack_thread` function creates UUIDs that consistently map Slack threads to LangGraph conversation threads:

```python
from agent.webapp import generate_thread_id_from_slack_thread

channel_id = "C12345"
thread_ts = "1730900000.123456"
thread_id = generate_thread_id_from_slack_thread(channel_id, thread_ts)
print(thread_id)   # e.g. "3a6f0c5e-2c1b-4e4a-9b2c-1d5f8e3a4c9b"

```

This implementation uses `hashlib.md5` on the string `"C12345:1730900000.123456"` and constructs a valid UUID (see [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py), lines 66-70).

### Selecting Slack Context Windows

The `select_slack_context_messages` utility determines which messages from a thread should be included in the LLM prompt:

```python
from agent.utils.slack import select_slack_context_messages

messages = [
    {"ts": "1.0", "text": "hello", "user": "U1"},
    {"ts": "2.0", "text": "<@UBOT> first request", "user": "U1"},
    {"ts": "3.0", "text": "extra info", "user": "U2"},
    {"ts": "4.0", "text": "<@UBOT> second request", "user": "U3"},
]

selected, mode = select_slack_context_messages(messages, "4.0", "UBOT")
print(mode)          # → "last_mention"

print([m["ts"] for m in selected])  # → ["2.0", "3.0", "4.0"]

```

The function scans for the last bot mention and returns all messages from that point onward (see [`agent/utils/slack.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/slack.py), lines 140-180).

### Building GitHub Issue Prompts

The `build_github_issue_prompt` function constructs rich prompts that include issue metadata and recent comment history:

```python
from agent.webapp import build_github_issue_prompt

prompt = build_github_issue_prompt(
    {"owner": "langchain-ai", "name": "open-swe"},
    issue_number=42,
    issue_id="12345",
    title="Fix flaky test",
    body="The test fails intermittently.",
    comments=[{"author": "octocat", "body": "Please take a look", "created_at": "2026-03-09T00:00:00Z"}],
    github_login="octocat",
)

print(prompt)

```

The resulting string instructs the agent to work on the specific issue, includes the full description and recent comments, and reminds the agent to use the `github_comment` tool (see [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py), lines 1104-1119).

## Key Source Files Reference

Understanding these files is essential for implementing custom Open SWE integrations:

- **[`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py)** – FastAPI entry point containing webhook handlers for Linear, Slack, and GitHub; thread ID generation; and prompt orchestration (lines 66-71, 441-466, 665-680, 997-1020, 1055-1083, 1281-1329).
- **[`agent/utils/slack.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/slack.py)** – Slack-specific utilities for reactions, thread history fetching, message formatting, and repository detection from user text (lines 140-180).
- **[`agent/utils/github_comments.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/github_comments.py)** – Constants and utilities for detecting `@openswe` tags, extracting PR context, and sanitizing comment bodies.
- **[`agent/utils/auth.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/auth.py)** – GitHub OAuth flow implementation for per-user or bot-token authentication with error handling and token persistence.
- **[`tests/test_slack_context.py`](https://github.com/langchain-ai/open-swe/blob/main/tests/test_slack_context.py)** – Unit tests that serve as runnable examples of Slack context selection and repository parsing logic.
- **[`tests/test_github_issue_webhook.py`](https://github.com/langchain-ai/open-swe/blob/main/tests/test_github_issue_webhook.py)** – Tests demonstrating GitHub webhook handling, prompt building, and token resolution workflows.

## Summary

- **Open SWE integrates with Slack, Linear, and GitHub** through webhook handlers in [`agent/webapp.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/webapp.py) that detect `@openswe` mentions and trigger LangGraph agents.
- **Deterministic thread IDs** ensure conversation continuity across multiple interactions, generated via `generate_thread_id_from_slack_thread` or platform-specific alternatives.
- **Rich context collection** pulls thread history, issue comments, and repository configuration to build comprehensive LLM prompts.
- **Sandboxed execution** runs agents in isolated environments (Modal, Daytona, Runloop) before automatically creating draft PRs with the proposed changes.
- **Runnable examples** in the test suite demonstrate context selection, prompt building, and webhook processing for local development and debugging.

## Frequently Asked Questions

### How does Open SWE determine which repository to modify?

The system uses platform-specific resolution logic. In Slack, `get_slack_repo_config` checks for explicit `repo:owner/name` syntax in the message text, falls back to thread metadata if available, and finally defaults to environment variables (`SLACK_REPO_OWNER` and `SLACK_REPO_NAME`). For GitHub, the repository is derived directly from the webhook payload's repository field.

### What sandbox environments does Open SWE support for agent execution?

According to the source code, Open SWE supports multiple isolated execution backends including **Modal**, **Daytona**, and **Runloop**. These sandboxes provide secure environments where the LangGraph agent can clone repositories, execute code, run tests, and generate diffs before submitting pull requests.

### How does Open SWE handle conversation context in long Slack threads?

The `select_slack_context_messages` function in [`agent/utils/slack.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/slack.py) implements an intelligent sliding window. If the thread contains previous bot mentions, it returns only messages from the most recent mention onward (mode: `"last_mention"`). Otherwise, it includes the entire thread history up to the current event, preventing token overflow while maintaining relevant context.

### Can Open SWE authenticate as individual users rather than a bot account?

Yes. The [`agent/utils/auth.py`](https://github.com/langchain-ai/open-swe/blob/main/agent/utils/auth.py) module implements a per-user GitHub OAuth flow that resolves individual access tokens via `get_github_token_for_github_login`. When a user-specific token is unavailable, the system gracefully falls back to a bot token for public repository operations, ensuring continuous operation while respecting user permissions for private repositories.