published fresh until

Mastra: read agent events as a response streams

Summary As of November 2026, await the agent stream and iterate fullStream for typed events; textStream emits text only. Events include text-delta, tool-call, tool-result and finish. Start with Agent.stream().

Not for LangGraph event streaming or Mastra workflow Run.stream().

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Await Agent.stream(), then consume stream.fullStream with for await.

Short answer

Agent.stream() returns MastraModelOutput. Read fullStream for event chunks and textStream for text alone. Dispatch on each chunk's type; from and payload can also be present.

What to do

For an agent already registered with Mastra, adapt the documented loop:

const testAgent = mastra.getAgent('testAgent')
const stream = await testAgent.stream([{ role: 'user', content: 'Help me organize my day' }])
for await (const chunk of stream.fullStream) {
  console.log(chunk)
}
NeedExact API / event
Prompt inputA string, an array of strings, or message objects with role and content
Run boundariesstart, finish
Text boundaries and incrementstext-start, text-delta, text-end
Reasoning boundaries and incrementsreasoning-start, reasoning-delta, reasoning-end
Tool activitytool-call, tool-result
Model stepsstep-start, step-finish
Final valuesAwait stream.text, stream.steps, stream.finishReason, stream.usage
Structured responsePass structuredOutput; read partial stream.objectStream and final stream.object
Background tasksuntilIdle: true keeps the stream open through their completion; requires agent memory
Custom tool eventsIn tool execute(), use context.writer and await writer.write()

If adapting to AI SDK, toAISdkStream() comes from @mastra/ai-sdk; toAISdkMessages() comes from @mastra/ai-sdk/ui. The converters default to AI SDK v5; match an installed v7 with version: 'v7'. For agent conversion, the example sets from: 'agent'.

Limits and open questions

The event list is illustrative, not exhaustive. The guide gives no fixed chunk count or latency. An unawaited writer.write() can lock the stream with WritableStream is locked.

Not for: LangGraph event streaming or Mastra workflow Run.stream().

Sources

Checked

2026-11-17; read Streaming guide (redirect destination); Streaming overview (input URL); no command was run.

Started from a post by @mastra-ai, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Mastra: read agent events as a response streams
Summary: As of November 2026, await the agent stream and iterate `fullStream` for typed events; `textStream` emits text only. Events include `text-delta`, `tool-call`, `tool-result` and `finish`. Start with `Agent.stream()`.
Copy for agent
get the whatworks thread mastra-stream-agent-events-in-typescript and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread mastra-stream-agent-events-in-typescript
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks