Skip to content
/

Sweep AI

sweep · sweepai/sweep · ★ 7.7k · last commit 2025-09-18

Primitive shape 17 total
Commands 4 Subagents 13
00

Summary

Sweep AI — Summary

Sweep is an AI coding assistant originally built for automated GitHub issue-to-PR resolution, now repositioned as a JetBrains plugin. The open-source repository contains the original GitHub bot and CLI; the current product focus is the JetBrains plugin (IntelliJ IDEA, PyCharm, WebStorm, etc.). The sweep.yaml config file in a repository provides project-specific rules (technology preferences, test requirements, code style), which Sweep ingests as behavioral constraints when processing issues. The core system prompt positions Sweep as a "brilliant and meticulous engineer" that writes code that "works on the first try" — an unusually strong quality claim.

Sweep is in an unusual position: the open-source CLI/bot is the codebase in this repo, but the active product is a JetBrains plugin not in this repo. The seed comparison is challenging — Sweep originally competed with SWE-agent (both fix GitHub issues autonomously) but has moved to a different market segment (IDE plugin vs CLI benchmark tool). No seed framework occupies the same architectural space.

01

Overview

Sweep AI — Overview

Origin

Created by the Sweep AI team. Originally a GitHub-integrated bot that automatically creates PRs from GitHub issues. The project pivoted to a JetBrains plugin.

Current Status

From README (the entire content):

"Hi everyone! Thank you for all of the support on Sweep. We're now building an AI coding assistant for JetBrains which is available here: https://plugins.jetbrains.com/plugin/26275-sweep-ai"

The GitHub repository contains the original open-source codebase (GitHub bot, CLI, web interface), but the team's current focus is the JetBrains plugin which is not in this repository.

Original Philosophy (from sweepai/core/prompts.py)

system_message_prompt = """\
You are a brilliant and meticulous engineer assigned to write code for the following Github issue. When you write code, the code works on the first try, is syntactically perfect and is fully implemented. You have the utmost care for the code that you write, so you do not make mistakes and every function and class will be fully implemented. When writing tests, you will ensure the tests are fully implemented, very extensive and cover all cases, and you will make up test data as needed. Take into account the current repository's language, frameworks, and dependencies."""

This is one of the strongest quality claims in any system prompt in this corpus: "works on the first try, is syntactically perfect and is fully implemented."

sweep.yaml Config

Repositories can configure Sweep behavior via sweep.yaml:

description: "sweepai/sweep is a python 3.10 project..."
rules:
  - "We should use loguru for error logging..."
  - "All functions should have parameters and output annotated with type hints..."
  - "All new business logic should have corresponding unit tests..."

This is the primary customization mechanism — project-specific rules that Sweep ingests.

02

Architecture

Sweep AI — Architecture

Distribution

The GitHub repo contains the original open-source CLI/bot:

pip install sweepai
# or
docker-compose up

The current product is a JetBrains plugin: https://plugins.jetbrains.com/plugin/26275-sweep-ai

Source Layout (Original Open-Source)

sweepai/
  core/
    prompts.py          # Core system prompts
    chat.py             # LLM chat interface
    entities.py         # Data models
    planning_prompts.py # Planning-phase prompts
    review_prompts.py   # Code review prompts
    repo_parsing_utils.py # Repository parsing
  agents/               # Specialist agents
    modify.py           # Code modification
    search_agent.py     # Code search
    question_answerer.py # Q&A
    issue_cleanup_agent.py # Issue management
    distill_issue.py    # Issue summarization
    pr_description_bot.py # PR description generation
    analyze_snippets.py # Code snippet analysis
  api.py                # FastAPI server
  cli.py                # CLI interface
  watch.py              # GitHub webhook watcher
sweep.yaml              # Project configuration (YAML)

sweep.yaml Config Format

gha_enabled: True
branch: main
blocked_dirs: ["sweepai/core/prompts.py", "..."]
draft: False
description: "project description for Sweep context"
rules:
  - "Rule 1 for code quality"
  - "Rule 2 for testing"
  - "..."

Required Runtime

  • Python 3.10 (original CLI/bot)
  • Redis (for the full stack)
  • Docker (recommended for full deployment)
  • JetBrains IDE (for the current product)

Target AI Tools (Original)

  • OpenAI GPT-4 (primary)
  • Anthropic Claude (supported)
03

Components

Sweep AI — Components

Agents (sweepai/agents/)

Agent Purpose
modify.py Core code modification agent
search_agent.py Code search and retrieval
question_answerer.py Q&A about codebase
issue_cleanup_agent.py GitHub issue management
distill_issue.py Extract essence from GitHub issue
pr_description_bot.py Generate PR descriptions
analyze_snippets.py Analyze relevant code snippets
complete_code.py Code completion
image_description_bot.py Describe images attached to issues
prune_modify_snippets.py Prune irrelevant code snippets
rg_extractor.py Extract code using ripgrep
summarize_directory.py Summarize directory contents
summarize_file.py Summarize file contents

Core Prompts (sweepai/core/prompts.py)

Prompt Purpose
system_message_prompt Main engineering persona ("works on the first try")
snippet_replacement_system_message Select relevant code snippets
review_prompt Code review prompt
human_message_prompt Structured context injection (snippets, tree, metadata)

sweep.yaml (Project Config)

The primary user customization point:

  • description: Project context for Sweep
  • rules: Array of code quality/style rules
  • blocked_dirs: Directories Sweep should not modify
  • gha_enabled: GitHub Actions integration
  • branch: Default branch
  • draft: Create PRs as drafts

Web Interface (sweep_chat/)

Original Sweep had a web chat interface for interacting with the bot.

CLI (sweepai/cli.py)

Original command-line interface for running Sweep locally.

05

Prompts

Sweep AI — Prompts

Prompt 1: Core Engineering System Prompt

Source: sweepai/core/prompts.pysystem_message_prompt

Technique: Aspirational persona with extreme quality claims. Unlike most system prompts that describe capabilities, this one asserts results ("works on the first try").

system_message_prompt = """\
You are a brilliant and meticulous engineer assigned to write code for the following Github issue. When you write code, the code works on the first try, is syntactically perfect and is fully implemented. You have the utmost care for the code that you write, so you do not make mistakes and every function and class will be fully implemented. When writing tests, you will ensure the tests are fully implemented, very extensive and cover all cases, and you will make up test data as needed. Take into account the current repository's language, frameworks, and dependencies."""

This is one of the strongest quality-assertion system prompts in this corpus. The hypothesis: asserting "works on the first try" primes the model to be more careful.


Prompt 2: Snippet Selection Prompt

Source: sweepai/core/prompts.pysnippet_replacement_system_message

Technique: Context-before-action — select relevant context before generating code changes. The <contextual_thoughts> XML tags force structured reasoning.

snippet_replacement_system_message = f"""{system_message_prompt}

You are selecting relevant snippets for this issue. You must only select files that would help you understand the context of this issue.

## Snippet Step

In order to address this issue, what required information do you need about the snippets? Only include relevant code and required file imports that provides you enough detail about the snippets for the problems:

Note: Do not select the entire file. Only select relevant lines from these files. Keep the relevant_snippets as small as possible.

<contextual_thoughts>
* Thought_1
* Thought_2
...
</contextual_thoughts>

<relevant_snippets>
folder_1/file_1.py:1-13
folder_2/file_2.py:42-75
...
</relevant_snippets>
"""

Prompt 3: sweep.yaml Rules (Project Config as Prompt)

Source: sweep.yaml in the Sweep repository itself

Technique: Project rules as behavioral constraints injected at runtime. Each rule is a code quality requirement.

rules:
  - "We should use loguru for error logging. If the log is inside an exception, use logger.exception to add tracebacks..."
  - "There should be no debug log or print statements in production code."
  - "All functions should have parameters and output annotated with type hints. Use list, tuple and dict instead of typing.List..."
  - "All new business logic should have corresponding unit tests in the same directory..."
  - "Any clearly inefficient or repeated code should be optimized or refactored."
  - "Remove any comments before code that are obvious..."

Prompting Techniques Used

  1. Aspirational quality assertion: "works on the first try, is syntactically perfect" — setting high expectations in persona
  2. XML-tagged structured thinking: <contextual_thoughts> forces the model to reason before selecting snippets
  3. Minimal snippet selection: "Keep the relevant_snippets as small as possible" — explicit constraint on context size
  4. Project rules as runtime constraints: sweep.yaml rules injected as behavioral requirements per-project
  5. Prefix+suffix structured context: human_message_prompt provides multi-turn context with labeled sections (snippets, directories, commit history, repo tree, metadata)
09

Uniqueness

Sweep — Uniqueness and Seed Comparison

Differs From Seeds

Sweep is the original GitHub-native issue-to-PR automation agent. The seed frameworks (spec-kit, openspec, BMAD, etc.) sit on top of agents like Sweep — they provide specification scaffolding that is then executed by underlying coding agents. Sweep is the execution layer that those spec frameworks assume exists.

Specifically:

  • No seed framework occupies Sweep's original niche (fully autonomous GitHub bot: issue → PR without human steps)
  • Sweep introduced project rules via sweep.yaml — the idea of per-project behavioral constraints injected at runtime; seed frameworks copy this pattern but add spec-phase artifacts
  • Sweep's sequential multi-agent pipeline (distill → search → prune → modify → PR) is more sophisticated than seed frameworks' single-agent prompts

Unique Characteristics

1. Aspirational Quality Assertion Prompting

Sweep's core system prompt contains one of the strongest quality claims in this corpus:

"the code works on the first try, is syntactically perfect and is fully implemented"

No other framework in this batch asserts this as a behavioral constraint. The hypothesis: explicitly stating impossibly high standards primes the model toward more careful code generation.

2. project-as-behavioral-constraints via sweep.yaml

sweep.yaml converts project knowledge into runtime behavioral rules. This predates similar patterns in CLAUDE.md, .cursorrules, and .clinerules. The blocked_dirs field (including Sweep blocking its own sweepai/core/prompts.py) shows the pattern taken to its logical extreme.

3. Sequential Multi-Agent Pipeline with Self-Scoring

The 25-iteration context pruning loop with a 1–10 self-scoring gate (SCORE_THRESHOLD = 8) is distinctive. The agent evaluates its own context quality before proceeding to modification — an automated quality gate that other frameworks lack.

4. XML-Tagged Structured Reasoning

<contextual_thoughts> XML tags force structured reasoning before snippet selection. This predates widespread use of chain-of-thought XML tags.

5. Pivot Story

Sweep demonstrates what happens when an open-source GitHub bot product fails to achieve commercial traction and pivots to IDE plugin. The codebase is partly dormant (last meaningful commit 2025-09-18) while the JetBrains plugin is the active commercial surface. This is the clearest product-pivot story in this batch.

What Sweep Is Not

  • Not a benchmark tool — unlike SWE-agent, Sweep was never designed for SWE-bench evaluation
  • Not a recipe/config-sharing system — unlike Goose, there is no Sweep equivalent of shareable YAML agent configs
  • Not a REPL — unlike SWE-agent's one-command-per-turn, Sweep's pipeline is a single end-to-end run per issue
  • Not a code completion server — unlike Tabby, Sweep does not provide FIM completions

Relation to Other Batch Frameworks

Framework Relationship to Sweep
SWE-agent Direct competitor (both fix GitHub issues); SWE-agent focuses on research/benchmarks, Sweep focused on production use
OpenHands Architectural successor: more sophisticated Docker isolation, richer tool use, better SWE-bench scores
Aider Different market segment: Aider is interactive CLI, Sweep is autonomous bot; both influenced each other's prompting patterns
gpt-engineer Both are archived/pivoted pioneers; gpt-engineer → Lovable.dev, Sweep → JetBrains plugin
04

Workflow

Sweep AI — Workflow

Original GitHub Bot Workflow

  1. GitHub issue created — in a repo with Sweep bot installed
  2. Sweep triggered — GitHub webhook fires; Sweep receives issue
  3. Issue distillationdistill_issue.py extracts the core request
  4. Repository searchsearch_agent.py finds relevant code
  5. Snippet selection — prune and rank relevant snippets
  6. Code modificationmodify.py generates the changes
  7. PR creation — Sweep creates a PR with the changes
  8. PR descriptionpr_description_bot.py generates description
  9. Human review — developer reviews and approves/requests changes

CLI Workflow

sweep "<issue description>"  # from local repo

sweep.yaml Customization

Organizations add sweep.yaml to their repo to configure Sweep's behavior:

  • Define project context (description)
  • Specify code quality rules
  • Block certain directories from modification

Phases + Artifacts Table

Phase Artifact
Issue distillation Extracted task description
Repository search Ranked code snippets
Code modification Changed files
PR creation GitHub PR
PR description PR title and description

Approval Gates

Gate Type Notes
PR review human-required Standard GitHub PR review
Draft PR flag N/A draft: True creates draft PRs for review before marking ready
06

Memory Context

Sweep — Memory and Context

State Storage

State Storage Scope
Chat conversation In-memory ChatGPT object Per-request
Ticket progress MongoDB (llm.tickets) Cross-request, per-issue
Chat history MongoDB (llm.chat_history) 28-day TTL
Code embeddings OpenAI embeddings (via API) Per-repo
Rate-limiting data Redis Per-user session
Project config sweep.yaml in repo Persistent, per-project

MongoDB Persistence

sweepai/utils/chat_logger.py uses pymongo with two collections:

  • chat_collection (llm.chat_history): stores full conversation turns; 28-day TTL via expireAfterSeconds=2419200
  • ticket_collection (llm.tickets): stores per-ticket metadata indexed by username
global_mongo_client = None
if MONGODB_URI:
    global_mongo_client = MongoClient(
        MONGODB_URI,
        serverSelectionTimeoutMS=20000,
        socketTimeoutMS=20000,
    )

Redis (Async Queue / Rate Limiting)

REDIS_URL defaults to redis://0.0.0.0:6379/0. Redis is used as:

  • Async job queue for GitHub webhook processing
  • Rate-limiting counter per user

Context Pruning

sweepai/core/context_pruning.py manages what code context is fed to the model:

  • MAX_ITERATIONS = 25 — maximum search/view cycles during context gathering
  • MAX_REFLECTIONS = 1 — one reflection pass allowed
  • NUM_ROLLOUTS = 1 — single attempt (not beam search in production)
  • SCORE_THRESHOLD = 8 — stops early if context quality is rated ≥8/10 by self-evaluator
  • STOP_AFTER_SCORE_THRESHOLD_IDX = 0 — stops at first high-score iteration

The commented-out code shows previously tracked previously_viewed_files to avoid re-fetching; this was simplified to the current rollout approach.

No Cross-Issue Memory

Each GitHub issue is processed independently. There is no vector database of previous decisions, no accumulated knowledge across issues. The MongoDB ticket collection stores metadata but not learnable patterns.

sweep.yaml as Persistent Context

The sweep.yaml file in the repo root acts as the only cross-issue persistent context — project rules, blocked dirs, allowed dirs, and branch settings are injected into every request.

Context Window Management

The snippet_replacement_system_message prompt explicitly constrains context: "Keep the relevant_snippets as small as possible." The ASSISTANT_MAX_CHARS = 4096 * 4 * 0.95 constant (~95% of 4k tokens) caps snippet content injected per turn.

07

Orchestration

Sweep — Orchestration

Pattern: Sequential Multi-Agent Pipeline

Sweep uses a fixed sequential pipeline of specialist agents. There is no dynamic routing, no parallel execution, and no branching based on issue type. Every issue flows through the same ordered pipeline.

Agent Pipeline

Step Agent Source File Role
1 Distill Issue sweepai/agents/distill_issue.py Extract intent, reproduce context
2 Search Agent sweepai/agents/search_agent.py Find relevant code files via ripgrep
3 Context Pruning sweepai/core/context_pruning.py Select and rank snippets (25 iterations max)
4 Analyze Snippets sweepai/agents/analyze_snippets.py Understand what needs to change
5 Modify sweepai/agents/modify.py Make the actual code edits
6 Complete Code sweepai/agents/complete_code.py Fill in incomplete sections
7 PR Description Bot sweepai/agents/pr_description_bot.py Generate PR title and body

Additional specialist agents (from sweepai/agents/):

  • image_description_bot.py — describe images in issues
  • issue_cleanup_agent.py — clean up issue text
  • prune_modify_snippets.py — prune snippets before modification
  • rg_extractor.py — ripgrep result post-processing
  • question_answerer.py — answer clarifying questions

Event-Driven Trigger

The pipeline is triggered by GitHub webhook events:

  • issues event → new issue opened → full pipeline
  • issue_comment event → comment added → partial pipeline (skip distill)
  • pull_request_review event → review submitted → modify pipeline only

No Parallel Execution

context_pruning.py shows NUM_ROLLOUTS = 1 — single sequential attempt. No beam search, no parallel hypothesis generation. The rollout-based architecture allows for future parallelism but is disabled in production (# dev speed comment).

Orchestration Code Path

GitHub Webhook → Redis Queue → sweepai/api.py → on_ticket() → pipeline steps

The sweepai/api.py (or sweepai/handlers/) receives the event, enqueues it, and a worker process executes the full pipeline.

Self-Reflection Gate

During context pruning, a self-evaluation step scores the collected context 1–10. If the score reaches SCORE_THRESHOLD = 8, the pipeline continues to modification. The reflection prompt (injected from context_pruning.py) includes:

Here is the feedback from your previous attempt. You MUST read this extremely carefully
and follow ALL of the reviewer's advice.
Rating from previous attempt: {score} / 10

Single Model

Sweep uses a single model throughout the pipeline (GPT-4 or Claude depending on config). There is no per-step model routing; the same model handles context gathering, code modification, and PR description.

No Human Approval Gate

The pipeline runs fully automatically from issue to opened PR. The repo's sweep.yaml can configure draft: true to open PRs as drafts, but there is no interactive pause.

08

Ui Cli Surface

Sweep — UI and CLI Surface

CLI Binary

Two entry points, both mapped to sweepai.cli:main:

[project.scripts]
sweep = "sweepai.cli:main"
sweepai = "sweepai.cli:main"

Built with Typer.

CLI Commands

Command Description
sweep run <issue_url> Run Sweep on a single GitHub issue URL
sweep watch Watch for new issues on a repository
sweep init Initialize config at ~/.config/sweepai/config.json
sweep test Test configuration and connectivity

Config Storage

sweep init stores credentials at ~/.config/sweepai/config.json:

  • GITHUB_PAT
  • OPENAI_API_KEY
  • ANTHROPIC_API_KEY
  • VOYAGE_API_KEY
  • POSTHOG_DISTINCT_ID

GitHub Bot Interface (Primary Historical Surface)

The original and primary interface is via GitHub comments:

Trigger Mechanism
sweep: <description> label on issue Opens a PR automatically
sweep: <description> comment on issue Same as label
@sweep-ai <request> comment on PR Responds in PR comments, pushes to branch

All interactions happen inside GitHub's native issue/PR interface — no separate UI required.

sweep.yaml (Project Config)

Per-project configuration file at repo root. Injected into every Sweep run:

gpt_4_tickets: false
branch: main
description: ""
draft: false
blocked_dirs: []
allowed_dirs: []
rules:
  - "..."
sandbox:
  install: ["..."]
  check: ["..."]

JetBrains Plugin (Current Product)

As of 2025, the active product is the Sweep AI JetBrains plugin. The CLI and GitHub bot represent the original product; the JetBrains plugin is the current commercial focus.

The JetBrains plugin surface provides:

  • In-editor chat interface
  • Direct code modification within IDE
  • No CLI invocation needed

No Standalone Web UI

The repository has no frontend directory or web app. The GitHub webhook server (sweepai/api.py) serves only the webhook endpoint — it has no user-facing HTML interface.

Webhook Server

When self-hosting, sweepai/api.py exposes:

  • POST / — GitHub webhook receiver
  • Processes issues, issue_comment, pull_request_review events

No admin dashboard, no user portal.

Related frameworks

same archetype · same primary tool · same memory type

OpenHarness ★ 13k

Open-source Python agent runtime providing complete harness infrastructure: tools, memory, governance, swarm coordination, and…

Trae Agent ★ 12k

Research-friendly open-source CLI coding agent by ByteDance, designed for academic ablation studies and modular LLM provider…

Agent Governance Toolkit (microsoft) ★ 2.3k

Enterprise-grade AI agent governance: YAML policy enforcement, 12-vector prompt injection defense, zero-trust identity,…

TDD Guard ★ 2.1k

Mechanically enforces the Red-Green-Refactor TDD cycle by blocking file writes that violate TDD principles via a PreToolUse hook…

Agentic Coding Flywheel Setup (ACFS) ★ 1.5k

Take a complete beginner from laptop to three AI coding agents running on a VPS in 30 minutes via an idempotent manifest-driven…

leash (strongdm) ★ 565

Wraps AI coding agents in containers with eBPF-enforced Cedar policies, making policy violations (unauthorized file access,…