cd /news/ai-agents/llm-recorder-package-in-mastra-codeb… · home › topics › ai-agents › article
[ARTICLE · art-179395] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

llm-recorder package in Mastra codebase.

Ramu Narasinga identified an internal Mastra package called _llm-recorder that records and replays real LLM API responses for deterministic tests, working like test snapshots that auto-record on first run and replay thereafter. The package uses Mock Service Worker for HTTP interception, supports SSE streaming with chunk timing, matches requests by MD5 hash of URL and body rather than order, and covers OpenAI, Anthropic, Google and OpenRouter APIs. It is currently internal to the TypeScript agent framework, with no announced date for a public release.

key takeaway

Mastra's internal _llm-recorder intercepts LLM HTTP calls via Mock Service Worker, matching requests by MD5 hash of URL plus body and replaying recorded SSE streams with original chunk timing, so agent tests run deterministically across OpenAI, Anthropic, Google and OpenRouter.

by read2 min views7 publishedDec 1, 2026

In this article, we review recordings folder found in core package in Mastra codebase. You will learn:

Mastra is a TypeScript framework for building AI agents and applications. Create your first agent with a single command and start building.

You can follow this [Quickstart guide](https://mastra.ai/docs#quickstart) to get started.

Following are the [usecases](https://mastra.ai/docs#use-cases) I found for this framework

Embed agents in your product

Customer-facing assistants

Software factories

Internal copilots

Regulated and back-office operations

Data analysis agents

Content automation

DevOps and engineering automation

Sales and go-to-market workflows

Learn more about these [usecases](https://mastra.ai/docs#use-cases).

I found a package named _llm-recorder in Mastra codebase. How? well, I first came across the folder named recordings in the core package. I searched for recording across the entire codebase and found the below results:

This helped me locate this package, _llm-recorder.

LLM response recording and replay for tests. Works like test snapshots - auto-records on first run, replays deterministically thereafter.

This is currently an internal package in Mastra. It will become a public package in the future. I don't know when this will be a public package.

Recording/Replay: Record real LLM API responses and replay them in tests

MSW-based: Uses Mock Service Worker for reliable HTTP interception

Streaming Support: Captures and replays SSE streaming responses with chunk timing

Contract Validation: Detect API schema drift in nightly tests

Multi-provider: Supports OpenAI, Anthropic, Google, and OpenRouter APIs

Content-based Matching: Requests matched by MD5 hash of URL + body, not order

There are 4 usage examples provided in the llm-recorder README.

Suite-wide via Vite plugin

Per-file via enableAutoRecording()

Per-describe via useLLMRecording()

Per-test via withLLMRecording()

Hey, my name is Ramu Narasinga. I spent 4+ years studying OSS codebases and wrote 400+ articles on what makes the production-grade.

Need help with a project? drop me an email - ramu.narasinga@gmail.com or book a meeting.

── more in #ai-agents 4 stories · sorted by recency
── more on @mastra 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/llm-recorder-package…] indexed:0 read:2min 2026-12-01 · —