Skip to main content

Tests whether an AI agent or stateful system recovers or cascades after a perturbation, using twin-trajectory divergence analysis. Works with minimal historical data and no model of the system's internals.

Project description

Bendex Resilience

Tests whether an AI agent (or any stateful system) recovers or cascades after a perturbation — a corrupted memory entry, a failed tool call, a config change — using twin-trajectory divergence analysis.

What makes this different

Most AI agent testing tools inject a failure and check one thing: did the task still complete? That's a pass/fail light switch — it can't tell the difference between "acting weird but fine" and "acting weird and actually breaking."

This tool instead:

  1. Clones your system into two copies.
  2. Applies a small, controlled perturbation to one copy.
  3. Runs both copies through the same real workload.
  4. Watches whether their behavior stays in sync (recovers) or drifts apart (cascades).

No historical baseline required before you can test it. No model of your system's internals needed. It works by comparing the two live copies to each other, not by comparing to weeks of past data.

Validated results

Tested against a real language model (Qwen2.5-0.5B-Instruct), not just synthetic data — see colab_shareable_demo.py, runnable yourself in one click:

Metric Result
Accuracy (40 trials: 20 healthy, 20 real injected failures) 95.0% (38/40)
Healthy systems correctly left alone 18/20 (2/20 false alarms)
Real failures caught 20/20

Also validated on systems where classical stability-analysis methods don't apply at all — nonlinear systems (90% accuracy against an exact known answer) and systems with memory/delay (100% accuracy against an exact known answer). Also validated to work with far less historical data than standard covariance-based drift detection methods require.

Known limitations — stated plainly, not hidden

  • Detection quality depends on calibration data size. Measured: 62% accuracy at 7 calibration observations, 83% at 25, 95% at 40+. Use at least ~40 observations where possible.
  • Does not yet automatically find your system's worst-case vulnerability. You tell it what scenario to test; it doesn't discover unknown weaknesses on its own. This is open, unsolved work.
  • Does not localize which specific subsystem is failing — tells you that something broke, not which part of a multi-component system.

Quick start

from resilience_v2 import ResilienceDetector

detector = ResilienceDetector()
detector.calibrate(nominal_trajectory)   # your system's normal behavior
result = detector.check(test_trajectory) # behavior after a perturbation
print(result)  # {'verdict': 'RECOVERS' or 'CASCADES', 'flagged_at_step': ..., ...}

Or run it as an API — see api.py (FastAPI, single /analyze endpoint, stateless).

Files

  • resilience_v2.py — core detector
  • api.py — REST API wrapper
  • colab_shareable_demo.py — real-LLM validation demo, runnable in Colab
  • tests/ — stress tests (scale, edge cases, false-positive rate)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bendex_resilience-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bendex_resilience-0.1.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file bendex_resilience-0.1.1.tar.gz.

File metadata

  • Download URL: bendex_resilience-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for bendex_resilience-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a373a039228199eb7293ed7096b6c54fa68c724ede775b7d8248739ed22a818c
MD5 fa9b95e9e4edd928675cf09ed71cf7e7
BLAKE2b-256 4ece89db21d521ffa1910d8daa9bb35e301c31cce0909f217b075e70f1ec7330

See more details on using hashes here.

File details

Details for the file bendex_resilience-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bendex_resilience-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1b05821b52c6a526ed0b07dc87ff04119363cda48f786342071a0e20f8f3385
MD5 19d5571575fa94713fbfed6aa4c016a7
BLAKE2b-256 76bb2297e2d6a01429bc49ef2d15cf2135cee8998e20881d7d45672c33b79c8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page