You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Emit a session token/cost summary on agent stream completion #552
Consumers of the JSON-line stream from infer agent (notably inference-gateway/infer-action, which surfaces run results on the GitHub issue) want to report how much a run cost.
Today the stream exposes per-turn token counts: each assistant ConversationMessage carries token_usage (prompt_tokens / completion_tokens / total_tokens) — see cmd/agent.goprocessSyncResponse → outputMessage. infer-action now sums these and shows a token line in the result footer.
But the dollar cost is never emitted on the stream. The CLI already computes it internally for the interactive UI via the pricing service (internal/services/pricing_service.goCalculateCost) and SessionCostStats (internal/domain/pricing.go). Stream consumers can't reach it without re-implementing the per-model pricing table, which would drift.
Proposal
When an infer agent session completes, emit a single structured status line (the machinery already exists — AgentSession.outputStatusMessage emits {type, message, timestamp, ...metadata}), e.g.:
Sourced from the same SessionTokenStats / SessionCostStats the /cost shortcut already displays. This lets headless consumers print real cost without summing per-turn usage or duplicating pricing.
Notes / questions
A final aggregate line is preferable to per-turn cost, but per-turn cost on each assistant message would also work.
Should this be gated (e.g. only in non-interactive agent mode, or behind a flag) to avoid noise for existing stream consumers? A new type is additive and should be safe to ignore.
Once available, infer-action will replace its token-only footer with the reported cost.
Filed from infer-action work on richer run reporting.
Activity
feat(agent): emit session_stats summary on stream completion (#553)
docs(cli): document the agent stream session_stats summary line
docs(cli): document the agent stream session_stats summary line (#86)
inference-gateway-releaser commentedon May 29, 2026
🎉 This issue has been resolved in version 0.115.0 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀