{"slug": "llm-recorder-package-in-mastra-codebase", "title": "llm-recorder package in Mastra codebase.", "summary": "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.", "body_md": "In this article, we review **recordings** folder found in core package in Mastra codebase. You will learn:\n\nMastra is a TypeScript framework for building AI agents and applications. Create your first agent with a single command and start building.\n\nYou can follow this [Quickstart guide](https://mastra.ai/docs#quickstart) to get started.\n\nFollowing are the [usecases](https://mastra.ai/docs#use-cases) I found for this framework\n\nEmbed agents in your product\n\nCustomer-facing assistants\n\nSoftware factories\n\nInternal copilots\n\nRegulated and back-office operations\n\nData analysis agents\n\nContent automation\n\nDevOps and engineering automation\n\nSales and go-to-market workflows\n\nLearn more about these [usecases](https://mastra.ai/docs#use-cases).\n\nI found a package named [_llm-recorder in Mastra codebase](https://github.com/mastra-ai/mastra/tree/c42d9b40ddcd7481d62f8e6b0a67aa1854e11969/packages/_llm-recorder). How? well, I first came across the folder named [**recordings** in the core package](https://github.com/mastra-ai/mastra/tree/main/packages/core/__recordings__). I searched for [**recording** across the entire codebase](https://github.com/search?q=repo%3Amastra-ai%2Fmastra+__recordings__&type=code) and found the below results:\n\nThis helped me locate this package, _llm-recorder.\n\nLLM response recording and replay for tests. Works like test snapshots - auto-records on first run, replays deterministically thereafter.\n\nThis 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.\n\nRecording/Replay: Record real LLM API responses and replay them in tests\n\nMSW-based: Uses Mock Service Worker for reliable HTTP interception\n\nStreaming Support: Captures and replays SSE streaming responses with chunk timing\n\nContract Validation: Detect API schema drift in nightly tests\n\nMulti-provider: Supports OpenAI, Anthropic, Google, and OpenRouter APIs\n\nContent-based Matching: Requests matched by MD5 hash of URL + body, not order\n\nThere are 4 usage examples provided in the [llm-recorder README](https://github.com/mastra-ai/mastra/blob/c42d9b40ddcd7481d62f8e6b0a67aa1854e11969/packages/_llm-recorder/README.md?plain=1#L57).\n\nSuite-wide via Vite plugin\n\nPer-file via enableAutoRecording()\n\nPer-describe via useLLMRecording()\n\nPer-test via withLLMRecording()\n\nHey, my name is Ramu Narasinga. I spent 4+ years studying OSS codebases and wrote 400+ articles on what makes the production-grade.\n\nNeed help with a project? drop me an email - [ramu.narasinga@gmail.com](mailto:ramu.narasinga@gmail.com) or [book a meeting](https://thinkthroo.com/contact).", "url": "https://wpnews.pro/news/llm-recorder-package-in-mastra-codebase", "canonical_source": "https://dev.to/ramunarasinga-11/llm-recorder-package-in-mastra-codebase-27g7", "published_at": "2026-12-01 13:12:50+00:00", "updated_at": "2026-12-01 13:15:37.014757+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "large-language-models", "ai-tools"], "entities": ["Mastra", "Ramu Narasinga", "Mock Service Worker", "OpenAI", "Anthropic", "Google", "OpenRouter"], "also_reported_by": [], "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.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/llm-recorder-package-in-mastra-codebase", "markdown": "https://wpnews.pro/news/llm-recorder-package-in-mastra-codebase.md", "text": "https://wpnews.pro/news/llm-recorder-package-in-mastra-codebase.txt", "jsonld": "https://wpnews.pro/news/llm-recorder-package-in-mastra-codebase.jsonld"}}