[BUG] 可观察性: 在完成的运行中,`model_chunk` 跨度中包含 `chunkType: 'tool-result'` 并导出了 `endedAt: null`
作者: kassol创建于 2026年9月17日更新于 2026年9月17日
标签Observability (AI Telemetry)effort:lowimpact:mediumstatus: auto-triaged
Install @mastra/[email protected], @mastra/[email protected] and zod in an empty package with "type": "module".
repro.mjs:
import { Agent } from '@mastra/core/agent';
import { Mastra } from '@mastra/core/mastra';
import { createTool } from '@mastra/core/tools';
import { Observability, TestExporter } from '@mastra/observability';
import { z } from 'zod';
const toolCallId = 'call-1';
function stream(parts) {
return {
stream: new ReadableStream({
start(controller) {
for (const p of parts) controller.enqueue(p);
controller.close();
},
}),
};
}
const step1 = () =>
stream([
{ type: 'stream-start', warnings: [] },
{ type: 'response-metadata', id: 'r1', modelId: 'mock', timestamp: new Date(0) },
{ type: 'reasoning-start', id: 'reason-1' },
{ type: 'reasoning-delta', id: 'reason-1', delta: 'thinking' },
{ type: 'reasoning-end', id: 'reason-1' },
{ type: 'tool-input-start', id: toolCallId, toolName: 'echo' },
{ type: 'tool-input-delta', id: toolCallId, delta: '{"text":"hi"}' },
{ type: 'tool-input-end', id: toolCallId },
{ type: 'tool-call', toolCallId, toolName: 'echo', input: '{"text":"hi"}' },
{ type: 'finish', finishReason: 'tool-calls', usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 } },
]);
const step2 = () =>
stream([
{ type: 'stream-start', warnings: [] },
{ type: 'response-metadata', id: 'r2', modelId: 'mock', timestamp: new Date(0) },
{ type: 'text-start', id: 'text-1' },
{ type: 'text-delta', id: 'text-1', delta: 'done' },
{ type: 'text-end', id: 'text-1' },
{ type: 'finish', finishReason: 'stop', usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 } },
]);
let call = 0;
const model = {
specificationVersion: 'v2',
provider: 'mock',
modelId: 'mock-model',
supportedUrls: {},
async doGenerate() {
throw new Error('not used');
},
async
…内容来源: mastra-ai/mastra