FailSafe by PhT Labs

Contract testing for
multi-agent AI systems

Validate handoffs, prevent data leakage, and enforce compliance policies — in milliseconds.

Demo coming soon

Get started in seconds

Install

$ pip install failsafe-ai

Usage

from failsafe import FailSafe
 
fs = FailSafe(mode="block")
 
fs.register_agent("research_agent")
fs.register_agent("writer_agent")
 
fs.contract(
name="research-to-writer",
source="research_agent",
target="writer_agent",
allow=["query", "sources", "summary"],
deny=["api_key", "internal_config"],
require=["query", "sources"],
)
 
result = await fs.handoff(
source="research_agent",
target="writer_agent",
payload={
"query": "AI safety",
"sources": ["arxiv.org/1234"],
"api_key": "sk-secret-123", # blocked
},
)
# result.passed == False
# "Denied fields found in payload: ['api_key']"

Built for production agent systems

Validate in milliseconds

Deterministic contract rules execute without LLM calls — sub-millisecond validation.

Prevent data leakage

Allow/deny field lists and pattern detection block sensitive data from crossing agent boundaries.

Compliance policies

Pre-built policy packs for finance regulations and GDPR. Load with a single line.

LLM-as-judge

Natural language rules evaluated by an LLM for nuanced validation beyond deterministic checks.

Full audit trail

Every handoff logged to SQLite with violations, timestamps, and trace IDs.

Warn or block modes

Choose whether violations log warnings or actively block handoffs. Configure per-contract.

How it works

01

Define contracts

Register agents and declare allow/deny rules, required fields, and natural language policies.

02

Validate handoffs

Call fs.handoff() whenever agents pass data. Contracts are checked in microseconds.

03

Monitor & audit

Every validation is logged. Inspect violations, trace issues, and export compliance reports.