0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00

Compare commits

...

4 commits

Author SHA1 Message Date
Anurag Ojha
80f0597be8 Merge branch 'main' into fix/model-span-tracker-output-lag 2026-11-17 13:05:17 +05:30
Anurag Ojha
cf10ebdf71 fix(core): trace a chunk only after the stream accepts it
A background tool result can arrive after the run's stream has closed. The loop traced that chunk before the closed stream rejected it, so the trace got a model step and a model inference span that never ended. Enqueue the chunk first, so a rejected chunk is not traced.
2026-11-17 13:05:06 +05:30
Anurag Ojha
8f92b3dec8 fix(core): trace agent stream chunks when the loop writes them
The span tracker got step events from the agent loop and from the output
stream. The stream reads chunks later when onStepFinish is slow, so the two
sources ran out of order. Record each chunk at the loop's enqueue point instead,
like durable agents do. Trackers without recordChunk keep the old path.
2026-11-15 13:55:58 +05:30
Anurag Ojha
7f24c3fc20 test(observability): cover model spans when onStepFinish is slow
The agent loop starts the next model call before the output stream reads the
last step-finish. Both tests fail on main: the third call is recorded under the
second step with its tokens counted twice, and a failed call gets an extra step.
2026-11-15 13:55:56 +05:30
5 changed files with 119 additions and 4 deletions