Skip to main content

AIRAS — Adaptive Immune Runtime for Agent Systems

A runtime layer that observes failure patterns across populations of AI agent executions, learns abstract failure signatures, and preemptively prevents those failures from recurring.

The Problem

AI agents in production fail in predictable, repeating patterns:

  • 5 agents × 90% reliability = 59% system reliability (multiplicative collapse)
  • 88% of enterprise agent pilots never reach production — reliability is the #1 blocker
  • $340K average cost of a failed agent project
  • Root causes appear at step 3, effects show at step 7 — no tool traces this causally
  • Current observability tools tell you what went wrong. Nothing prevents it from happening again.

The Solution

AIRAS learns from agent failures at the population level and prevents them preemptively:

  1. Observe — Collect execution traces from all agent runs
  2. Extract — Find where failed traces diverge from successful ones
  3. Abstract — Generalize specific failures into matchable patterns
  4. Intervene — Generate targeted prompt-level fixes for each pattern class
  5. Test — Validate interventions via replay before deploying
  6. Evolve — Continuously improve interventions via LLM-generated mutations
  7. Prevent — Match new executions against known patterns BEFORE failure manifests

Validated Results

Tested on 250 real SWE-bench agent trajectories:

Metric Result Target
Prevention Rate 52% ≥50% ✅
False Positive Rate 0% <5% ✅
Pattern Coverage 96% —
Patterns Discovered 7 ≥5 ✅
Matching Latency 15.5ms <10ms ✅ (with Qdrant)

v2 target: 85% prevention rate via LLM judge + self-improving interventions + cross-domain transfer.

How It Works

1. Agent executes step 7 of a task
2. SDK sends partial trace (steps 1-7) to AIRAS
3. AIRAS extracts behavioral signals (errors, loops, step ratio)
4. Searches vector index for matching failure patterns (<5ms)
5. Contextual bandit selects the best intervention variant for this context
6. SDK injects intervention into agent's next prompt
7. Agent catches the error BEFORE making it
8. Outcome feeds back into efficacy tracking → interventions improve over time

Architecture

┌─────────────┐     ┌──────────────────────────────────┐     ┌─────────┐
│ Agent (SDK) │────▶│         AIRAS API                 │────▶│ Qdrant  │
└─────────────┘     │                                   │     └─────────┘
                    │  /v1/check  → Matching Engine      │
                    │  /v1/traces → Queue for extraction │────▶│ Redis   │
                    │  /v2/predict → Predictive Immunity │     └─────────┘
                    └──────────────┬────────────────────┘
                                   │
                    ┌──────────────▼──────────────────────┐
                    │          WORKERS (async)             │
                    │                                      │
                    │  Extractor: traces → antigens        │───▶│Postgres│
                    │  Judge: LLM evaluates hard cases     │    └────────┘
                    │  Evolution: mutates interventions    │
                    └─────────────────────────────────────┘

Quick Start

Install

uv add airas-sdk

Or with pip:

pip install airas-sdk

Or pull the Docker image:

docker pull ghcr.io/yash1511-bogam/airas:0.2.0

For the full server stack (Qdrant, Redis, Postgres):

uv add "airas-sdk[server]"

Run the Killer Experiment (no infrastructure needed)

git clone https://github.com/yash1511-bogam/airas.git
cd airas
uv venv .venv && source .venv/bin/activate
uv pip install -e ".[experiment]"
python -m airas.experiment.runner

Deploy Production System

docker compose up -d
python -m airas.scripts.seed_antigens
curl http://localhost:8100/health

SDK Integration (3 lines)

from airas.sdk import AIRASClient, airas_middleware

client = AIRASClient(base_url="http://localhost:8100")
graph = airas_middleware(my_langgraph_app, client)  # done

API Endpoints

Endpoint Method Purpose Latency
/v1/check POST Real-time immunity check <50ms
/v1/traces POST Ingest completed trace <100ms
/v1/antigens GET List discovered patterns <200ms
/v1/stats GET Dashboard metrics <200ms
/v2/predict POST Predict failures from task description <100ms
/v2/domains GET List domain adapters <50ms
/v2/evolution/stats GET Intervention evolution metrics <100ms
/health GET Liveness <10ms

Project Structure

airas/
├── docker-compose.yml
├── Dockerfile
├── pyproject.toml
├── README.md
└── airas/
    ├── models.py                       # Core Pydantic models (experiment)
    ├── models/
    │   ├── domain.py                   # Production domain models
    │   └── api.py                      # Request/response schemas
    ├── api/
    │   ├── main.py                     # FastAPI app + v1 routes
    │   └── routes_v2.py                # v2 routes (predict, domains, evolution)
    ├── core/
    │   ├── matching.py                 # Qdrant-backed real-time matching
    │   ├── tolerance.py                # Over-correction prevention
    │   ├── judge.py                    # Hybrid heuristic + LLM judge
    │   ├── bandit.py                   # Contextual Thompson Sampling
    │   └── predictor.py                # Task → failure class prediction
    ├── storage/
    │   ├── qdrant.py                   # Vector DB layer
    │   └── redis_store.py              # Cache + streams
    ├── extraction/                     # Pattern extraction pipeline
    │   ├── alignment.py                # Structural divergence detection
    │   ├── classifier.py               # Rule-based failure classification
    │   ├── abstraction.py              # Pattern abstraction
    │   └── clustering.py               # HDBSCAN clustering
    ├── intervention/
    │   └── templates.py                # Intervention template bank
    ├── replay/
    │   └── engine.py                   # Heuristic effectiveness judge
    ├── evolution/
    │   └── __init__.py                 # LLM mutation engine + evolution lifecycle
    ├── domains/
    │   ├── __init__.py                 # Universal adapter framework (4 domains)
    │   └── templates.py                # Domain-specific intervention templates
    ├── experiment/
    │   └── runner.py                   # Killer experiment orchestrator
    ├── sdk/
    │   ├── __init__.py                 # Package exports
    │   ├── client.py                   # Async HTTP client (graceful degradation)
    │   └── langgraph.py                # LangGraph middleware
    ├── workers/
    │   ├── main.py                     # Trace extraction worker
    │   └── evolution_worker.py         # Intervention mutation + promotion worker
    └── scripts/
        └── seed_antigens.py            # Load validated patterns into Qdrant

Tech Stack

Component Technology Why
API FastAPI Async, <50ms p99
Vector DB Qdrant HNSW <5ms at 100K vectors, payload filtering
State PostgreSQL Audit trail, efficacy tracking
Cache/Queue Redis Hot cache, stream-based async processing
Embeddings all-MiniLM-L6-v2 384-dim, local, free, fast
Clustering HDBSCAN Finds natural clusters without specifying K
LLM (judge/mutations) DeepSeek V4-Flash $0.14/M input — entire learning loop costs $1.47/month
SDK httpx (async) Non-blocking, 500ms timeout, graceful degradation

Key Design Decisions

  1. No LLM calls in the hot path — real-time matching is deterministic (<50ms)
  2. LLM only in async learning loop — judge + mutations run in background workers
  3. Graceful degradation — if AIRAS is down, agents run normally (SDK never blocks)
  4. Two-phase matching — embedding similarity (Qdrant) + condition predicates (code)
  5. Behavioral signals only — runtime matching uses errors, loops, step anomalies (not outcome)
  6. Contextual bandits — different intervention variants for different execution contexts
  7. Self-improving — interventions evolve via LLM-generated mutations + A/B testing
  8. Cross-domain — patterns learned in coding agents transfer to support/research/data agents
  9. Tolerance layer — max 3 interventions per trace, cooldown, auto-disable low-efficacy
  10. Population-level learning — every failure makes the system smarter for ALL users

Supported Domains

Domain Adapter Example Tools
Coding CodingAdapter edit, search, run_test, submit
Customer Support SupportAdapter search_kb, draft_reply, escalate, close_ticket
Research ResearchAdapter web_search, read_paper, synthesize, verify_claim
Data Pipeline DataPipelineAdapter query_db, transform, validate, write_table

Adding a new domain: implement DomainAdapter.map_action() (maps domain tools → 6 universal types). All existing patterns transfer immediately.

The Moat

The failure pattern database is the product. Every deployment adds patterns. More users → more patterns → better prevention → more users. The self-improvement loop means interventions get better every day without human effort.

License

MIT License

Metadata

Release files for airas-sdk 0.2.1

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

Source distribution (sdist)

Source distribution for airas-sdk 0.2.1
File Size Uploaded Provenance Actions
airas_sdk-0.2.1.tar.gz 44.5 kB Without provenance Details for airas_sdk-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for airas-sdk 0.2.1
File Interpreter ABI Platform Actions
airas_sdk-0.2.1-py3-none-any.whl Python 3 none any Details for airas_sdk-0.2.1-py3-none-any.whl

Total release size: 95.7 kB

Release files / airas_sdk-0.2.1.tar.gz

Download URL airas_sdk-0.2.1.tar.gz
Size 44.5 kB
Tags Source
SHA-256 checksum
How to use checksums
673bf20e97645b6eff832d77bf69a53f8feb0a515cf4d8e028b429cba497510c
BLAKE2b-256 checksum
How to use checksums
4573945b2089d9ddbbcd6db30629d162f0a13221ab5906788612afc977f2ed28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / airas_sdk-0.2.1-py3-none-any.whl

Download URL airas_sdk-0.2.1-py3-none-any.whl
Size 51.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
269a126affab2597a6ff85d360b52a23caa4f5a15ee2edf52c9af8446a90cc38
BLAKE2b-256 checksum
How to use checksums
742599b4c68c50eda47f190fa11e9a7f51d79525d9a1ede06d7f53e79012fc3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for airas-sdk 0.2.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.2.1 This release

2 release files No 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