agent.network() Usage Tracking Not Working

Environment - Mastra: 0.0.0-ai-sdk-network-text-delta-20251017172601 (snapshot for network streaming fix) - Provider: @openrouter/ai-sdk-provider (direct, not through Mastra gateway) - Models: OpenRouter with GPT-4o-mini, Grok, etc. - Use case: Credit-based billing system - need accurate token usage for each network call What We Found The Problem agent.network() returns zero usage data - both networkStream.usage and all chunk/result objects have no usage information. What We Tried 1. ✅ Verified OpenRouter config with createOpenRouter({ extraBody: { usage: { include: true } } }) 2. ✅ Inspected all stream chunks - finish chunk is completely empty: {"type":"finish"} 3. ✅ Inspected data-network chunks - contain agent output but no usage 4. ✅ Checked networkStream.result.steps - no usage in any step metadata 5. ✅ Tried onRouteComplete callback - never fires What We See
// Finish chunk structure:
{"type":"finish"} // Empty - no payload, no usage

// networkStream.result structure:
{
status: "success",
steps: {...},
result: "...",
// NO usage field
// NO experimental_providerMetadata
}
// Finish chunk structure:
{"type":"finish"} // Empty - no payload, no usage

// networkStream.result structure:
{
status: "success",
steps: {...},
result: "...",
// NO usage field
// NO experimental_providerMetadata
}
The snapshot build doesn't track or expose usage data anywhere. What We Need Accurate token usage tracking for agent.network() calls to bill users correctly. Right now we can only track direct agent.stream() calls (those work fine), but network routing usage is invisible. Questions 1. Is this a known limitation of the snapshot build? Should we wait for a proper release with usage tracking? 2. What's the recommended approach? Should we: - Instrument individual agents to report usage to a collector? - Use direct agent.stream() calls for credit-sensitive operations? - Wait for Mastra to add network-level usage tracking? 3. Does using OpenRouter directly (not through Mastra gateway) affect this? We're using @openrouter/ai-sdk-provider with createOpenRouter(). 4. Is there a hidden API or callback we're missing? We've checked chunks, result, callbacks - usage data doesn't exist anywhere. We're building a production credit system and can't deploy without accurate usage tracking. Any guidance appreciated! @Romain or @Ward is there way to track usage data with the Agent Network approach?
7 Replies
Mastra Triager
GitHub
[DISCORD:1429448714484846703] agent.network() Usage Tracking Not Wo...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1429448714484846703 Environment Mastra: 0.0.0-ai-sdk-network-text-delta-20251017172601 (snapshot for netwo...
Ward
Ward2d ago
we will get this sorted @! .kinderjaje, thank you for the twitter post as well! if it doesn't go out tomorrow, we will do a hotfix on wednesday or thursday
! .kinderjaje
! .kinderjajeOP2d ago
thats amazing Ward! Thank you alot man. I feel bad everytime I mention you guys, but I felt that I needed to get your attention with those does my post have sense? Did u have time to confirm the issue? Sometimes I am not 100% sure if the issue is on my side or Mastra, but I not gonna report until I spent all night on it and abuse both Cursor and CC
Ward
Ward2d ago
Just report away, we have the GOAT @Romain who does the triaging and we go throug all issues each day and target them accordingly. Network has been relativly new and not much usage so when in doubt just open an issue 🙂 haven't had the time yet to test it myself yet
! .kinderjaje
! .kinderjajeOP2d ago
I hope its on Mastra :P, dont wanna embarrass myself
Ward
Ward2d ago
Nah, if not our issue, we can always improve the docs. Don't think about embarrassment. We are all here to learn together! We should be embaressed for not able to get you from point a -> b without issues.
! .kinderjaje
! .kinderjajeOP2d ago
its okay, I know u are just warming up guys. The important thing is that someone can listen to our pain. 🙏

Did you find this page helpful?