---
title: "Deterministic AI Testing with Session Recording in cagent"
description: "cagent's session recording applies the VCR pattern to AI agents."
url: "https://swe.quest/articles/deterministic-ai-testing-with-session-recording-in-cagent-aad4a70e828b2b3b"
canonical: "https://www.docker.com/blog/deterministic-ai-testing-with-session-recording-in-cagent/"
source: "Docker"
published: "2026-01-06"
difficulty: "medium"
kind: "How-to"
reading_minutes: 2
tags: ["ai-agents","testing","ci-cd"]
---

# Deterministic AI Testing with Session Recording in cagent

A post on [Docker](https://swe.quest/sources/docker.md), published 2026-01-06, 2 min read, How-to. Original: [https://www.docker.com/blog/deterministic-ai-testing-with-session-recording-in-cagent/](https://www.docker.com/blog/deterministic-ai-testing-with-session-recording-in-cagent/)

## Summary

cagent's session recording applies the VCR pattern to AI agents. It proxies requests to the model provider, saves each request/response cycle to a YAML cassette, and replays matching requests from that file, so test runs are deterministic, cost nothing in API calls and finish in milliseconds. The --record and --fake flags support CI testing without API keys, cheap prompt iteration against one recording, sharing reproducible bug reports, and capturing multi-agent delegation. Tool call IDs are normalized so replay matching works, and auth headers are stripped so cassettes can be committed to version control.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)

## Prerequisites

- AI agent basics ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- HTTP mocking

## Keywords

cagent, Docker, VCR pattern, OpenAI, Anthropic

## Related posts

- [Agents, Randomness, and Receipts: Notes from trivago's QA Meetup](https://swe.quest/articles/agents-randomness-and-receipts-notes-from-trivago-s-qa-meetup-6bb8ef93642d84a1.md): trivago tech · 2026-08-12 · Easy · 5 min read · Testing, AI agents, AI for coding, Developer productivity
  Recap of three QA meetup talks on verifying testing and delivery.
- [Build a Multi-Agent System in 5 Minutes with cagent](https://swe.quest/articles/build-a-multi-agent-system-in-5-minutes-with-cagent-b6fd900693f4f3cc.md): Docker · 2025-10-14 · Medium · 4 min read · AI agents, LLMs, Developer tools
  cagent is an open-source Docker tool that defines multi-agent AI systems declaratively in a single YAML file.
- [Agents are users, so your software needs evals](https://swe.quest/articles/agents-are-users-so-your-software-needs-evals-ae7971006fec5a38.md): Vercel · 2026-11-16 · Medium · 19 min read · Evaluation, AI agents, Testing, LLMs
  Agents act as users of APIs, CLIs, MCP servers and SDKs, so measuring whether they complete tasks correctly requires evals: tests run many times and scored.
- [Agentic Testing: Where Agents Fit in the E2E Testing Stack](https://swe.quest/articles/agentic-testing-where-agents-fit-in-the-e2e-testing-stack-fa760680a95bc5c9.md): Slack Engineering · 2026-06-11 · Medium · 11 min read · Testing, AI agents, LLMs, Cost optimization
  Across 200+ agent-driven E2E runs against Slack test workspaces, agents using Playwright MCP were the most reliable (0% failures on a simple thread-reply flow, ~12% on a longer search flow).
- [Scaling Managed Agents with stable interfaces](https://swe.quest/articles/scaling-managed-agents-with-stable-interfaces-06b4cb4f85923c79.md): Anthropic Engineering · 2026-04-08 · Medium · 9 min read · AI agents, System design, Sandboxing & isolation, Resilience, LLMs
  Claude Managed Agents splits a long-running agent into three virtualized interfaces: an append-only session log, a stateless harness that calls Claude and routes tool calls, and sandboxes reached through a generic \`execute(name, input) → string\` tool call.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
