SWE Pipeline
A structured 5-phase bug-fixing pipeline that automatically localizes faults, designs a fix, implements it, and verifies correctness with tests.
Overview
The SWE (Software Engineering) Pipeline is a specialized mode for resolving bugs and regressions. Instead of a free-form agent loop, it runs a structured 5-phase process — understand, locate, plan, implement, verify — with real-time phase indicators in the UI and automatic retry on test failure.
Activating the Pipeline
Type /swe in the chat input followed by a description of the bug:
/swe TypeError: Cannot read properties of undefined (reading 'map') in Dashboard.tsx line 42
You can also paste a full stack trace or error log. The pipeline will extract signals from it automatically.
The SWE pipeline works best when you include the full error message and, if available, the failing test output. The more signal you provide, the more accurate the fault localization step.
The 5 Phases
Understand — The agent reads the error context you provided, identifies the error class, message, and any stack frames. It builds a mental model of the problem domain before touching any files.
Locate — Fault localization runs automatically. The agent extracts signals (stack frames, error classes, file references, variable names) from the error message and searches the codebase for relevant candidates. Results are ranked by relevance — the most likely fault location is investigated first.
Plan — The agent proposes a numbered fix plan and enters plan mode. The plan is shown in the chat for your review. You can approve it or ask for adjustments before any code is changed.
Implement — The agent executes the approved plan: edits files, applies patches, and updates any related code (imports, types, callers) that the fix requires. Each file change goes through the standard diff review workflow.
Verify — The agent runs the test suite. If tests fail, it analyzes the failure, adjusts the fix, and retries — up to 3 times. The full conversation context is preserved across retries so the agent learns from each attempt.
Fault Localization
The localization step works without any configuration:
Stack Frame Extraction
Parses file paths, line numbers, and function names from stack traces in the error message.
Error Class Matching
Maps error classes (TypeError, AttributeError, NullPointerException, etc.) to likely root-cause patterns.
Symbol Search
Searches the workspace for the variable names, function names, and class names mentioned in the error.
Candidate Ranking
Ranks fault candidates by signal density — files and symbols that appear most often in the extracted signals are investigated first.
Multi-Attempt Mode
For complex bugs where the first approach may not succeed, the pipeline uses git worktrees to try multiple independent fix strategies:
- Current changes are stashed with
git stash - Each attempt runs on a separate worktree / branch
- After all attempts complete, the results are evaluated and the best fix (highest test pass rate) is selected
- The winning fix is applied to the working tree
- The stash is popped and the other attempts are cleaned up
Multi-attempt mode is triggered automatically for bugs that score high on complexity. You can also request it explicitly: /swe --multi use multiple approaches for this one.
Phase Indicators
The chat UI shows a progress card for each phase:
| Indicator | Meaning | |-----------|---------| | Spinning circle | Phase is currently running | | Green checkmark | Phase completed successfully | | Yellow warning | Phase completed with caveats (e.g., tests partially passing) | | Red X | Phase failed — pipeline stops and reports the error |
Timeout
The full pipeline has a 30-minute timeout. If any phase exceeds this limit, the pipeline stops gracefully and reports what was completed so far. Partial fixes (already-implemented phases) are preserved in the working tree.
Configuration Reference
| Setting | Type | Default | Description |
|---------|------|---------|-------------|
| misar.swePipelineTimeout | number | 1800 | Timeout in seconds for the full SWE pipeline run |
| misar.sweMaxVerifyRetries | number | 3 | Maximum test-failure retry attempts in the Verify phase |
| misar.sweMultiAttempt | boolean | false | Always use multi-attempt mode (default: automatic based on complexity) |