How It Works
The regression layer for production AI agents.
Capture agent state at failure time, propose a fix, and require replay verification before a pull request can open. Three steps with a defined contract: nothing merges until the replay passes.
Step 1: Capture
Intercept the Exact Run That Failed
When your agent misbehaves in production, Relai's capture hook records everything needed to replay that run identically: tool call inputs, model responses, environment state, and the session context at the moment of failure.
- 01Capture Hook
A single SDK call wraps your agent's execution boundary and begins recording on any non-zero exit.
- 02State Serialization
Tool state, memory context, and intermediate outputs are serialized into a portable replay bundle.
- 03Log Retention
Configurable retention windows: 7 days on Developer, 30 on Team, 90 on Scale. Logs are encrypted at rest.
- 04Replay ID
Each captured failure gets a stable ID you can reference in PRs, Slack, or your issue tracker.
✓ relai.capture(agent_run)
replay_id: rpl_0a1b2c3d
captured_at: 2026-06-20T14:33:01Z
tool_calls: 12 recorded
model: gpt-4o-mini@2024-07
exit_code: 1 (non-zero)
context_tokens: 4,892
state_size: 18.4 KB
→ Bundle stored. Use replay_id to reproduce.
✗ Step 4: summarize_findings()
TypeError: expected list, got None
at agent.run:line 88
tool_state: {findings: null}
✓ Step 4: summarize_findings()
findings coerced to []
tool_state: {findings: []}
Replay passed in 1.2s
Step 2: Replay
Deterministic Replay on Every Fix Candidate
Every captured failure becomes a frozen environment. When a developer proposes a fix, Relai restores the exact tool state, model version, and context, then re-runs the agent against it. The replay is identical each time, eliminating the nondeterminism that makes AI bugs so hard to verify.
Step 3: Verify
Fixes That Have to Earn Their Merge
A fix proposal is only credible if it passes the failure it claims to solve. Before a PR can open, Relai runs the proposed change against the captured replay environment and gates the result. Green replay: PR opens. Red replay: the fix goes back to the developer, not to production.
- findings = tool_result["findings"]
+ findings = tool_result.get("findings") or []
replay_id: rpl_0a1b2c3d
Replay Passed ✓
PR gate: unlocked
CI Integration
Connect to Your Pipeline
Relai runs in GitHub Actions, GitLab CI, and any environment that can execute a shell command.
- name: Install Relai SDK
run: pip install relai-sdk
- name: Run agent with capture
env:
RELAI_API_KEY: ${{ secrets.RELAI_API_KEY }}
run: relai run --capture ./agent.py
Everything Your Team Needs
Configurable 7, 30, or 90-day retention windows. Failure bundles are encrypted at rest and accessible via API.
POST to any endpoint on failure capture and fix verification events. Integrates with Slack, PagerDuty, and custom receivers.
Capture from parallel agent runs across distributed pipelines. Each run gets its own isolated replay bundle.
Browse all fix attempts per failure ID. Compare how each proposed change performed on replay and track resolution time.
Python and JavaScript SDKs. Install in under two minutes and start capturing with a single function call.
Per-agent health overview. See capture rate, replay pass rate, and mean time to fix across your entire agent fleet.