跳到正文
Mastra Blog·· 2 小時前AI 評分48

Mastra Observability 推出 Thread View

Introducing Thread View for Mastra Observability

AI 導讀

Mastra Observability 在 Mastra Studio 推出 Thread View,讓用戶並排查看智能體對話訊息及其生成步驟,亦可按順序檢視完整對話。已有記憶功能並透過 MastraStorageExporter 儲存追蹤記錄的智能體無須額外設定。Thread View 要求 mastra@1.33.0 或更新版本,並只適用於屬於 thread 的智能體追蹤記錄。

正文

You can now read agent conversations alongside their traces in Mastra Studio. Open an agent trace to see its messages next to the steps that produced them. Then open the full thread to see the whole conversation in order.

When you debug an agent's behavior, you want to follow the story of what the user asked, what the agent decided, and which tools it called. The longer the agent runs, the harder it gets to find the right step. A single session can span dozens of messages. Thread view lets you inspect the trace in the context of the whole conversation.

Agent activity is usually traced as a tree of nested steps, model calls, and timestamps. Even though a tree view is precise, it's difficult to interpret. You have to reconstruct the conversation to understand what happened. With the thread view, it's the other way around.

You start from the messages and when something looks wrong, you dig into the steps behind it. It's easier to read, follow and navigate. Thread view also helps subject-matter experts who need to review an agent's behavior but didn't build the agent.

Get started

If your agent already uses memory and persists traces with MastraStorageExporter, no additional setup is required. Thread view works with its existing stored traces.

If you start from scratch, install Mastra observability, memory, and storage:

npm install mastra@latest @mastra/core @mastra/observability @mastra/memory @mastra/libsql

note

Requires mastra@1.33.0 or later, added in PR #25812.

Thread view appears for agent traces that belong to a thread. Give your agent memory and persist traces with the MastraStorageExporter:

import { Mastra } from "@mastra/core/mastra";
import { Agent } from "@mastra/core/agent";
import { Memory } from "@mastra/memory";
import { LibSQLStore } from "@mastra/libsql";
import { Observability, MastraStorageExporter } from "@mastra/observability";
 
const supportAgent = new Agent({
  id: "support-agent",
  name: "Support Agent",
  instructions: /* ... */,
  model: "openai/gpt-5.6-astra",
  tools: { /* ... */ },
  memory: new Memory()
});
 
export const mastra = new Mastra({
  agents: { supportAgent },
  storage: new LibSQLStore({ id: "storage", url: "file:./mastra.db" }),
  observability: new Observability({
    configs: {
      default: {
        serviceName: "mastra",
        exporters: [new MastraStorageExporter()]
      }
    }
  })
});

Call the agent with a thread and resource. Each call becomes one turn in the thread, and one trace in Studio:

const agent = mastra.getAgent("supportAgent");
 
await agent.generate("What's the status of my order?", {
  memory: { thread: "thread-123", resource: "user-456" }
});

Run mastra dev, open Traces in Studio, and select an agent run. The conversation for that turn appears beside the span tree.

Hover over any message and select Highlight spans to see the steps behind it with the rest of the tree faded.

Select Open full thread to see the whole conversation.

For more information and full configuration options, see:

來源:Mastra Blog · mastra.ai