Two AIs fight over your agent.
One attacks it. One heals it.

AI agents break in production: models time out, providers rate-limit, tools crash, replies come back garbled, and hidden text hijacks them. Chaos Doctor breaks your agent on purpose, finds why with a local open-weight model, patches the code, and proves the fix with a 0-100 resilience score.

▶ Watch a real battle How it works
0 → 100demo agent's score
18/20bugs fixed by a 4B model
6/6diagnoses made by the AI
100% localQwen3 via Ollama, no API keys
⏱

The model stalls

Timeouts and 429 rate-limit storms crash an agent that never retries.

🔧

A tool breaks

One failing API call and the whole answer is gone.

🎭

The data lies

Garbled replies and hidden prompt injections slip straight through to users.

The battle

A real battle recorded on an 8 GB laptop with qwen3:4b. Step through it with ← →, press Space to play, or click the timeline.

  1. Attack
  2. Score
  3. Diagnose
  4. Patch
  5. Verify
0/0

Loading the battle...

--/100
Resilience under each attack
examples/shop_agent/agent.py

          

The Doctor and Attacker cards show what the model actually returned. "Placement corrected" means our call-site check moved a fix to the function that makes the failing call.

How it works

Two open-weight models take turns. agentic-chaos does the breaking and the judging. Everything else is plain, testable code.

your agent open-weight model · Doctor open-weight model · Attacker deterministic code
1-2

Break and score

Faults from agentic-chaos hit the model client and tools. Its contracts plus the agent's own check give a pass rate per attack.

3

Diagnose

The Doctor (Qwen3) reads the failure and the code and answers in strict JSON: root cause, function, one recipe from a fixed menu, parameters.

4-5

Patch and verify

An ast patcher adds one guard decorator, so the code always parses. Re-scan: keep the patch if the score rises, roll back if not.

6

Attack again

The Attacker (Qwen3) reads the patched code and picks the next attack, writing its own prompt-injection payloads.

✓

Why a small model works

Both AIs choose from fixed, executable menus. They never write free-form code, and every change is a reviewable diff.

↗

Fits the ecosystem

Ships as an Agent Skill, a CLI, a CI gate (--min-score) and AIOS v0.4 Run export for the DeepAgentLabs tools.

Results

Measured, not promised. All numbers come from files in the repo.

Doctor benchmark · 20 planted bugs

3 agents × 6 attacks + 2 "strengthen" cases. One diagnosis each, then re-attack.

Full results ↗

Agent pattern leaderboard

Common agent designs, before → after an offline battle.

What we learned ↗

Run it yourself

Python 3.10+. No model needed for --offline; add Ollama for the AI Doctor.

terminal
git clone https://github.com/Yashasm18/chaos-doctor.git
cd chaos-doctor
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
chaos-doctor battle examples/shop_agent/agent.py --offline
with the open-weight model
ollama pull qwen3:4b
export CHAOS_DOCTOR_MODEL=qwen3:4b
chaos-doctor battle examples/shop_agent/agent.py
chaos-doctor scan examples/shop_agent/agent.py --min-score 70