Skip to main content

AgentProbe

Fault-injection testing for tool-using LLM agents, in pytest.

PyPI Python versions CI Documentation MIT license

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.
  • Model-side failures too. Script the model's responses (bad tool arguments, unknown tools, endless tool calls, empty replies) to test what your agent does with them, with a cap on model calls. Since 1.6.
  • 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.7" 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().

pytest plugin (since 1.7): a built-in probe fixture (def test_x(probe): ...) gives each test a fresh probe and runs the gate as part of the test; pytest --agentprobe-report=agentprobe.json writes every fault test's outcome and evidence to one file. See getting started.

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, scripting the model, 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.
  • API stability: what's covered by semantic versioning, and how deprecations work.
  • 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 redact recognized secrets and email addresses by default (since 1.7), with custom rules and a redact=False opt-out. Filtering is pattern-based and raw evidence isn't redacted, so review a report before sharing it; 1.6.x reports are not redacted at all. See Reports for what is covered.

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. Questions go to SUPPORT.md; how the project is run is in GOVERNANCE.md.

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

MIT

Metadata

Release files for agentprobe-toolkit 1.7.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 agentprobe-toolkit 1.7.0
File Size Uploaded Provenance Actions
agentprobe_toolkit-1.7.0.tar.gz 359.9 kB With provenance Details for agentprobe_toolkit-1.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agentprobe-toolkit 1.7.0
File Interpreter ABI Platform Actions
agentprobe_toolkit-1.7.0-py3-none-any.whl Python 3 none any Details for agentprobe_toolkit-1.7.0-py3-none-any.whl

Total release size: 511.4 kB

Release files / agentprobe_toolkit-1.7.0.tar.gz

Download URL agentprobe_toolkit-1.7.0.tar.gz
Size 359.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5136b0b00b2e5db9933fd81d35185300d528612246a55d77ad15b774b7b65102
BLAKE2b-256 checksum
How to use checksums
18b15c6b02ba777c2b3dad5e703381321091823d9da28fa091ac1602d1a5a288
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 30, 2026.

Transparency log

Release files / agentprobe_toolkit-1.7.0-py3-none-any.whl

Download URL agentprobe_toolkit-1.7.0-py3-none-any.whl
Size 151.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e842aeb60cc86b0e29e1b9720dc572860839ec23d36a01962dcb25ef087ba74b
BLAKE2b-256 checksum
How to use checksums
f52599b528c322c4dd0bca3ddba5cf4bac7dd6daa45afd525dffbd1243293dd7
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 30, 2026.

Transparency log

Security for agentprobe-toolkit 1.7.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.

Select from 2 files

Attestation for agentprobe_toolkit-1.7.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 30, 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.

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