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.
Timeouts and 429 rate-limit storms crash an agent that never retries.
One failing API call and the whole answer is gone.
Garbled replies and hidden prompt injections slip straight through to users.
A real battle recorded on an 8 GB laptop with qwen3:4b. Step through it with ← →, press Space to play, or click the timeline.
Loading the battle...
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.
Two open-weight models take turns. agentic-chaos does the breaking and the judging. Everything else is plain, testable code.
Faults from agentic-chaos hit the model client and tools. Its contracts plus the agent's own check give a pass rate per attack.
The Doctor (Qwen3) reads the failure and the code and answers in strict JSON: root cause, function, one recipe from a fixed menu, parameters.
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.
The Attacker (Qwen3) reads the patched code and picks the next attack, writing its own prompt-injection payloads.
Both AIs choose from fixed, executable menus. They never write free-form code, and every change is a reviewable diff.
Ships as an Agent Skill, a CLI, a CI gate (--min-score) and AIOS v0.4 Run export for the DeepAgentLabs tools.
Measured, not promised. All numbers come from files in the repo.
3 agents × 6 attacks + 2 "strengthen" cases. One diagnosis each, then re-attack.
Full results ↗Python 3.10+. No model needed for --offline; add Ollama for the AI Doctor.
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
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