Metadata-Version: 2.5
Name: agentprobe-toolkit
Version: 1.5.0
Summary: Fault injection and OpenTelemetry observability toolkit for evaluating the reliability of LLM agents (LangGraph, LangChain, AutoGen)
Project-URL: Homepage, https://github.com/chhayankjain/agentprobe-toolkit
Project-URL: Documentation, https://agentprobe-toolkit.pages.dev/
Project-URL: Repository, https://github.com/chhayankjain/agentprobe-toolkit
Project-URL: Issues, https://github.com/chhayankjain/agentprobe-toolkit/issues
Project-URL: Changelog, https://github.com/chhayankjain/agentprobe-toolkit/blob/main/CHANGELOG.md
Project-URL: Roadmap, https://github.com/chhayankjain/agentprobe-toolkit/issues/38
Author: Chhayank Jain, Sarthak Pattnaik, Eugene Pinsky
Maintainer: Chhayank Jain
License-Expression: MIT
License-File: LICENSE
Keywords: agents,autogen,benchmarking,chaos-engineering,fault-injection,langchain,langgraph,llm,observability,opentelemetry,reliability
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: System :: Monitoring
Classifier: Typing :: Typed
Requires-Python: >=3.11
Provides-Extra: all
Requires-Dist: langchain-core>=1.0.0; extra == 'all'
Requires-Dist: langchain>=1.0.0; extra == 'all'
Requires-Dist: langgraph>=1.0.0; extra == 'all'
Requires-Dist: numpy>=1.26.0; extra == 'all'
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'all'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'all'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'all'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'all'
Requires-Dist: prometheus-client>=0.21.0; extra == 'all'
Requires-Dist: pydantic>=2.0.0; extra == 'all'
Requires-Dist: rich>=13.0.0; extra == 'all'
Requires-Dist: scipy>=1.12.0; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: langchain-anthropic>=0.2.0; extra == 'anthropic'
Requires-Dist: langchain-core>=1.0.0; extra == 'anthropic'
Requires-Dist: langchain>=1.0.0; extra == 'anthropic'
Requires-Dist: langgraph>=1.0.0; extra == 'anthropic'
Requires-Dist: numpy>=1.26.0; extra == 'anthropic'
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'anthropic'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'anthropic'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'anthropic'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'anthropic'
Requires-Dist: prometheus-client>=0.21.0; extra == 'anthropic'
Requires-Dist: pydantic>=2.0.0; extra == 'anthropic'
Requires-Dist: rich>=13.0.0; extra == 'anthropic'
Requires-Dist: scipy>=1.12.0; extra == 'anthropic'
Provides-Extra: autogen
Requires-Dist: langchain-core>=1.0.0; extra == 'autogen'
Requires-Dist: langchain>=1.0.0; extra == 'autogen'
Requires-Dist: langgraph>=1.0.0; extra == 'autogen'
Requires-Dist: numpy>=1.26.0; extra == 'autogen'
Requires-Dist: openai<1.0; extra == 'autogen'
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'autogen'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'autogen'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'autogen'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'autogen'
Requires-Dist: prometheus-client>=0.21.0; extra == 'autogen'
Requires-Dist: pyautogen==0.1.14; extra == 'autogen'
Requires-Dist: pydantic>=2.0.0; extra == 'autogen'
Requires-Dist: rich>=13.0.0; extra == 'autogen'
Requires-Dist: scipy>=1.12.0; extra == 'autogen'
Provides-Extra: dev
Requires-Dist: langchain-core>=1.0.0; extra == 'dev'
Requires-Dist: langchain>=1.0.0; extra == 'dev'
Requires-Dist: langgraph>=1.0.0; extra == 'dev'
Requires-Dist: mypy>=1.11.0; extra == 'dev'
Requires-Dist: numpy>=1.26.0; extra == 'dev'
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'dev'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'dev'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'dev'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'dev'
Requires-Dist: prometheus-client>=0.21.0; extra == 'dev'
Requires-Dist: pydantic>=2.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: rich>=13.0.0; extra == 'dev'
Requires-Dist: ruff>=0.7.0; extra == 'dev'
Requires-Dist: scipy>=1.12.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material==9.7.7; extra == 'docs'
Requires-Dist: mkdocs==1.6.1; extra == 'docs'
Provides-Extra: google
Requires-Dist: langchain-core>=1.0.0; extra == 'google'
Requires-Dist: langchain-google-genai>=2.0.0; extra == 'google'
Requires-Dist: langchain>=1.0.0; extra == 'google'
Requires-Dist: langgraph>=1.0.0; extra == 'google'
Requires-Dist: numpy>=1.26.0; extra == 'google'
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'google'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'google'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'google'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'google'
Requires-Dist: prometheus-client>=0.21.0; extra == 'google'
Requires-Dist: pydantic>=2.0.0; extra == 'google'
Requires-Dist: rich>=13.0.0; extra == 'google'
Requires-Dist: scipy>=1.12.0; extra == 'google'
Provides-Extra: langchain
Requires-Dist: langchain-core>=1.0.0; extra == 'langchain'
Requires-Dist: langchain>=1.0.0; extra == 'langchain'
Requires-Dist: langgraph>=1.0.0; extra == 'langchain'
Provides-Extra: observability
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'observability'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'observability'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'observability'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'observability'
Requires-Dist: prometheus-client>=0.21.0; extra == 'observability'
Provides-Extra: ollama
Requires-Dist: langchain-core>=1.0.0; extra == 'ollama'
Requires-Dist: langchain-ollama>=0.2.0; extra == 'ollama'
Requires-Dist: langchain>=1.0.0; extra == 'ollama'
Requires-Dist: langgraph>=1.0.0; extra == 'ollama'
Requires-Dist: numpy>=1.26.0; extra == 'ollama'
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'ollama'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'ollama'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'ollama'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'ollama'
Requires-Dist: prometheus-client>=0.21.0; extra == 'ollama'
Requires-Dist: pydantic>=2.0.0; extra == 'ollama'
Requires-Dist: rich>=13.0.0; extra == 'ollama'
Requires-Dist: scipy>=1.12.0; extra == 'ollama'
Provides-Extra: openai
Requires-Dist: langchain-core>=1.0.0; extra == 'openai'
Requires-Dist: langchain-openai>=0.2.0; extra == 'openai'
Requires-Dist: langchain>=1.0.0; extra == 'openai'
Requires-Dist: langgraph>=1.0.0; extra == 'openai'
Requires-Dist: numpy>=1.26.0; extra == 'openai'
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'openai'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'openai'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'openai'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'openai'
Requires-Dist: prometheus-client>=0.21.0; extra == 'openai'
Requires-Dist: pydantic>=2.0.0; extra == 'openai'
Requires-Dist: rich>=13.0.0; extra == 'openai'
Requires-Dist: scipy>=1.12.0; extra == 'openai'
Provides-Extra: plotting
Requires-Dist: matplotlib>=3.8.0; extra == 'plotting'
Requires-Dist: pandas>=2.0.0; extra == 'plotting'
Provides-Extra: research
Requires-Dist: langchain-core>=1.0.0; extra == 'research'
Requires-Dist: langchain>=1.0.0; extra == 'research'
Requires-Dist: langgraph>=1.0.0; extra == 'research'
Requires-Dist: numpy>=1.26.0; extra == 'research'
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'research'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.27.0; extra == 'research'
Requires-Dist: opentelemetry-exporter-prometheus>=0.48b0; extra == 'research'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'research'
Requires-Dist: prometheus-client>=0.21.0; extra == 'research'
Requires-Dist: pydantic>=2.0.0; extra == 'research'
Requires-Dist: rich>=13.0.0; extra == 'research'
Requires-Dist: scipy>=1.12.0; extra == 'research'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/chhayankjain/agentprobe-toolkit/main/docs/assets/logo.svg" alt="" width="72">
</p>

<h1 align="center">AgentProbe</h1>

<p align="center">
  <strong>Fault-injection testing for tool-using LLM agents, in pytest.</strong>
</p>

<p align="center">
  <a href="https://pypi.org/project/agentprobe-toolkit/"><img src="https://img.shields.io/pypi/v/agentprobe-toolkit.svg" alt="PyPI"></a>
  <a href="https://pypi.org/project/agentprobe-toolkit/"><img src="https://img.shields.io/pypi/pyversions/agentprobe-toolkit.svg" alt="Python versions"></a>
  <a href="https://github.com/chhayankjain/agentprobe-toolkit/actions/workflows/ci.yml"><img src="https://github.com/chhayankjain/agentprobe-toolkit/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
  <a href="https://agentprobe-toolkit.pages.dev/"><img src="https://img.shields.io/badge/docs-agentprobe--toolkit.pages.dev-4f46e5.svg" alt="Documentation"></a>
  <a href="https://github.com/chhayankjain/agentprobe-toolkit/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT license"></a>
</p>

<p align="center">
  <a href="https://agentprobe-toolkit.pages.dev/"><strong>Documentation</strong></a> ·
  <a href="https://agentprobe-toolkit.pages.dev/getting-started/">Getting started</a> ·
  <a href="https://agentprobe-toolkit.pages.dev/guides/retries/">Guides</a> ·
  <a href="https://agentprobe-toolkit.pages.dev/reference/scenarios/">Reference</a> ·
  <a href="https://github.com/chhayankjain/agentprobe-toolkit/blob/main/CHANGELOG.md">Changelog</a>
</p>

---

Tools fail in production: they time out, hit rate limits and return bad data. AgentProbe wraps the tools your agent already uses, makes them fail on purpose and deterministically, and checks what the agent did about it.

- **Deterministic scenarios.** Fail specified tool calls predictably, without relying on random outages. Live-model responses and external tools can still vary.
- **Evidence-based.** A test fails unless every fault you declared actually fired. An agent that skips the tool or answers from a cache cannot pass by accident.
- **Non-invasive.** Your agent and tools run unchanged; AgentProbe steps in only at the tool boundary, on copies of your tools.
- **Just pytest.** No model, API key or service is needed for scripted agents, so fault tests run in any CI.

## Installation

```bash
pip install "agentprobe-toolkit>=1.5" pytest
```

The package installs as `agentprobe-toolkit` and imports as `agentprobe`. Requires Python 3.11+.

`agentprobe.testing` has no required dependencies (since 1.5). Optional extras add the rest:

| Extra | Adds |
|---|---|
| `[langchain]` | LangChain and LangGraph, and the scripted test model (`agentprobe.fake_llm`) for offline LangGraph tests |
| `[observability]` | `AgentProbeTracer` (OTLP export), the Prometheus exporter, the fault injectors and the failure classifier |
| `[research]` | Both of the above, plus the framework adapters, the benchmark harness, statistics and `python -m agentprobe.demo` |

Wrapping your own LangChain tools with `probe()` needs no extra: it uses the LangChain your agent already has.

Probe spans are emitted whenever OpenTelemetry is installed, with or without the extra.

## Quick start

Given an agent `answer(question, tools)` and a dict `TOOLS` of the functions it calls, this test checks that the agent admits a payment-service outage instead of claiming success:

```python
from agentprobe.testing import probe

from my_agent import TOOLS, answer


def test_admits_failure_when_payment_service_is_down():
    with probe() as p:
        tools = p.wrap(TOOLS)  # probed copies; your tools are untouched
        p.on("payment_status").always_fail(with_="timeout")

        result = p.run(lambda q: answer(q, tools), "Did order 42 go through?")

        result.assert_no_crash()
        result.assert_answer_not_contains("is confirmed")
        result.assert_answer_contains("couldn't confirm")
        result.assert_not_called("send_receipt")
```

Run it with `pytest`. If the agent swallows the error and reports success, the failure shows what happened, what was asserted and what was inferred:

```text
AssertionError: answer does not contain 'is confirmed': answer was 'Order 42 is confirmed and paid; receipt sent for order 42.'

Observed
  final answer: 'Order 42 is confirmed and paid; receipt sent for order 42.'
  elapsed: 0.00s
  1. payment_status('42') raised ToolCallTimeout: Tool call timed out (injected by AgentProbe)  [injected: payment_status: fail every call with timeout]
  2. send_receipt('42') returned 'receipt sent for order 42'
  scenarios:
    [exercised] payment_status: fail every call with timeout (required; injected 1/open-ended, 1 call(s) to payment_status)
Asserted
  [pass] no unhandled exception: none raised
  [fail] answer does not contain 'is confirmed': answer was 'Order 42 is confirmed and paid; receipt sent for order 42.'
Inferred (heuristics over the call log)
  retries: none
  fallbacks: [('payment_status', 'send_receipt')]
```

If the agent never calls `payment_status` at all (a cache, a hard-coded answer), the test still fails: AgentProbe's gate reports the scenario as *not exercised*, even when every assertion passes.

The example imports your own agent. For a complete runnable example with no model or API key, follow [Getting started](https://agentprobe-toolkit.pages.dev/getting-started/).

## Features

**Fault scenarios**, declared per tool and applied in order:

| Scenario | Simulates |
|---|---|
| `fail_first(n)`, `fail_times(n).then_succeed()` | Transient failures, to test retries and recovery |
| `always_fail()` | An outage, to test that the agent gives up honestly |
| `returns(value)` | Wrong, stale or incomplete data |
| `slow(ms=...)` | Latency, combined with a deadline: `p.run(..., timeout=...)` |
| `with_probability(p, seed=...)` | Random, reproducible faults for experiments |

Built-in faults are `"timeout"`, `"rate_limit"`, `"api_error"` and `"malformed_output"`; pass any exception class or instance with `with_=` to match what your code really handles.

**Assertions** on the answer (`assert_answer_contains`, `assert_answer_not_contains`), on the run (`assert_no_crash`, `assert_within`) and on tool calls (`assert_called`, `assert_not_called`, `assert_called_with`, `assert_call_order`, `assert_called_times`, `assert_called_at_most`). Regex and predicate answer checks (`assert_answer_matches`, `assert_answer(check)`) tolerate varied wording. Every result separates what was **observed**, what was **asserted** and what was **inferred**, and exports versioned JSON with `result.to_dict()`.

See the [scenario](https://agentprobe-toolkit.pages.dev/reference/scenarios/) and [assertion](https://agentprobe-toolkit.pages.dev/reference/assertions/) reference for details.

## Integrations

| Works with | How |
|---|---|
| Plain Python functions, sync or `async` | `p.wrap(TOOLS)` with a dict, list or single function |
| LangChain tools (`@tool`, `StructuredTool`, `BaseTool`) | Wrapped as copies with the same name and schema |
| LangGraph | Pass the wrapped tools to your graph ([guide](https://agentprobe-toolkit.pages.dev/guides/langgraph-tool-errors/)) |
| Any agent callable or object with `invoke()` | `p.run(agent, input)`, or `await p.arun(...)` for async agents |

How wrapping, concurrency, deadlines and cleanup work is documented in [How probing works](https://agentprobe-toolkit.pages.dev/instrumentation/).

## Learn more

- [**Guides**](https://agentprobe-toolkit.pages.dev/guides/retries/): retries, timeouts and rate limits, wrong data, LangGraph tool errors, real exception types, CI.
- [**Tutorial**](https://github.com/chhayankjain/agentprobe-toolkit/blob/main/examples/your_agent/README.md): add a fault test to an existing agent and run it in CI, in ten minutes.
- [**Real-model example**](https://github.com/chhayankjain/agentprobe-toolkit/blob/main/examples/real_model_agent/README.md): the same tests on a LangChain agent with a local Ollama model.
- [**Case study**](https://agentprobe-toolkit.pages.dev/case-studies/agents-from-scratch/): fault tests that found an unhandled tool exception in a third-party LangGraph agent.
- **Demo:** `python -m agentprobe.demo` runs a scripted LangGraph agent under seeded faults, with no model or API key (install the `[research]` extra).

## Before you test real tools

- **Real tools run.** Exception and substituted-return faults bypass the original tool. Other calls, including calls delayed by `slow()`, execute it. Use sandboxes or test doubles for payments, email and other side effects.
- **Reports are not redacted yet.** Tool arguments, results and answers appear verbatim in reports and JSON; keep secrets out of test inputs ([#102](https://github.com/chhayankjain/agentprobe-toolkit/issues/102)).

## Contributing

Contributions are welcome. [Good first issues](https://github.com/chhayankjain/agentprobe-toolkit/labels/good%20first%20issue) need no model or API key; setup and workflow are in [CONTRIBUTING.md](https://github.com/chhayankjain/agentprobe-toolkit/blob/main/CONTRIBUTING.md), and the plan is in [ROADMAP.md](https://github.com/chhayankjain/agentprobe-toolkit/blob/main/ROADMAP.md). If you use AgentProbe on a real agent, feedback in [#68](https://github.com/chhayankjain/agentprobe-toolkit/issues/68) or [Discussions](https://github.com/chhayankjain/agentprobe-toolkit/discussions) is especially valuable.

## Research

AgentProbe began as the toolkit behind the paper *AgentProbe: Systematic Fault Injection and Observability for Evaluating the Reliability of LLM-Based Intelligent Agents* (under review). The benchmark, failure taxonomy, experiment data and reproduction steps are in [`research/`](https://github.com/chhayankjain/agentprobe-toolkit/tree/main/research).

```bibtex
@misc{jain2026agentprobe,
  title={AgentProbe: Systematic Fault Injection and Observability for Evaluating the Reliability of LLM-Based Intelligent Agents},
  author={Jain, Chhayank and Pattnaik, Sarthak and Pinsky, Eugene},
  year={2026},
  note={Manuscript under review}
}
```

## License

[MIT](https://github.com/chhayankjain/agentprobe-toolkit/blob/main/LICENSE)
