Inspiration

Before a car is allowed on the road, it is crash-tested.

We realized enterprise AI agents should be treated the same way.

Today, AI agents are being connected to customer records, internal databases, external APIs, financial systems, and production workflows. These agents can take actions on behalf of companies, but even a small reliability failure can have serious consequences: exposing PII, accessing another customer's records, sending sensitive information to an external service, skipping an approval step, or violating an internal compliance policy.

Most existing tools help developers observe what an agent did after something goes wrong. We wanted to go one step further.

We built Darwin - a crash-testing and repair system for enterprise AI agents, designed to make them more reliable before they reach production.

Instead of waiting for a real customer to discover a privacy or security failure, Darwin actively tries to break the agent first.


What it does

Darwin takes an enterprise AI agent and systematically stress-tests it against privacy, security, and compliance edge cases.

1. Crash Test

Darwin first analyzes the target agent, its available tools, data access patterns, and the organization's privacy or compliance policies.

A strong frontier model then generates adversarial and realistic evaluation scenarios.

For example:

  • Can one customer retrieve another customer's information?
  • Can the agent accidentally expose PII?
  • Can sensitive data be sent to an external tool?
  • Can the agent skip an identity verification step?
  • Can it access more data than is necessary?
  • Can it violate a company policy?
  • Can it perform an action without a required approval?

Organizations can also upload their own privacy, security, or compliance documents. Darwin uses those policies as additional context when generating crash-test scenarios.


Observability

When Darwin runs each evaluation, it does not only look at the final answer.

It captures the full execution trace of the agent.

This includes:

  • model calls
  • tool calls
  • database accesses
  • tool arguments
  • tool outputs
  • permission decisions
  • external API calls
  • execution errors
  • latency
  • the source file and function involved

This lets Darwin identify not just that the agent failed, but where and why it failed.

For example, an agent might incorrectly return another customer's account information.

Instead of simply reporting:

Unauthorized access detected

Darwin can trace the failure to:

tools/customers.py
→ get_customer()
→ ownership verification missing

This makes the failure actionable.


Evaluations

Reliability testing is only useful if the tests themselves are difficult and representative.

Darwin generates edge cases dynamically using a frontier reasoning model and combines them with deterministic privacy checks.

We intentionally avoid relying entirely on an LLM judge.

Where possible, Darwin uses explicit checks such as:

[ \text{requested_customer_id} \neq \text{authenticated_customer_id} ]

or:

[ \text{sensitive field} \in \text{external payload} ]

These deterministic checks catch concrete failures such as unauthorized record access or PII leakage.

For more nuanced behavior, Darwin uses semantic evaluation to determine whether the agent still completed the legitimate user request correctly.

This is important because the easiest way for an agent to appear "safe" is to refuse every request.

Darwin explicitly tests legitimate requests as well, ensuring that privacy improvements do not destroy usefulness.


Targeted Repair

Finding the failure is only half of the problem.

Darwin goes further and generates an actual source-code fix.

However, we did not want to simply give a coding model unrestricted access to the repository and say:

"Fix the security problem."

Instead, Darwin classifies every defect into one of five constrained reliability repair strategies:

Authorization Gate

Used when the agent is missing ownership, role, tenant, or permission checks.

Example:

if customer_id != auth_context["customer_id"]:
    raise PermissionError("Unauthorized customer access")

Data Minimization

Used when the agent retrieves or shares more information than necessary.

Instead of returning:

return customer.__dict__

Darwin may restrict the response to:

return {
    "name": customer.name,
    "balance": customer.balance
}

Validation Guardrail

Used when an action or payload should be checked before execution.

Examples include:

  • validating recipients
  • checking sensitive fields
  • enforcing schemas
  • blocking dangerous external requests

Workflow Orchestration

Used when the agent performs correct operations in the wrong order.

For example:

Bad workflow:

Retrieve sensitive record
→ Send report
→ Verify identity

Darwin may repair it into:

Verify identity
→ Check permission
→ Retrieve minimum required data
→ Validate output
→ Send report

Runtime Resilience

Used for reliability failures such as:

  • retries
  • timeouts
  • duplicate execution
  • idempotency
  • confidence thresholds
  • fallback behavior
  • human escalation

Each repair strategy is governed by its own skill file.

This means Darwin is not freely rewriting the repository. The repair model receives:

  • the root cause
  • relevant traces
  • applicable policy
  • the relevant source files
  • the selected repair strategy

and is instructed to generate the smallest safe code change.


Verification

A generated fix is never automatically assumed to be correct.

After applying the patch in an isolated Git worktree, Darwin re-runs the evaluation suite.

It tests:

  1. the scenarios that originally failed
  2. legitimate user scenarios
  3. regression tests
  4. held-out evaluation scenarios that the repair model never saw

This separation is important.

The repair model should not be able to optimize directly against every test used to judge its work.

Darwin therefore compares:

[

R_{before}

\frac{\text{tests passed before repair}} {\text{total evaluations}} ]

with:

[

R_{after}

\frac{\text{tests passed after repair}} {\text{total evaluations}} ]

but improving the overall score alone is not enough.

A patch must also satisfy constraints such as:

[ \text{critical privacy failures} = 0 ]

[ \text{regressions} = 0 ]

and:

[ \text{legitimate request success}{after} \ge \text{legitimate request success}{before} ]

This prevents shortcuts such as simply refusing all requests.


GitHub Integration

Once a repair passes validation, Darwin creates a Git branch, commits the validated changes, pushes the branch, and opens a GitHub pull request.

The pull request includes:

  • the discovered root causes
  • the selected repair strategies
  • files changed
  • before-and-after evaluation metrics
  • held-out test performance
  • regression results
  • known limitations

Darwin never automatically merges the pull request.

A human remains in the loop and reviews the code before it reaches production.


Privacy and Compliance Policies

One of the most important parts of Darwin is that reliability is not defined only by generic rules.

Every organization has different policies.

For our demo, we created a fictional banking policy containing requirements such as:

  • customers may access only their own records
  • identity must be verified before account-specific information is returned
  • PII must not be sent to unauthorized external systems
  • sensitive fields must not appear in logs
  • agents should retrieve only the minimum data required
  • certain high-risk actions require human approval

Darwin can use uploaded policy documents to generate organization-specific crash tests.

The goal is not to claim automatic legal compliance.

Instead, Darwin answers a much more concrete question:

"Does this agent behave according to the privacy, security, and compliance policies the organization has defined?"


How we built it

Darwin consists of several coordinated components.

Frontend

We built the frontend using:

  • React
  • TypeScript
  • Tailwind CSS
  • React Flow
  • real-time event streaming

The interface is designed as a reliability engineering workspace rather than a chatbot.

Developers can watch:

  • evaluation scenarios execute
  • failures appear live
  • execution traces
  • root causes
  • selected repair strategies
  • generated code diffs
  • validation results
  • before-and-after reliability
  • the final GitHub pull request

Backend

The backend is built with Python and FastAPI.

The core pipeline orchestrates:

[ \text{Scenario Generator} \rightarrow \text{Evaluation Runner} \rightarrow \text{Observer} \rightarrow \text{Diagnoser} \rightarrow \text{Repair Agent} \rightarrow \text{Validator} ]

Server-Sent Events stream every stage of the pipeline to the frontend in real time.


Agent Orchestration

Darwin uses multiple specialized AI roles rather than asking a single model to do everything.

Challenger

Generates difficult and adversarial evaluation scenarios.

Target Agent

The enterprise agent being tested.

Evaluator

Determines whether the agent behaved correctly.

Diagnoser

Analyzes failed evaluations and traces them to their root cause.

Repair Agent

Generates the smallest targeted source-code patch using one of Darwin's constrained repair strategies.

Validator

Independently checks whether the new version actually improves reliability.

This separation reduces the risk of a model effectively saying:

"I wrote the fix, therefore I think the fix works."


Our demo

For our demo, we use a synthetic banking customer-support agent.

The agent has tools for:

  • retrieving customer information
  • retrieving account balances
  • retrieving transaction histories
  • generating reports

All customer information is synthetic.

Darwin crash-tests the banking agent against scenarios involving:

  • unauthorized customer access
  • PII leakage
  • excessive data retrieval
  • unsafe external data sharing
  • identity and permission failures
  • policy violations

When Darwin discovers a defect, the interface shows the complete path:

Crash test failed
        ↓
Execution trace
        ↓
Privacy/compliance violation
        ↓
Root cause
        ↓
Repair strategy selected
        ↓
Code patch generated
        ↓
Re-evaluation
        ↓
Held-out tests
        ↓
GitHub pull request

Challenges we faced

One of the hardest problems was ensuring that the repair agent could not simply "game" the evaluation system.

For example, if an agent leaks customer information, the easiest possible repair is:

Reject every customer request.

That may eliminate privacy leaks, but it also makes the agent useless.

We therefore designed evaluations containing both adversarial scenarios and legitimate requests.

A repair must improve safety while preserving functionality.

Another major challenge was making code repair targeted.

Giving a coding model the entire repository often results in unnecessarily large or unpredictable changes.

We solved this by combining execution traces, source-code metadata, root-cause grouping, and predefined repair skills.

This allows Darwin to provide the repair model only the code and context relevant to the failure.

We also separated visible evaluations from held-out tests so that a generated patch must generalize beyond the exact failures it was shown.


What we learned

The biggest lesson from building Darwin was that production AI reliability is much more than prompt engineering.

An enterprise agent's behavior depends on:

  • models
  • tools
  • permissions
  • data access
  • workflow ordering
  • APIs
  • application code
  • organizational policies

This means reliability failures often cannot be solved by simply changing the system prompt.

Sometimes the correct solution is a permission gate.

Sometimes it is data minimization.

Sometimes it is validation middleware.

Sometimes the workflow itself needs to change.

This led us to treat AI-agent reliability as an engineering problem rather than purely a model-behavior problem.


What's next

Darwin currently focuses on privacy, security, and policy failures, but the same crash-testing architecture can extend to broader enterprise-agent reliability.

Future directions include:

  • financial-agent reliability
  • healthcare-agent safety
  • browser-agent testing
  • multi-agent workflow failures
  • tool permission auditing
  • production regression monitoring
  • organization-specific reliability benchmarks

The long-term vision is simple:

Every enterprise AI agent should be crash-tested before it reaches production.

Darwin is the infrastructure that makes that possible.


Closing

Claude, GPT, Gemini, and other frontier models will continue becoming better at building and operating agents.

But increasingly capable agents make independent reliability testing even more important.

A frontier model can be the mechanic.

Darwin is the crash-testing facility.

We generate the failures, observe what breaks, repair the underlying code, and independently verify that the agent is safer and more reliable before the change ever reaches production.

Built With

Share this project:

Updates

Submission history