AgentProbe
Fault-injection testing for tool-using LLM agents, in pytest.
Documentation · Getting started · Guides · Reference · Changelog
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
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:
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:
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.
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 and assertion 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) |
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.
Learn more
- Guides: retries, timeouts and rate limits, wrong data, LangGraph tool errors, real exception types, CI.
- Tutorial: add a fault test to an existing agent and run it in CI, in ten minutes.
- Real-model example: the same tests on a LangChain agent with a local Ollama model.
- Case study: fault tests that found an unhandled tool exception in a third-party LangGraph agent.
- Demo:
python -m agentprobe.demoruns 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).
Contributing
Contributions are welcome. Good first issues need no model or API key; setup and workflow are in CONTRIBUTING.md, and the plan is in ROADMAP.md. If you use AgentProbe on a real agent, feedback in #68 or 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/.
@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
Metadata
Release files for agentprobe-toolkit 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentprobe_toolkit-1.5.0.tar.gz | 269.4 kB | With provenance | Details for agentprobe_toolkit-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentprobe_toolkit-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for agentprobe_toolkit-1.5.0-py3-none-any.whl |
Total release size: 385.3 kB
Release files / agentprobe_toolkit-1.5.0.tar.gz
| Download URL | agentprobe_toolkit-1.5.0.tar.gz |
|---|---|
| Size | 269.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18be302bc4c3d2bd052cc039b9adf376d0815b78df9600394ba270bd7709361d
|
|
BLAKE2b-256 checksum How to use checksums |
f6a63a27bb1bb83e545e4f13340dd6d2298058f8c0ce7f91cc9d3765328ae340
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 20, 2026.
Transparency logRelease files / agentprobe_toolkit-1.5.0-py3-none-any.whl
| Download URL | agentprobe_toolkit-1.5.0-py3-none-any.whl |
|---|---|
| Size | 115.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1df4eb175a6fccb095bd29847e738277ad91ea2801103d7b4db431830678b1c
|
|
BLAKE2b-256 checksum How to use checksums |
407df804ca91bb9bc221562bbef4b3b3e968142e5de5d9c50cfc24b826b1633d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 20, 2026.
Transparency logSecurity for agentprobe-toolkit 1.5.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
Both files in this release have been uploaded with provenance metadata.
Attestation for agentprobe_toolkit-1.5.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 Nov 20, 2026.
Transparency logA 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.