Skip to main content

AgentChaos

Evaluate agent system robustness through controlled, runtime, non-intrusive LLM API fault injection.

PyPI version Python License: MIT CI codecov Tests Docs


Overview

LLM-based agent systems issue multiple API calls per task, and each call can fail (HTTP 5xx, truncation, empty response, encoding corruption, schema violation). Once a faulty response occurs, it propagates through downstream agents and causes task failure. AgentChaos injects controlled faults at the HTTP transport layer — without modifying any agent source code — to evaluate robustness before these failures happen in production.


Quick Start

pip install agentchaos-sdk
import agentchaos

# Inject fault (your agent code needs ZERO changes)
agentchaos.inject("llm_error_single")
result = await my_agent(query)         # agent runs normally, unaware
agentchaos.disable()                   # stop
agentchaos.save_trace("trace.json")   # save full LLM call trace
# examples
git clone https://github.com/floritange/AgentChaos.git
cd AgentChaos
uv sync
uv run python examples/list_faults.py       # list all 65 faults
uv run python examples/agent_openai.py      # OpenAI agent: normal vs faulted
uv run python examples/agent_langchain.py   # LangChain agent
uv run python examples/agent_adk.py         # Google ADK agent
uv run python examples/eval_batch.py        # batch evaluation

How It Works

An HTTP-layer injection mechanism patches the HTTP client at runtime to intercept and modify LLM API responses according to the fault configuration, requiring no changes to any agent system.

Properties:

  • Works with any framework using OpenAI-compatible APIs (OpenAI, LangChain, ADK, AutoGen, CrewAI, LiteLLM)
  • Zero code changes — just inject() / disable() around your existing code
  • Records full execution trace (raw input/output, token usage, timing) for every LLM call
  • 65 pre-built fault configurations covering all real-world failure modes

API

Function Description
agentchaos.inject(fault) Start fault injection + trace (None = trace only)
agentchaos.disable() Stop injection and trace
agentchaos.save_trace(path) Save trace to JSON
agentchaos.eval(agent_fn, query, faults) Batch robustness evaluation
agentchaos.diagnose(text) Detect fault type from output
agentchaos.list_faults() List all 65 experiments
import agentchaos

# Trace only (no fault)
agentchaos.inject(None)
result = await my_agent(query)
agentchaos.disable()
agentchaos.save_trace("trace_normal.json")

# Inject fault + trace
agentchaos.inject("llm_error_single")
result = await my_agent(query)
agentchaos.disable()
agentchaos.save_trace("trace_faulted.json")

# Batch evaluation
report = await agentchaos.eval(my_agent, query, faults="all")
print(report.summary())

Trace Format

{
  "call_index": 0,
  "raw_input": {"model": "gpt-5.5", "messages": [...], "tools": [...]},
  "raw_output": {
    "content": "The answer is 42.",
    "tool_calls": [],
    "finish_reason": "stop",
    "usage": {"prompt_tokens": 306, "completion_tokens": 54, "total_tokens": 360},
    "http_status": 200
  },
  "injected_output": {
    "content": "[API ERROR] HTTP 500: Internal Server Error.",
    "tool_calls": []
  },
  "timing": {"llm_latency_ms": 1523.4, "total_ms": 1524.1},
  "fault_applied": true
}

raw_output = LLM original response. injected_output = what the agent actually receives (only present when fault_applied: true).


Fault Taxonomy

We define a fault taxonomy by adapting the classical fault classification from distributed systems (Avizienis et al., 2004) to LLM API responses. The taxonomy covers crash, omission, and value faults on both content and tool call fields.

Category Fault Type Content Tool Call Real-world Scenario
Crash Error yes yes Server overload, HTTP 5xx, rate limiting
Crash Timeout yes yes Network congestion, backend delay, API latency
Omission Empty yes yes Safety filter, content policy rejection
Omission Truncate yes yes Token limit, TCP interruption, incomplete completion
Value Corrupt yes yes Encoding error, garbled characters
Value Schema yes yes Parsing error, schema mismatch

From Crash to Value, faults become progressively harder to detect. Crash faults produce obvious error signals and are typically retried. Value faults look like valid output and propagate silently — making them the most dangerous in practice.

65 = (6 fault types x 2 targets x 4 strategies) + 8 compound + 9 positional

Detailed documentation: docs/faults.md


Evaluation Results

Experimental Setup

Agent SystemArchitectureBenchmarks
AutoGenIterative (coder + executor)HumanEval, HumanEval+, MBPP, MBPP+, MMLU-Pro, MATH-500
MADDebate (proposer + critic)
MapCoderPipeline (planner + coder + debugger)
EvoMACIterative (multi-agent collaboration)
Mini-SEIterative (SWE agent)SWE-bench Pro

Backbone LLMs: Claude-Sonnet-4.5, GPT-5.2, DeepSeek-V3.2, Seed-1.8

Metric: Δpass@1 = pass@1 (w/o fault) − pass@1 (w/ fault). Higher = more vulnerable.

RQ1: Overall Robustness Degradation (Claude-Sonnet-4.5)

System HumanEval HumanEval+ MBPP MBPP+ MMLU-Pro MATH-500
AutoGen 19.44 21.13 17.31 11.61 7.05 8.38
MAD 24.20 24.84 24.49 15.08 20.64 20.70
MapCoder 48.61 49.30 41.07 40.85 38.25 34.27
EvoMAC 18.48 18.18 16.67 14.73 13.63 15.85
Mini-SE — — — — — —

Mini-SE is evaluated only on SWE-bench Pro (Δpass@1 = 0.87%).

RQ2: Impact of Fault Configurations

  • Content faults cause higher Δpass@1 than tool call faults; only corrupt stays below 7%
  • Persistent injection causes the highest Δpass@1 — up to 62.39% (MapCoder)
  • Pipeline systems are most position-sensitive — single early fault drops pass@1 by up to 83.87%
  • Compound content faults amplify degradation — up to 86.36% (MapCoder)

RQ3: Fault Diagnosis

Existing methods achieve below 53% accuracy on fault type and below 56% on fault step. Truncation — the most harmful fault — is identified with only 4.3% accuracy.

Key Findings

# Finding
1 All systems degrade under fault injection (Δpass@1 up to 50 pp)
2 Most severe faults are NOT most harmful — truncation/empty propagate silently
3 Most harmful faults are hardest to diagnose (truncation: 4.3% accuracy)
4 Architecture determines robustness — ranking consistent across all LLMs
5 Persistent injection overrides architectural advantages (up to 62.39%)
6 Compound content faults amplify degradation (up to 86.36%)

Documentation

  • Fault Reference — Complete reference for all 65 fault configurations
  • Examples — Runnable demos for OpenAI, LangChain, ADK

Citation

If you use AgentChaos in your research, please cite:

@article{agentchaos2026,
  title={AgentChaos: Chaos Engineering for Robust Agent Evaluation via LLM API Fault Injection},
  year={2026}
}

License

MIT -- see LICENSE.

Metadata

Release files for agentchaos-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentchaos-sdk 0.1.0
File Size Uploaded Provenance
agentchaos_sdk-0.1.0.tar.gz 930.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agentchaos-sdk 0.1.0
File Interpreter ABI Platform
agentchaos_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 949.9 kB

Release files / agentchaos_sdk-0.1.0.tar.gz

Download URL agentchaos_sdk-0.1.0.tar.gz
Size 930.3 kB
Tags Source
SHA-256 checksum
How to use checksums
28c10f7380ba41d21ee47762eaee779718e6b19d308825dcf01157cee0f81e90
BLAKE2b-256 checksum
How to use checksums
725a733e2551b5d7b414697f1411b7f54152257f334965ac0aca785125f12c53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 7, 2026.

Transparency log

Release files / agentchaos_sdk-0.1.0-py3-none-any.whl

Download URL agentchaos_sdk-0.1.0-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6db7cb5b5bf93da8c8fdaef35b7db6477ad81a4f634de2f0c83847997d4a06c5
BLAKE2b-256 checksum
How to use checksums
b038100b09c405c425053691bd664d4a715d46fef6722ad0233393eed8a4fd35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 7, 2026.

Transparency log

Security for agentchaos-sdk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for agentchaos_sdk-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page