Introducing Browser Recording for Mastra Agents

Record and replay your agent's browser sessions.

Paul ScanlonPaul Scanlon·

Jul 2, 2026

·

2 min read

Your Mastra agents can now record their browser sessions with browser recording. Each run writes a video file to disk letting you replay every step your agent took.

Recordings include open captions explaining what the agent is doing — “opening blog post”, “entering email address”, or “clicking submit” — embedding a running trace of its reasoning, useful for debugging and agent tuning.

Before browser recording, an agent's browser session was live-only in Studio. When the run ended, there was no option to replay. Now every session can be recorded, archived or shared with your team.

Browser recording exposes two tools to the agent: browser_record which starts and stops the recording, and browser_record_caption which adds the open captions.

Get started

Install a browser provider:

GNU BashTerminal
npm install @mastra/stagehand # or @mastra/agent-browser
note

Requires @mastra/core@1.43.0 or later, added in PR #17028.

Configure StagehandBrowser with an outputDir for recordings — and a headless mode:

TypeScriptsrc/mastra/agents/web-search-agent.ts
import { join } from "node:path";
import { Agent } from "@mastra/core/agent";
import { StagehandBrowser } from "@mastra/stagehand";
 
export const webSearchAgent = new Agent({
  id: "webSearchAgent",
  name: "Web Search Agent",
  model: "anthropic/claude-opus-4-8",
  instructions: "You are a research assistant.",
  browser: new StagehandBrowser({
    headless: false,
    recording: {
      outputDir: join(process.cwd(), "browser-recordings")
    }
  })
});

When developing locally with Studio the above config would output a .avi file to: src/mastra/public/browser-recordings.

For more information and full configuration options, see:

Share:
Paul Scanlon
Paul ScanlonTechnical Product Marketing Manager

Paul Scanlon sits between Developer Education and Product Marketing at Mastra. Previously, he was a Technical Product Marketing Manager at Neon and worked in Developer Relations at Gatsby, where he created educational content and developer experiences.

All articles by Paul Scanlon