Chaos Engineering
ChaosRunner runs your agent under a clean baseline and then
under each requested fault, so you can measure how behavior drifts
when things go wrong.
Faults
Eight fault types are available (all wrapped as agent decorators):
| Fault | Effect |
|---|---|
api_fail | Raises a simulated API failure. |
timeout | Raises a timeout error. |
rate_limit | Raises a 429 rate-limit error. |
network_delay | Raises a connection-reset error. |
tool_crash | Marks tool calls as crashed. |
memory_corrupt | Pollutes memory writes. |
token_limit | Truncates the output. |
malformed_output | Returns [[MALFORMED]]. |
Running chaos
from entropy import ChaosRunner
cr = ChaosRunner(seed=0)
result = cr.run(agent, dataset, ["api_fail", "timeout"], trials=50)
print(cr.summary(result))
result contains "baseline" and a
"faults" dict keyed by fault name. Each entry is a full
results dictionary, so you can diff success_rate,
drift_score, recovery_score, etc.
Fine-grained injection
Inject a single fault manually with a probability and seed:
from entropy import chaos_inject, chaos_available
print(chaos_available()) # list of fault names
faulty = chaos_inject(agent, "tool_crash", p=0.3, seed=1)
Interpretation
A large jump in drift_score or failure_rate
under a fault signals brittle behavior. Pair chaos with
assert_stable thresholds for a resilience gate in CI.