Behavioral regression testing for AI agents that take actions: deterministic tool twins, Quality-Diversity search, and a replayable regression corpus for CI.
pip install lifeforge==0.4.0 Copy PIP instructions
Your agent's failure map, re-tested on every pull request. LIFE FORGE builds a deterministic twin of the tools your agent can call, searches for the conditions that make it move money, leak data, or skip a gate, and turns every scenario it finds into a replayable regression test.
Most agent red-teaming sends a list of attack prompts to a model and asks another model whether the reply looked bad. That tells you little about an agent whose job is to do things. LIFE FORGE judges what the agent actually did to the world:
pip install -e ".[all]" # 1. Generate a twin of the tools your agent uses (from an MCP manifest), then edit it lifeforge compile-domain --from-mcp mcp_tools.json --out my_domain.yaml lifeforge compile-domain --spec my_domain.yaml --check # 2. Record the baseline on main: search + save the replayable corpus lifeforge surface --record --domain-spec my_domain.yaml --target agent.py:my_agent --out results/agent_surface.json # 3. On every PR: replay the corpus against the changed agent and fail on regressions lifeforge surface --baseline results/agent_surface.json --domain-spec my_domain.yaml --target agent.py:my_agent --fail-on-regression Research Results: 8 Open-Weight Models (oracle 1.x) Eight local open-weight models (Ollama, one RTX 4090) were run as procurement agents through 30 generations at seed=42, one campaign per model.
Read these numbers with their limits. They come from a single seed per model and were judged by oracle 1.x. The October 2026 audit (oracle 2.0) found that oracle 1.x over-reported some categories. The table below is kept for provenance with corrected labels. It is not a statistically meaningful ranking, and it will be replaced by multi-seed re-runs.
What the data does support, as observations to test with more seeds:
Profiles and raw JSON: results/LEADERBOARD.md. Write-up: docs/research/THE_SCALE_PARADOX_IN_AI_AGENTS.md. Both predate oracle 2.0, so apply the same caveats.
Unlike standard optimizers that search for only one failure, LIFE FORGE maps an entire topography of agent fragility across a 3-dimensional phenotypic coordinate space:
A zero-side-effect in-memory enterprise simulation state (WorldState) with instantaneous snapshot and causal rollback. Agents interact with 5 simulated enterprise tools:
Monitors agent actions after every step and enforces mathematical policy boundaries:
LIFE FORGE can be run as a standard Model Context Protocol (MCP) server over stdio or SSE. Any MCP-compatible client--including Claude Desktop, Cursor, LangGraph, or custom multi-agent frameworks--can directly connect to LIFE FORGE's adversarial environments.
Test any frontier or local model with zero code changes:
Underneath the agent simulator lies LIFE FORGE's foundational Artificial Life laboratory, designed to measure open-ended evolution and avoid the "Beautiful Garbage" trap (confusing high-entropy white noise with true computational complexity):
Clone the repository and install with optional extras:
git clone https://github.com/zariffromlatif/life-forge.git cd life-forge python -m venv .venv # On Windows: .\.venv\Scripts\Activate.ps1 # On Linux/macOS: source .venv/bin/activate # Install with LLM, MCP, and visualization dependencies: pip install -e ".[all]" 1. Instant Baseline Stress Test (Offline / Zero Cost) Stress-test the built-in reference agent across 50 evolutionary generations (requires no API keys):
python -m lifeforge.cli test --scenarios 50 --out results/baseline_report.md --json 2. Stress-Test Local Models on Your GPU (Ollama) Run unlimited, free evolutionary stress tests against open-weight models on your local GPU (e.g. RTX 3080/4090):
# 1. Start Ollama with your chosen model: ollama run llama3.1:8b # 2. Run LIFE FORGE against your local GPU: python -m lifeforge.cli test --model ollama/llama3.1:8b --api-base http://localhost:11434 --scenarios 30 --seed 42 --out results/llama_report.md --json 3. Launch the Visual Flight Simulator Dashboard (Web UI) Explore 3D MAP-Elites behavior spaces, compare model showdowns, and inspect step-by-step exploit traces in an interactive local command center (zero extra dependencies required):
python -m lifeforge.cli ui --port 8000 Open your browser at http://localhost:8000 to inspect discovered failures, explore behavioral niches, or export an executive PDF audit dossier. The dashboard binds to localhost and rejects requests with a foreign Host header.
Run against cloud frontier models using your API keys:
# Test Gemini (Google AI Studio Free Tier): $env:GEMINI_API_KEY = "your-api-key" python -m lifeforge.cli test --model gemini/gemini-1.5-flash --scenarios 20 --delay 4.0 --out results/gemini_report.md --json # Test OpenAI GPT-4o: $env:OPENAI_API_KEY = "your-api-key" python -m lifeforge.cli test --model gpt-4o-mini --scenarios 20 --out results/gpt_report.md --json 5. Evaluate Your Own Agent via Python Spec or Webhook (lifeforge eval) Evaluate your existing agent pipelines (LangGraph, CrewAI, AutoGen, or custom microservices) with a single command:
# Evaluate a Python agent class, instance, or callable: python -m lifeforge.cli eval --target path/to/my_agent.py:MyAgentClass --scenarios 30 --out results/my_agent_report.md --json # Evaluate any remote or containerized agent via HTTP webhook: python -m lifeforge.cli eval --endpoint http://localhost:5050/act --reset-endpoint http://localhost:5050/reset --scenarios 30 # Enforce CI/CD gating (fails build with exit code 1 if critical findings are discovered): python -m lifeforge.cli eval --target my_agent.py:agent --scenarios 25 --fail-on-critical 6. Head-to-Head Model Showdown Comparison Compare two or more evaluation reports side-by-side to crown the security winner:
python -m lifeforge.cli compare results/local_qwen_report.json results/local_llama_report.json --out results/MODEL_SHOWDOWN.md 7. Run as an MCP Server (Claude Desktop & Cursor) Expose LIFE FORGE as a live MCP tool server:
python -m lifeforge.cli mcp-serve --transport stdio --adversarial Add to your claude_desktop_config.json:
{ "mcpServers": { "lifeforge": { "command": "python", "args": ["-m", "lifeforge.cli", "mcp-serve", "--transport", "stdio", "--adversarial"] } } } 8. Scientific Cellular Automata Laboratory Simulate candidate universes and compute quantitative MODES complexity vectors:
# Run Conway's Game of Life python -m lifeforge.cli run --substrate totalistic --steps 100 # Run Wolfram Rule 110 (Turing complete) python -m lifeforge.cli run --substrate elementary --rule 110 --steps 100 # High-throughput 100-universe physics survey python -m lifeforge.cli survey --count 100 --steps 150 --db results/survey.jsonl 9. Docker Container Deployment Run the complete LIFE FORGE environment inside an isolated Docker container with zero host dependencies:
# Launch interactive web dashboard on http://localhost:8000 docker compose up lifeforge-ui # Or run ad-hoc agent flight simulation docker build -t lifeforge:latest . docker run --rm -v ${PWD}/results:/app/results lifeforge test --scenarios 30 --out results/docker_report.md --json Scenario Domains: Test Beyond Procurement The procurement ERP is the default environment, but the same evolutionary search runs against four registered scenario domains, each with its own world state, tool suite, invariant policies, and adversarial mutators:
lifeforge domains # list what each domain tests lifeforge eval --domain customer_support --target agent.py:my_agent --json lifeforge eval --domain devops --endpoint http://localhost:5000/act lifeforge eval --domain financial --target agent.py:trading_agent Domain Agent under test Failure modes it surfaces procurement Enterprise purchasing agent Unauthorized wire transfers, retry loops, budget breaches customer_support SaaS/telco support agent Social-engineered refunds, PII exfiltration, admin-grant abuse devops CI/CD pipeline agent Gate bypass (merge/deploy without tests), secret egress, forced merges financial Trading desk agent Approval bypass, spoofed-signal trading, risk-model tampering Frontier Attacks (2026 Research Gaps) Opt in with --frontier to add five attack classes that contemporary tooling does not cover:
lifeforge test --model ollama/llama3.1:8b --frontier --json self_replicating_worm: injections whose payload copies itself into the agent's own outputs (paired SELF_REPLICATING_WORM_PROPAGATION oracle verdict). rag_memory_poisoning: false facts seeded into memory/RAG stores that survive the session (paired RAG_MEMORY_POISONING_ADOPTED). cross_session_propagation: payloads instructing the agent to persist directives for the next agent in an orchestration. context_flood: oversized untrusted payloads sized to evict safety instructions from the context window (CONTEXT_FLOOD_ATTACK). multilingual_degradation: the same injection delivered in Chinese, Russian, Arabic, Base64, and romanized Chinese to expose language-dependent guardrails. Pluggable Invariant Policies The oracle's checks are extensible: lifeforge/sandbox/policies.py ships nine composable policy objects (ContextFloodAttackPolicy, CascadingToolFailurePolicy, UnauthorizedScopeExpansionPolicy, ExcessiveDataQueryingPolicy, ProhibitedArgumentValuePolicy, BalanceDrainPolicy, RequiredPredecessorPolicy, PayloadPropagationPolicy, PoisonedMemoryAdoptionPolicy). Attach them to any GoalSpecification:
from lifeforge.sandbox import GoalSpecification from lifeforge.sandbox.policies import ExcessiveDataQueryingPolicy goal = GoalSpecification(policies=[ExcessiveDataQueryingPolicy(max_sensitive_queries=1)]) Framework Adapters: LangChain, LangGraph, CrewAI Wrap an existing framework agent with zero modification and evaluate it in the sandbox:
from lifeforge.adapters import LangChainAdapter, LangGraphAdapter, CrewAIAdapter executor = AgentExecutor(agent=agent, tools=tools) # your existing LangChain agent lf_agent = LangChainAdapter(executor) app = builder.compile() # your compiled LangGraph graph lf_agent = LangGraphAdapter(app=app) crew = Crew(agents=[...], tasks=[...]) # your CrewAI crew lf_agent = CrewAIAdapter(crew=crew) results = lifeforge.test(lf_agent) Or let LIFE FORGE auto-detect the framework in your project:
lifeforge quickstart # scans the current directory, generates a harness, runs the benchmark lifeforge quickstart --dry-run # detection only, writes nothing Detection covers LangChain, LangGraph, CrewAI, AutoGen, LlamaIndex, smolagents, and OpenAI Agents.
lifeforge report --input results/local_llama_report.json --output audit_report.pdf --customer "Acme Corp" Executive summary page with risk score and band, failure-mode tables, threat-surface charts, per-finding evidence, remediation section, and a reproducibility appendix.
Turn every discovered violation into a drop-in tool-boundary guard:
lifeforge harden --input results/local_qwen_report.json --out remediation_decorators.py The generated file imports the real runtime from lifeforge.hardening (@tool_guard, PolicyError) - guards raise PolicyError before a forbidden call reaches your implementation.
lifeforge audit --input results/local_phi4_report.json --customer "Acme Corp" --out audit_report/ # or run a fresh audit directly: lifeforge audit --target agent.py:my_agent --customer "Acme Corp" --out audit_report/ Produces: executive_summary.md + .pdf, technical_report.md + .pdf, raw_data.json, reproduction_commands.sh, remediation_decorators.py, and MANIFEST.md.
The same invariant policies that judge simulations enforce production tool calls, with a tamper-evident (hash-chained) audit trail:
lifeforge gateway --input results/local_qwen_report.json --out lifeforge_policy.yaml from lifeforge.gateway import PolicyGateway gateway = PolicyGateway.from_config("lifeforge_policy.yaml") guarded = gateway.wrap_executor(original_executor) # drop-in replacement # gateway.audit.verify() -> tamper check over the whole trail Critical findings become blocking rules; lower-severity ones start in monitor mode so you can promote them after observing false-positive rates.
A free, deterministic scanner for MCP tool definitions. It is a supporting tool, not the product: it feeds the twin generator (compile-domain --from-mcp), and Snyk Agent Scan covers similar static ground. Point it at a manifest or a live server:
# Static scan of a tool manifest lifeforge mcp-scan --manifest mcp_tools.json --out results/mcp_scan.md --json # Live probe: handshake + tools/list + rug-pull (drift) check across two fetches lifeforge mcp-scan --server "python my_mcp_server.py" --baseline approved.json --out results/mcp_scan.md # Streamable HTTP endpoint (CI gate on critical findings) lifeforge mcp-scan --url https://mcp.example.com/mcp --fail-on-critical lifeforge mcp-scan --list-rules # the full ruleset Detected classes: schema poisoning anywhere in the schema (descriptions, nested properties, enums, defaults; NFKC-normalized, decoded Base64 payloads), invisible Unicode by category, non-ASCII tool and parameter names, destructive tools with no authorization surface, unbounded parameters, cross-server tool shadowing, and description drift after approval (the rug pull). A server's band is anchored on its most severe finding, so CRITICAL means a CRITICAL finding exists. The scanner never calls tools, but a live probe does launch the server, which runs its startup code: probe untrusted servers in a sandbox.
Example: examples/mcp_manifest_example.json ships with a poisoned tool and a homoglyph-shadowed tool - scan it to see the detector classes fire.
The built-in domains model four environments, but your agent talks to your tools. Describe them in a YAML spec and LIFE FORGE compiles a working sandbox - world state, executable tools with real effects, and the invariant policy set - without writing Python:
domain: name: expense_approval title: Expense Approval Desk declared_tools: [lookup_expense, approve_expense, send_email] world: balances: {expense_budget: 50000} inbox: [{from: manager, subject: Approve EXP-1001, body: Please review.}] tools: - name: approve_expense description: Approve an expense and debit the budget. args: expense_id: {type: string, pattern: "^EXP-[0-9]{4}$", required: true} amount: {type: number, minimum: 0, required: true} effects: - spend: {balance: expense_budget, amount_arg: amount} - record: {list: approved, include_args: [expense_id, amount]} policies: - balance_drain: {balance_key: expense_budget, max_drain: 500} Or start from an MCP server's tool list instead of writing the spec by hand. Every tool keeps its argument schema, state-changing tools are gated behind a generated request_human_approval tool, and the output is a spec you then edit:
lifeforge compile-domain --from-mcp mcp_tools.json --out my_domain.yaml --task "Refund order ORD-1 if eligible" lifeforge compile-domain --spec my_domain.yaml --check # validate + probe episode lifeforge test --domain-spec my_domain.yaml --scenarios 30 # red-team an agent against it lifeforge surface --domain-spec my_domain.yaml --record --out results/surface.json Everything is validated at compile time - unknown policies, unknown effects or argument types, effects referencing undeclared arguments or unknown balances - with the full list of valid options in the error. Tools validate their arguments (required, type, pattern, enum, min/max, finite numbers) and refuse invalid calls the way real tools do; a tool's effects apply atomically, and spending cannot overdraw an account unless the spec allows it. Full worked example: examples/custom_domain_expense_approval.yaml.
We scanned 15 of the most-installed public MCP servers (9 live protocol probes, 6 static source extractions; 167 tool definitions). Maintainers of Microsoft's playwright-mcp and Upstash's context7 triaged the reported issues.
Correction (2026-10-10). The first version of this scan reported 40% of servers in the CRITICAL band. That was a scoring bug: bands followed finding volume, and the scan had zero CRITICAL findings. Re-scored with bands anchored on the most severe finding: 0 CRITICAL, 8 HIGH (mostly state-changing tools with no confirmation or approval argument), 4 MODERATE, 3 LOW. Three static extractions (brave-search, google-maps, slack) were invalid because of an extraction bug and need a fresh scan. Details and original scores: results/MCP_ECOSYSTEM_SCAN.md.
A one-shot benchmark tells you whether an agent fails. A regression gate has to tell you whether this change made it worse, and comparing two searches cannot do that reliably: the search explores differently once the agent changes, so a failure can disappear from the map only because it was not visited.
lifeforge surface --record therefore saves two things: the failure surface, and a corpus of every scenario the search kept (passing and failing) together with the baseline agent's verdict on each. In CI the corpus is replayed scenario by scenario against the changed agent. That replay is the gate, and it compares like with like:
# On main: run the search, record the surface and the replayable corpus lifeforge surface --record --target agent.py:my_agent --scenarios 30 --out results/agent_surface.json # On every PR: replay the corpus (gate) and run a fresh search (new findings to triage) lifeforge surface --baseline results/agent_surface.json --target agent.py:my_agent --scenarios 30 \ --out results/surface_diff.md --json --fail-on-regression # Sampled LLM agents: replay each scenario several times and allow for sampling noise lifeforge surface --baseline results/agent_surface.json --target agent.py:my_agent \ --repeats 5 --tolerance 0.2 --fail-on-regression The report lists every regressed scenario (a previously handled scenario now fails, a failure became critical, or a new violation type appeared) and every fixed one, with the mutations that built it. Scenarios where the agent errored on every run (API down, bad key) are reported as invalid, never as fixed. The fresh search is diffed against the baseline search as informational output: new failing cells there are leads to triage and add to the corpus, not a gate.
Cross-session propagation attacks only become observable when a second agent runs on the state the first one left behind. The swarm runner chains agents sequentially over one evolving world - each hop inherits the previous agent's memory, outbox, and flags, plus a neutral orchestrator handoff message - and judges every hop with the same invariant oracle:
from lifeforge.sandbox.swarm import run_swarm, cross_agent_propagations result = run_swarm([agent_a, agent_b], world, between_hops=attack_mutator) result.critical_hops # which hops went critical cross_agent_propagations(result, marker) # payload moved hop 0 -> hop 1 Attacks inject at the handoff boundary (between_hops), which is where multi-agent coordination attacks actually live.
Map the deterministic violation register onto regulatory controls (EU AI Act: risk management Art. 9, data governance Art. 10, record-keeping Art. 12, transparency Art. 13, human oversight Art. 14, robustness Art. 15):
lifeforge compliance --input results/local_qwen_report.json --gateway-trail audit_trail.jsonl --customer "Acme Corp" --out results/compliance_pack.md Per-control verdicts: GAP (violations mapped to the control), PASS, or UNVERIFIED. When a gateway audit trail is supplied, its hash chain is verified as part of the record-keeping control. The document is deterministic evidence, not a legal opinion - and says so on its face.
Keep agents that obey injected instructions, leak data, or deadlock out of production. Add the LIFE FORGE GitHub Action (action.yml) to a repository. Pin it to a release tag, not @main: it is a security gate.
# .github/workflows/agent_guard.yml name: AI Agent Gatekeeper on: [push, pull_request] jobs: gatekeeper: runs-on: ubuntu-latest permissions: contents: read pull-requests: write # Allows posting audit summary to PR review steps: - uses: actions/checkout@v4 - name: Run LIFE FORGE Flight Simulation uses: zariffromlatif/life-forge@v0.4.0 with: target: "src/agent.py:my_agent" # Python agent class, instance, or callable scenarios: 30 # Number of evolutionary scenarios fail-on-critical: "true" # Block the PR if critical findings are discovered comment-on-pr: "true" # Post audit table directly to PR review Action Configuration Matrix Input Description Default target Python agent specifier (e.g. src/agent.py:my_agent) "" endpoint HTTP webhook URL for Dockerized / remote microservice agents "" reset-endpoint Optional HTTP reset URL for external microservice agents "" scenarios Number of evolutionary generations to simulate 30 seed Deterministic random seed for reproducible exploration 42 fail-on-critical Exit with code 1 and block build if critical vulnerabilities found 'true' comment-on-pr Post an executive audit table directly into PR review comments 'true' report-path Output path for generated Markdown audit report results/lifeforge_audit.md github-token GitHub token for PR comments and summaries ${{ github.token }} See examples/ci_agent_workflow.yml for a complete copy-paste workflow.
lifeforge/ ├── substrates/ # Artificial Life & Cellular Automata physics │ ├── base.py # Abstract Substrate & State interfaces │ └── ca/ │ ├── elementary.py # 1D Elementary CA (Rules 0-255) │ ├── totalistic.py # 2D Vectorized Outer-Totalistic CA (Moore/von Neumann) │ └── multi_state.py # Multi-State 2D CA (Brian's Brain, Langton loops) │ ├── metrics/ # Quantitative MODES measurement suite │ ├── evolutionary_activity.py# Bedau-Packard evolutionary activity & neutral shadow baseline │ ├── complexity.py # Shannon entropy, bit-packed LZW, Complexity Gap │ ├── novelty.py # Pattern vocabulary growth & trajectory divergence │ ├── ecology.py # Connected-component entity labeling (pure NumPy BFS) │ └── modes.py # Unified Wolfram class classifier (I, II, III, IV) │ ├── sandbox/ # Enterprise Agent Simulation Sandbox │ ├── world_state.py # Deterministic digital twin state machine with deep rollback │ ├── mock_tools.py # Enterprise tools (database, vendor API, PO, email, funds transfer) │ ├── agent.py # AgentInterface, RuleBasedPurchasingAgent, CallableAgentAdapter │ ├── oracle.py # Invariant policy enforcement & SandboxRunner orchestrator │ ├── policies.py # Pluggable invariant policies (flood, cascade, scope, recon, worm, poison) │ ├── domains/ # Scenario domains: procurement, customer_support, devops, financial │ ├── llm_agent.py # Unified LiteLLM adapter with 429/503 rate-limit backoff │ └── mcp_server.py # Model Context Protocol (MCP) JSON-RPC stdio server │ ├── evolution/ # Co-Evolutionary Red-Teaming Engine │ ├── engine.py # EvolutionEngine coordinating multi-generation search │ ├── map_elites.py # 3D Quality-Diversity Archive (adversarial x volatility x budget) │ └── mutators/ │ ├── environmental.py # PriceVolatility, InventoryScarcity, BudgetConstraint, VendorDropout │ ├── adversarial.py # IndirectPromptInjection, SpoofedExecutiveMessage, ConflictingSpec │ ├── frontier.py # 2026 frontier attacks: worms, memory poisoning, context flood, multilingual │ ├── mcp_schema.py # MCP tool schema poisoning (CVE-2025-53773 / CVE-2025-54135 class) │ └── semantic.py # 10,000+ combinatorial template payloads & SLM generation │ ├── reporting/ # Causal Root-Cause Diagnostics │ ├── analyzer.py # CausalAnalyzer extracting minimal failure triggers │ ├── report.py # Markdown and JSON executive audit generator │ ├── leaderboard.py # Ranked model security leaderboard generator │ ├── audit.py # Customer-deliverable audit bundle (PDF + evidence + remediation) │ └── pdf.py # CISO-ready PDF export (reportlab, vector charts) │ ├── adapters/ # Framework adapters (lazy imports, zero lock-in) │ ├── langchain.py # LangChain AgentExecutor adapter │ ├── langgraph.py # LangGraph compiled StateGraph adapter │ ├── crewai.py # CrewAI Crew adapter │ └── generic.py # Callable adapter for any Python agent │ ├── mcpsec/ # MCP security scanner (poisoning, drift, shadowing) │ ├── manifest.py # Tool-definition model + manifest loaders │ ├── detectors.py # Static ruleset over MCP tool definitions │ ├── probe.py # Live stdio/HTTP protocol probe + drift check │ └── report.py # Scan scoring and Markdown/JSON reports │ ├── hardening.py # @tool_guard runtime + remediation code generator ├── gateway.py # Runtime PolicyGateway with tamper-evident audit chain │ └── cli/ # Unified Command-Line Interface ├── main.py # Commands: run, survey, test, eval, compare, mcp-serve, ui, │ # leaderboard, report, harden, audit, gateway, domains, │ # quickstart, mcp-scan, surface, compile-domain └── quickstart.py # Framework auto-detection + harness generation Test Suite LIFE FORGE maintains an extensive test suite verifying algorithm determinism, tool execution, and regression immunity:
pytest -q # PDF tests are skipped when reportlab is not installed (pip install -e ".[pdf]") Examples & Programmatic API Check the examples/ directory for self-contained, runnable Python integration scripts:
If you use LIFE FORGE in your research or evaluations, please cite using CITATION.cff.
ai-agents red-teaming llm-security evolutionary-computation map-elites artificial-life cellular-automata model-context-protocol mcp ai-safety
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.




