Architecture β’ Key Features β’ Quick Start β’ Agent Roster β’ Security Sandbox β’ License
AutoHeal Swarm is an autonomous software engineering system that turns natural language specifications into verified, production-grade Python projects.
Powered by high-throughput Groq LPUs, AutoHeal Swarm orchestrates a team of specialized AI agents working inside an AST-governed execution sandbox. The swarm decomposes requirements, generates modular code, synthesizes comprehensive unit tests, executes test suites in isolated subprocesses, and autonomously debugs and self-heals failing code in a real-time feedback loop.
flowchart TD
Start([User Specification / Prompt]) --> Arch[π§ Architect Agent\nDecompose requirements into modular project files]
Arch --> Code[π» Coder Agent\nRefine implementations, docstrings & type safety]
subgraph Sandbox [π Isolated AST & Execution Sandbox]
Code --> AST{π‘οΈ AST Static Security Lint}
AST -- Violations Found --> Blocked[β Block Execution & Abort]
AST -- Safe --> Write[π Mount Ephemeral Workspace]
Write --> Subproc[π§ͺ Execute Test Suite in Subprocess]
end
Subproc --> Result{Tests Passed?}
Result -- Yes --> Pass[π Verified Project Ready]
Pass --> Zip[π¦ Export In-Memory ZIP Archive]
Result -- No --> RetryCheck{Retries Remaining?}
RetryCheck -- Yes --> Debug[π Debugger Agent\nAnalyze tracebacks & generate patch]
Debug --> Patch[π©Ή Apply Patch to SwarmProject]
Patch --> AST
RetryCheck -- No --> Fail[π₯ Swarm Max Retries Exceeded]
style Start fill:#2b6cb0,stroke:#63b3ed,stroke-width:2px,color:#fff
style Arch fill:#1a365d,stroke:#63b3ed,stroke-width:2px,color:#fff
style Code fill:#1c4532,stroke:#9ae6b4,stroke-width:2px,color:#fff
style AST fill:#44337a,stroke:#d6bcfa,stroke-width:2px,color:#fff
style Debug fill:#7b341e,stroke:#fc814a,stroke-width:2px,color:#fff
style Pass fill:#22543d,stroke:#48bb78,stroke-width:2px,color:#fff
style Fail fill:#742a2a,stroke:#f56565,stroke-width:2px,color:#fff
- π§ Specialized Multi-Agent Pipeline:
- Architect Agent: Breaks down specifications into modular architecture files (
source,test,config). - Coder Agent: Adds defensive error handling, docstrings, type annotations, and edge-case guards.
- Debugger Agent: Ingests compiler tracebacks,
stdout, andstderrto perform root-cause analysis and generate atomic patches.
- Architect Agent: Breaks down specifications into modular architecture files (
- π‘οΈ AST Static Security Engine:
- Zero-trust static AST analysis (
ast.NodeVisitor) scanning generated code prior to disk writes. - Restricts dynamic evaluation (
eval,exec,__import__), OS manipulation (os.system,subprocess.*), network sockets (socket.*,http.server), and foreign function wrappers (ctypes,cffi).
- Zero-trust static AST analysis (
- β‘ Ephemeral Subprocess Sandbox:
- Executes unit tests in isolated, time-bounded subprocesses with dedicated
PYTHONPATHisolation. - Guarantees deterministic filesystem cleanup on test completion or timeout.
- Executes unit tests in isolated, time-bounded subprocesses with dedicated
- π Fault-Tolerant Model Fallback Cascading:
- Automatic model fallback across
openai/gpt-oss-120b,openai/gpt-oss-20b,qwen/qwen3.6-27b, andgroq/compound-mini. - Built-in JSON bracket-stack repair and
failed_generationrecovery for truncated LLM responses.
- Automatic model fallback across
- π₯οΈ Real-Time Streamlit Command Center:
- Dual-column telemetry dashboard with live agent status stream and tabbed source code viewer.
- Instant one-click project download as
.zip.
- π Strict Pydantic v2 Contracts:
- Strictly validated data models (
FileArtifact,DebuggingPatch,SwarmProject) with automated markdown code-fence sanitization.
- Strictly validated data models (
| Agent | Icon | Responsibilities | Default Model |
|---|---|---|---|
| Architect | π§ | System decomposition, modular file hierarchy, dependency planning | openai/gpt-oss-120b |
| Coder | π» | Production-grade code synthesis, type hinting, unit tests | openai/gpt-oss-120b |
| Sandbox | π | AST static policy linting, ephemeral workspace execution, timeout monitoring | Native Python AST Engine |
| Debugger | π | Traceback inspection, root-cause diagnosis, self-healing patch synthesis | openai/gpt-oss-120b |
βββ agents.py # Multi-agent orchestrators & LLM fallback cascade
βββ app.py # Streamlit command dashboard & live UI
βββ contracts.py # Pydantic v2 schemas & patch application logic
βββ sandbox.py # AST static security linter & isolated subprocess runner
βββ test_contracts.py # Unit test suite for validation schemas & data contracts
βββ requirements.txt # Application dependencies
βββ .env.example # Environment variable template
βββ LICENSE # MIT License
βββ README.md # Documentation
- Python 3.10+
- A Groq Cloud API Key
# Clone the repository
git clone https://github.com/binarylaiba/AI-Heal-Swarm.git
cd "AI-Heal-Swarm"
# Create a virtual environment
python -m venv .venv
# Activate the virtual environment
# On Windows (PowerShell):
.\.venv\Scripts\Activate.ps1
# On Linux/macOS:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txtCreate a .env file from .env.example:
cp .env.example .envSet your Groq API key inside .env:
GROQ_API_KEY=gsk_your_groq_api_key_herestreamlit run app.pyNavigate to http://localhost:8501 to access the interactive web interface.
Run the contract validation test suite with unittest:
python -m unittest test_contracts.py -vClick to expand AST security policy details
AutoHeal Swarm enforces strict AST inspection before any code is written or executed:
- Disallowed Built-in Functions:
eval(),exec(),compile(),__import__(),breakpoint(),memoryview(). - Disallowed Modules & Imports:
subprocess,socket,ctypes,pty,pexpect,paramiko,ftplib,telnetlib,http.server,xmlrpc,multiprocessing,cffi,winreg,msvcrt,posix. - Blocked Attributes: Destructive file helpers (
os.system,os.remove,os.unlink,shutil.rmtree,shutil.move). - Dynamic Bypass Detection: Flags
getattr(module, 'dangerous_func')patterns.
Distributed under the MIT License. See LICENSE for more information.