Agents that work as you intend.

Counterfact is an agent quality harness that continuously redesigns and optimizes your AI system to be consistent, correct, and understandable, at the cost and latency point you choose.

PATH TAKEN LATENT COUNTERFACTUAL · R-8841
Product

For companies building AI products where consistency and correctness matter.

Most agent tooling records what happened and leaves the diagnosis to you. Counterfact engineers the system: modular components with defined responsibilities, root causes isolated to the component that produced them, fixes tested against the behavior they replace, and eval sets that keep the result in place. These are the disciplines software teams already trust, applied to a stack that has been running without them.

Architecture counterfact/checkout-agent · main · analyzed 2m ago
Webhook POST /support
Router sonnet-4.5
query_orders issue_refund +7
order_cache redis
Policy check ×398
policy_api · audit_log
Escalation haiku-4.5
counterfactual · replaying r-8841
Reply
path taken latent counterfactual
Read the system in one screen

The graph is the front door. See the agents, the tools they call and the paths production takes, without reading the repository.

Apply a fix as a pull request

Counterfact writes the change, opens the PR in your repository and commits the eval set that proves it. One action, in your existing workflow.

Bring the whole team in

Product owners read the same graph engineers do, so a question about intent gets answered by the person who knows, not translated first.

How it works

From one large prompt to a system you can understand and control

Modularize

A flaky agent becomes a system you can inspect and rely on.

Counterfact brings the rigor of systems engineering to agent building: it decomposes a monolithic agent into discrete components, so you can see what each part is doing instead of guessing from one large prompt.

agent.py
12,180 token prompt
Router
sonnet-4.5
Policy check
agents/policy.py
order_cache
redis
tools ×9
scoped schemas
Escalation
latent
prompts ×3
one per agent
Isolate and optimize

The component that caused the failure, found and fixed.

Counterfact tests interventions against the original behavior, identifying which change reverses the bad outcome and repairing it with measurable impact.

F-114 · Ordering · seen ×12 HIGH
Refund issued before policy check

The router emits issue_refund and policy_check as parallel tool calls, so the refund lands before the policy result returns.

Router issue_refund ✕ policy_check
S-42 · Move the policy check ahead of the refund
removes 12 of 12
Collaborate

Everyone who shapes the agent can read it.

Counterfact asks the questions only a human can settle, and it asks them in a screen a product owner can read without opening the repository. Answers apply to the system in place. No prompt archaeology, no waiting for the one engineer who remembers how the router works.

NEEDS YOUR JUDGEMENT · F-109
Should a refund over $500 always escalate to a human, or only for first-time customers?
Always escalateFirst-time only
Your answer becomes a policy the harness tests and enforces.
Evaluate

Eval sets from a few labeled examples.

Good eval sets are expensive to build by hand. Counterfact takes a few labeled examples and generates a set that covers the behaviors you care about.

EVAL SETCASESPASS RATE
Refund policy adherence 120 88%
Order lookup accuracy 240 94%
Escalation routing 60 71%
6 labeled examples → 420 generated cases
Balance

Quality, cost, and latency, at the point on the frontier you choose.

Counterfact compares combinations of models, providers, and system choices to trace the Pareto frontier of cost, quality, and latency, so you can run at the point that fits your budget and reliability target.

$0.001 $0.003 $0.006 80% 90% 99% COST PER CALL QUALITY YOUR OPERATING POINT $0.0026 · 94.2% · p95 1.2s
Compound

Counterfact keeps a consistent record.

Most teams stop after the first patch that seems okay. Counterfact records every evaluation, failure, and proven fix, so the system can change without losing what already works.

S-42 merged and verified: refund ordering fixed 2d ago
E-21 recorded: 120 cases from production traces 4d ago
Regression caught: model swap dropped E-18 from 94% to 89%, rolled back 1w ago
S-38 applied: cost per call $0.0041 → $0.0026 2w ago
About

Reliability is a systems problem, not a model problem.

Counterfact Labs builds software for engineers who have shipped an AI agent and watched it fail in a way no dashboard explained. Agent reliability improves the way software reliability always has: by treating the system as a system that can be inspected, tested, and improved.

Our approach combines causal testing, structured evaluation, and production monitoring, so that every change is measured against the behaviors that matter to you and your users. We build the harness that keeps those behaviors working.

We have spent our careers building ML systems in production, and we have felt both the benefit of rigorous systems engineering and the difficulty of building reliable AI without it. That is why we built Counterfact.

Contact

Tell us what you are building, and where it fails.