Mastra is now an agent meta-harness. Starting today, you can run Claude Code, Cursor, and Codex subagents from within Mastra.
Subagents inherit Mastra's stream composition APIs — hand off to a workflow, or vice versa. You can write evals for them, chat with them in Studio, and swap one for another without changing your code.
Mastra has always been model-agnostic. Today with so many harnesses, we're taking a step towards being harness agnostic as well.
Harnesses maintain their existing feature set — file handling, codebase reasoning, multi-agent handoffs, permission controls — and inherit Mastra's agent surface:
- Calls:
.generate(),.stream(),.resumeGenerate(),.resumeStream() - Per-run options:
requestContext,abortSignal,instructions,structuredOutput,runId,tracingContext - Composition: workflow steps, subagent delegation, attached tools
- Observability: logs, traces, token usage, model cost in Studio
Get started
Install the SDK package and its peer dependency. This example uses Mastra’s ClaudeSDKAgent:
npm install @mastra/claude @anthropic-ai/claude-agent-sdkCreate a new SDK agent and configure it with sdkOptions:
import { ClaudeSDKAgent } from "@mastra/claude";
export const claudeSDKAgent = new ClaudeSDKAgent({
id: "claude-sdk-agent",
name: "Claude SDK Agent",
description: "Anthropic's Claude Agent SDK with file editing, shell execution, and codebase reasoning.",
sdkOptions: {
model: "claude-opus-4-8",
cwd: process.cwd()
}
});Register SDK agents on your Mastra instance:
import { Mastra } from "@mastra/core/mastra";
import { claudeSDKAgent } from "./agents/claude-sdk-agent";
export const mastra = new Mastra({
agents: { claudeSDKAgent }
});If you've already built an OpenAI or Cursor agent, pass it to a Mastra SDK agent using the agent option:
import { Agent } from "@openai/agents";
import { OpenAISDKAgent } from "@mastra/openai";
const existingOpenAIAgent = new Agent({
name: "OpenAI Agent",
instructions: "...",
model: "gpt-5.3-codex"
});
export const openaiSDKAgent = new OpenAISDKAgent({
id: "openai-sdk-agent",
name: "OpenAI SDK Agent",
description: "...",
agent: existingOpenAIAgent
});For more information and full configuration options, see:
