Sandbox
@Agent-Field/SWE-AF

Multi-agent engineering runtime for AgentField

SWE-AF is a control stack for agent-led software work. It coordinates planning, coding, testing, review, and merge steps across one repo or many repos, using isolated worktrees, role-based model settings, and replanning when work gets stuck.

993 stars173 forksGoUpdated 7d ago
Who it's for

Builders who want Claude Code or Codex to handle a full PR workflow across one or more repositories.

What it delivers

You can turn a goal into a reviewed, tested, and merged change without running each step yourself.

What it does

Role-based engineering team

Runs planner, coder, reviewer, tester, merger, and verifier roles as separate agents.

Single-repo and multi-repo builds

Handles one codebase or a dependency chain of repositories in one coordinated build.

Adaptive replanning

Retries failed work, splits issues, or replans the remaining DAG when an issue gets hard.

Model routing by role

Lets you assign different models to coder, QA, architect, and other roles in one config.

Checkpointed long runs

Supports `resume_build` after crashes or interruptions.

Web search for open runtime

Can enable external search and fetch tools for coding and review through env flags.

How to get it

  1. 1Already running an AgentField control plane? Install SWE-AF straight from GitHub — no…
    af install https://github.com/Agent-Field/SWE-AF
    af run swe-planner
  2. 2af install clones the repo, provisions an isolated Python environment, and registers the…
    af call swe-planner.build --in '{"goal": "Add JWT auth", "repo_url": "https://github.com/user/my-repo"}'
  3. 3Once deployed, trigger a build
    curl -X POST https://<control-plane>.up.railway.app/api/v1/execute/async/swe-planner.build \
      -H "Content-Type: application/json" \
      -H "X-API-Key: this-is-a-secret" \
      -d '{"input": {"goal": "Add JWT auth", "repo_url": "https://github.com/user/my-repo"}}'
  4. 4Run
    python3.12 -m venv .venv
    source .venv/bin/activate
    python -m pip install --upgrade pip
    python -m pip install -e ".[dev]"
  5. 5Run
    af                 # starts AgentField control plane on :8080
    python -m swe_af   # registers node id "swe-planner"
  6. 6For Infron with open_code, set INFRON_API_KEY and use infron/ / (for example…
    SWE_DEFAULT_MODEL=infron/moonshotai/kimi-k2.6

README

SWE-AF

Autonomous Engineering Team Runtime Built on AgentField

Pronounced: "swee-AF" (one word)

Public Beta Python License Tests Built with AgentField More from Agent-Field WorldSpace Community Developer Example PR

One API call → full engineering team → shipped code.

Quick StartWhy SWE-AFIn ActionFactory ControlBenchmarkModesAPIArchitecture

One API call spins up a full autonomous engineering team — product managers, architects, coders, reviewers, testers — that scopes, builds, adapts, and ships complex software end to end. SWE-AF is a first step toward autonomous software engineering factories, scaling from simple goals to hard multi-issue programs with hundreds to thousands of agent invocations.

SWE-AF autonomous engineering fleet banner

One-Call DX

Trigger it with the af CLI (requires af ≥ 0.1.87) — it streams live progress and prints the result:

af call swe-planner.build --in '{
  "goal": "Refactor and harden auth + billing flows",
  "repo_url": "https://github.com/user/my-project",
  "config": {
    "runtime": "claude_code",
    "models": { "default": "sonnet", "coder": "opus", "qa": "opus" },
    "enable_learning": true
  }
}'

Prefer raw HTTP? Hit the API directly with curl:

curl -X POST http://localhost:8080/api/v1/execute/async/swe-planner.build \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "input": {
    "goal": "Refactor and harden auth + billing flows",
    "repo_url": "https://github.com/user/my-project",
    "config": {
      "runtime": "claude_code",
      "models": {
        "default": "sonnet",
        "coder": "opus",
        "qa": "opus"
      },
      "enable_learning": true
    }
  }
}
JSON

Swap models.default and any role key (coder, qa, architect, etc.) to any model your runtime supports.

Operating Modes

SWE-AF works in two modes: point it at a single repository, or orchestrate coordinated changes across multiple repos in one build.

Single-Repository Mode

The default. Pass repo_url (remote) or repo_path (local) and SWE-AF handles everything:

curl -X POST http://localhost:8080/api/v1/execute/async/swe-planner.build \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "goal": "Add JWT auth",
      "repo_url": "https://github.com/user/my-project"
    }
  }'

Multi-Repository Mode

When your work spans multiple codebases — a primary app plus shared libraries, monorepo sub-projects, or dependent microservices — pass config.repos as an array with roles:

curl -X POST http://localhost:8080/api/v1/execute/async/swe-planner.build \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "goal": "Add JWT auth across API and shared-lib",
      "config": {
        "repos": [
          {
            "repo_url": "https://github.com/org/main-app",
            "role": "primary"
          },
          {
            "repo_url": "https://github.com/org/shared-lib",
            "role": "dependency"
          }
        ],
        "runtime": "claude_code",
        "models": {
          "default": "sonnet"
        }
      }
    }
  }'

Roles:

  • primary — The main application. Changes here drive the build; failures block progress.
  • dependency — Libraries or services modified to support the primary repo. Failures are captured but don't block.

Use cases:

  • Primary app + shared SDK or utilities library
  • Monorepo sub-projects that live in separate repos
  • Feature spanning multiple microservices (e.g., API + worker queue)

Autonomous Build Spotlight

Rust-based Python compiler benchmark (built autonomously):

MetricCPython (subprocess)RustPython (SWE-AF)Improvement
Steady-state executionBaseline (~19ms)Optimized in-process runtime88.3x-602.3x faster
Geometric mean1.0x baseline253.8x253.8x
Peak throughput~52 ops/s31,807 ops/s~612x
Measurement methodology

Throughput comparison measures different execution models: CPython subprocess spawn (~19ms per call → ~52 ops/s) vs RustPython pre-warmed interpreter pool (in-process). This is the real-world tradeoff the system was built to optimize — replacing repeated subprocess invocations with a persistent pool for short-snippet execution.

Artifact trail includes 175 tracked autonomous agents across planning, coding, review, merge, and verification.

Details: examples/llm-rust-python-compiler-sonnet/README.md

Why SWE-AF

Most agent frameworks wrap a single coder loop. SWE-AF is a coordinated engineering factory — planning, execution, and governance agents run as a control stack that adapts in real time.

  • Hardness-aware execution — easy issues pass through quickly, while hard issues trigger deeper adaptation and DAG-level replanning instead of blind retries.
  • Factory architecture — not a single-agent wrapper. Planning, execution, and governance agents run as a coordinated control stack — the architecture encodes the engineering strategy, not the prompts (see The Atomic Unit of Intelligence).
  • Multi-model, multi-provider — assign different models per role (coder: opus, qa: haiku). Works with Claude, OpenRouter, OpenAI, and Google.
  • Continual learning — with enable_learning=true, conventions and failure patterns discovered early are injected into downstream issues.
  • Agent-scale parallelism — dependency-level scheduling + isolated git worktrees allow large fan-out without branch collisions.
  • Fleet-scale orchestration — many SWE-AF nodes can run continuously in parallel via AgentField, driving thousands of agent invocations across concurrent builds.
  • Explicit compromise tracking — when scope is relaxed, debt is typed, severity-rated, and propagated.
  • Long-run reliability — checkpointed execution supports resume_build after crashes or interruptions.

In Action

PR #179: Go SDK DID/VC Registration — built entirely by SWE-AF (Claude runtime with haiku-class models). One API call, zero human code.

MetricValue
Issues completed10/10
Tests passing217
Acceptance criteria34/34
Agent invocations79
Modelclaude-haiku-4-5
Total cost$19.23
Cost breakdown by agent role
RoleCost%
Coder$5.8830.6%
Code Reviewer$3.4818.1%
QA$1.789.2%
GitHub PR$1.668.6%
Integration Tester$1.598.3%
Merger$1.226.3%
Workspace Ops$1.779.2%
Planning (PM + Arch + TL + Sprint)$0.794.1%
Verifier + Finalize$0.341.8%
Synthesizer$0.050.2%

79 invocations, 2,070 conversation turns. Planning agents scope and decompose; coders work in parallel isolated worktrees; reviewers and QA validate each issue; merger integrates branches; verifier checks acceptance criteria against the PRD.

Claude, open-source, and Codex models supported: Run builds with any runtime and tune models per role in one flat config map.

  • runtime: "claude_code" maps to Claude backend.
  • runtime: "open_code" maps to OpenCode backend (OpenRouter/OpenAI/Google/Anthropic model IDs).
  • runtime: "codex" maps to the OpenAI Codex CLI backend.

Adaptive Factory Control

SWE-AF uses three nested control loops to adapt to task difficulty in real time:

LoopScopeTriggerAction
Inner loopSingle issueQA/review failsCoder retries with feedback
Middle loopSingle issueInner loop exhaustedrun_issue_advisor retries with a new approach, splits work, or accepts with debt
Outer loopRemaining DAGEscalated failuresrun_replanner restructures remaining issues and dependencies

This is the core factory-control behavior: control agents supervise worker agents and continuously reshape the plan as reality changes.

Quick Start

Install into AgentField (af install)

Already running an AgentField control plane? Install SWE-AF straight from GitHub — no clone, no local Python setup:

af install https://github.com/Agent-Field/SWE-AF
af run swe-planner

af install clones the repo, provisions an isolated Python environment, and registers the swe-planner node with your control plane. On first af run you're prompted for the one required secret — an LLM provider key (ANTHROPIC_API_KEY or OPENROUTER_API_KEY) — which is stored encrypted and reused across every node, so you enter it only once. (Add GH_TOKEN when you want builds to clone private repos and open pull requests.) Then kick off a build:

af call swe-planner.build --in '{"goal": "Add JWT auth", "repo_url": "https://github.com/user/my-repo"}'

New to AgentField? Install the control plane first with curl -fsSL https://agentfield.ai/install.sh | bash, or use the Railway / local options below.

Deploy with Railway (fastest)

Deploy on Railway

One click deploys SWE-AF + AgentField control plane + PostgreSQL. Exactly one environment variable is required in Railway — an LLM provider key:

  • OPENROUTER_API_KEYrecommended, simplest. One key, 200+ open and proprietary models. With only this set (no ANTHROPIC_API_KEY, no SWE_DEFAULT_RUNTIME), SWE-AF auto-selects the open_code runtime and defaults every role to openrouter/deepseek/deepseek-v4-flash-0731 — no further configuration needed.
  • Alternative: ANTHROPIC_API_KEY, or CLAUDE_CODE_OAUTH_TOKEN from claude setup-token in Claude Code CLI (uses Pro/Max subscription credits), to run the claude_code runtime instead.

Optional:

  • GH_TOKEN — GitHub personal access token with repo scope. Needed only to clone private repos, push branches, and open pull requests; builds against public repos work without it.

Once deployed, trigger a build:

curl -X POST https://<control-plane>.up.railway.app/api/v1/execute/async/swe-planner.build \
  -H "Content-Type: application/json" \
  -H "X-API-Key: this-is-a-secret" \
  -d '{"input": {"goal": "Add JWT auth", "repo_url": "https://github.com/user/my-repo"}}'

1. Requirements (local)

  • Python 3.12+
  • AgentField control plane (af)
  • AI provider API key (Anthropic, OpenRouter, OpenAI, or Google)

2. Install

python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

3. Run

af                 # starts AgentField control plane on :8080
python -m swe_af   # registers node id "swe-planner"

4. Trigger a build

# Default (uses Claude)
curl -X POST http://localhost:8080/api/v1/execute/async/swe-planner.build \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "input": {
    "goal": "Add JWT auth to all API endpoints",
    "repo_url": "https://github.com/user/my-project"
  }
}
JSON

# With open-source runtime + flat role map
curl -X POST http://localhost:8080/api/v1/execute/async/swe-planner.build \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "input": {
    "goal": "Add JWT auth",
    "repo_url": "https://github.com/user/my-project",
    "config": {
      "runtime": "open_code",
      "models": {
        "default": "openrouter/minimax/minimax-m2.5"
      }
    }
  }
}
JSON

# With Codex CLI runtime
curl -X POST http://localhost:8080/api/v1/execute/async/swe-planner.build \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "input": {
    "goal": "Add JWT auth",
    "repo_url": "https://github.com/user/my-project",
    "config": {
      "runtime": "codex",
      "models": {
        "default": "gpt-5.3-codex"
      }
    }
  }
}
JSON

# Fast mode with Codex CLI runtime
curl -X POST http://localhost:8080/api/v1/execute/async/swe-fast.build \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "input": {
    "goal": "Add a focused bug fix",
    "repo_url": "https://github.com/user/my-project",
    "config": {
      "runtime": "codex",
      "models": {
        "default": "gpt-5.3-codex"
      }
    }
  }
}
JSON

# Local workspace mode (repo_path) + targeted role override
curl -X POST http://localhost:8080/api/v1/execute/async/swe-planner.build \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "input": {
    "goal": "Refactor and harden auth + billing flows",
    "repo_path": "/path/to/repo",
    "config": {
      "runtime": "claude_code",
      "models": {
        "default": "sonnet",
        "coder": "opus",
        "qa": "opus"
      },
      "enable_learning": true
    }
  }
}
JSON

For OpenRouter with open_code, use model IDs in openrouter/<provider>/<model> format (for example openrouter/minimax/minimax-m2.5).

For Infron with open_code, set INFRON_API_KEY and use infron/<provider>/<model> (for example infron/moonshotai/kimi-k2.6). Infron is an OpenAI-compatible gateway serving the standard <provider>/<model> ids, so moving a role across is a prefix swap and nothing else changes:

SWE_DEFAULT_MODEL=infron/moonshotai/kimi-k2.6

With only an INFRON_API_KEY set (no ANTHROPIC_API_KEY, no other gateway key, no SWE_DEFAULT_RUNTIME), SWE-AF auto-selects the open_code runtime and defaults to infron/deepseek/deepseek-v4-flash-0731 — the same rule the existing gateway path already follows. A gateway key already configured keeps precedence, so adding an Infron key never reroutes an existing deployment on its own.

Docker and Railway deployments using Infron must set HARNESS_MODEL=infron/deepseek/deepseek-v4-flash-0731 (or another infron/... id) in the environment. The image bakes an openrouter/... value that the open_code model cascade reads after the Infron auto default and would otherwise override it. SWE_DEFAULT_MODEL pins every role model but does not feed OpenCode's small_model; set HARNESS_MODEL for that path (setting both is fine).

MiniMax direct providers

The Docker images include direct MiniMax provider entries for both supported regions and API compatibility modes. MiniMax-M3 and MiniMax-M2.7 are available in every entry.

RegionOpenAI-compatible open_code model IDsAnthropic-compatible open_code model IDsAnthropic base URL
Globalminimax-global-openai/MiniMax-M3, minimax-global-openai/MiniMax-M2.7minimax-anthropic/MiniMax-M3, minimax-anthropic/MiniMax-M2.7https://api.minimax.io/anthropic
Chinaminimax-cn-openai/MiniMax-M3, minimax-cn-openai/MiniMax-M2.7minimax-anthropic/MiniMax-M3, minimax-anthropic/MiniMax-M2.7https://api.minimaxi.com/anthropic
ModelContext windowInput modalitiesThinkingInput / output / cache read / cache write per million tokens
MiniMax-M31,000,000text, image, videoadaptive or disabled$0.30 / $1.20 / $0.06 / not charged
MiniMax-M2.7204,800textalways on$0.30 / $1.20 / $0.06 / $0.375

MiniMax-M3 pricing is tiered by input length: requests over 512K input tokens are billed at $0.60 / $2.40 / $0.12 instead. The baked provider metadata uses the standard ≤512K tier, which is what normal coding requests hit.

For the direct OpenAI-compatible path, set MINIMAX_API_KEY, use runtime: "open_code", and select one of the minimax-global-openai/* or minimax-cn-openai/* model IDs above. The configured OpenAI-compatible base URLs are https://api.minimax.io/v1 and https://api.minimaxi.com/v1.

For the Anthropic-compatible OpenCode path, set MINIMAX_API_KEY, set ANTHROPIC_BASE_URL to either regional /anthropic URL shown above, use runtime: "open_code", and select minimax-anthropic/MiniMax-M3 or minimax-anthropic/MiniMax-M2.7. The provider configuration appends /v1; keep ANTHROPIC_BASE_URL at the regional /anthropic URL.

For the Anthropic-compatible Claude path, set ANTHROPIC_AUTH_TOKEN, set ANTHROPIC_BASE_URL to the regional /anthropic URL shown above, use runtime: "claude_code", and select MiniMax-M3 or MiniMax-M2.7. Do not append /v1; Claude Code adds /v1/messages to the configured base URL. Unset ANTHROPIC_API_KEY (and CLAUDE_CODE_OAUTH_TOKEN) in that deployment — an Anthropic credential left in the environment can be sent to the non-Anthropic endpoint.

ANTHROPIC_BASE_URL is process-wide, so one deployment cannot route Claude and MiniMax Anthropic-compatible traffic to different endpoints.

For Codex with ChatGPT subscription auth, install the Codex CLI on the host, run codex login, leave OPENAI_API_KEY unset for this process, and set SWE_CODEX_AUTH_MODE=chatgpt or auto. For OpenAI API-platform billing, set SWE_CODEX_AUTH_MODE=api_key and OPENAI_API_KEY.

The Docker image bakes HARNESS_MODEL=openrouter/deepseek/deepseek-v4-flash-0731 so OpenCode's small_model config interpolation always has a value. HARNESS_MODEL only affects the open_code runtime — claude_code and codex deployments resolve their own runtime defaults (codex picks its model by auth mode) and can override per role via SWE_DEFAULT_MODEL / models as usual.

Codex CLI's workspace-write sandbox uses bubblewrap (bwrap) and needs Linux user namespaces enabled on the host. Most production Linux hosts and managed container runtimes (Railway, etc.) allow this by default, but local Docker on WSL2 or hardened environments may refuse with bwrap: No permissions to create a new namespace. If the verifier reports that error, the coder ran but couldn't write files — enable user namespaces on the host before relying on the codex runtime there.

Optional: web search

Coding and review agents can look up external documentation, library APIs, error messages, and version/deprecation status during a build. This is opt-in via two env vars on the deployment:

OPENCODE_ENABLE_EXA=1
EXA_API_KEY=...

When set, opencode's built-in websearch and webfetch tools become available to every reasoner running through the open runtime — the model decides when to use them based on the task. Get a key at exa.ai.

The coder reasoner additionally gets a brief restraint guideline appended to its system prompt, so a long coding loop doesn't rabbit-hole on searches it could answer by reading the codebase. No setup required beyond the env vars; the wiring inherits parent env naturally through agentfield's CLI harness.

This works on the open runtime (opencode). The Claude runtime uses Anthropic's first-party WebSearch/WebFetch and is currently not wired here — file an issue if you want it.

What Happens In One Build

  • Architecture is generated and reviewed before coding starts
  • Issues are dependency-sorted and run in parallel across isolated worktrees
  • Each issue gets dedicated coder, tester, and reviewer passes
  • Failed issues trigger advisor-driven adaptation (split, re-scope, or escalate)
  • Escalations trigger replanning of the remaining DAG
  • End result is merged, integration-tested, and verified against acceptance criteria

SWE-AF architecture

Typical runs spin up 400-500+ agent instances across planning, execution, QA, and verification. For larger DAGs and repeated adaptation/replanning cycles, SWE-AF can scale into the high hundreds to thousands of agent invocations in a single build.

Benchmark

95/100 with haiku and MiniMax: SWE-AF scored 95/100 with both Claude haiku-class routing ($20) and MiniMax M2.5 via open runtime ($6), outperforming Claude Code sonnet (73), Codex o3 (62), and Claude Code haiku (59) on the same prompt.

DimensionSWE-AF (haiku)SWE-AF (MiniMax)CC SonnetCodex (o3)CC Haiku
Functional (30)3030303030
Structure (20)2020101010
Hygiene (20)202016107
Git (15)1515222
Quality (15)1010151010
Total9595736259
Cost~$20~$6???
Time~30-40 min43 min???
Full benchmark details and reproduction

Same prompt tested across multiple agents. SWE-AF with Claude runtime (haiku-class model mapping) used 400+ agent instances; SWE-AF with MiniMax M2.5 via open runtime achieved identical quality at 70% cost savings.

Prompt used for all agents:

Build a Node.js CLI todo app with add, list, complete, and delete commands. Data should persist to a JSON file. Initialize git, write tests, and commit your work.

Scoring framework

DimensionPointsWhat it measures
Functional30CLI b

Files in the repo

Repository payload28 top-level entries
  • .claude
  • .github
  • assets
  • docs
  • examples
  • go
  • swe_af
  • tests
  • .dockerignore
  • .env.example
  • .gitignore
  • agentfield-package.yaml
  • CHANGELOG.md
  • CODE_OF_CONDUCT.md
  • CODEOWNERS
  • docker-compose.go.yml
  • docker-compose.local.yml
  • docker-compose.yml
  • Dockerfile
  • LICENSE
  • Makefile
  • opencode.json
  • pyproject.toml
  • railway.toml
  • README.md
  • requirements-docker.txt
  • requirements.txt
  • SECURITY.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More agents

Hmbown/
Codewhale

Open-source coding agent for your terminal, built in Rust and on a journey of continuous community improvement. Issues and PRs welcome.

41k

A lightweight alternative to OpenClaw that runs in containers for security. Connects to WhatsApp, Telegram, Slack, Discord, Gmail and other messaging apps,, has memory, scheduled jobs, and runs directly on Anthropic's Agents SDK

31k
TokenRhythm/
opensquilla

OpenSquilla — Token-Efficient AI Agent with same budget, higher intelligence density

7k

An open-source AI coding agent that lives in your terminal.

28k
Untrivial-ai/
agent-orchestrator

Run and supervise teams of coding agents from planning to merge. Any harness (Claude code, codex, +25 more). Desktop, web, mobile, and cloud agents.

11k