Runtimes · Mastra

Mastra Overview

Mastra is a TypeScript agent framework. It is the only non-Python runtime in the measured set, and the only one whose upstream AG-UI integration ships no HTTP endpoint at all.

The Threadplane example is a camping trip planner. It streams messages, calls a backend tool, keeps a packing list in shared state through Mastra's working memory, and suspends a run for human approval before reserving a campsite.

See it live

The hosted example runs at examples.threadplane.ai/runtimes/mastra. The Angular source is cockpit/runtimes/mastra, and its backend is deployments/ag-ui-mastra rather than the FastAPI deployment the two Python runtimes share.

What the integration demonstrates

SurfaceStatusHow
MessagesSupportedStreamed assistant text over TEXT_MESSAGE_CHUNK.
Tool callsSupportedcheck_conditions executes server-side with no pause.
Shared stateSupportedA working-memory packing list, over snapshots and real JSON-Patch deltas.
InterruptsSupportedreserve_campsite suspends the run and resumes from a persisted snapshot.
SubagentsNot availableACTIVITY_* is reserved for background tasks and observational memory.

Upstream ships no HTTP endpoint

@ag-ui/mastra provides an in-process MastraAgent bridge and a CopilotKit runtime mount. It does not provide a plain AG-UI HTTP endpoint, which is what @threadplane/ag-ui connects to.

Threadplane therefore maintains a small hosting service, deployments/ag-ui-mastra. It accepts POST /agent/<topic>, calls MastraAgent.run(input), and writes one Server-Sent Events frame per AG-UI event. It is deliberately hand-written rather than generated: the Python generator targets one aggregated FastAPI process, and Mastra is a different language on a different hosting lane.

This is the honest shape of the Mastra integration. The adapter needed no changes, but somebody has to serve the events, and upstream does not.

Persistence is a hard requirement

Mastra persists memory and suspended-run snapshots to LibSQL file storage. Resume loads the suspended snapshot back, so the database path has to survive between HTTP requests and across restarts. An in-memory store breaks resume, and an ephemeral filesystem orphans every pending interrupt on redeploy.

Subagents are not available

Mastra reserves the ACTIVITY_* events for background tasks and observational memory. The Threadplane subagent projection keys on an activityType of subagent, which Mastra does not emit and does not intend to.

As with the other two runtimes, this is an upstream modeling difference rather than an adapter defect.

How the Mastra row was measured

Its cells come from a real Mastra server driven with live model calls. The raw Server-Sent Events were captured off the wire and are committed and replayed like every other runtime's, including the interrupt and resume round trip driven through the real @ag-ui/client.

Next steps