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] Include session token stats in the AG-UI RUN_FINISHED event #1186
docs/ag-ui-output.md says RUN_FINISHED "carries the session stats (tokens, cost)" in result, but emitRunFinished in internal/platform/render/agui.go emits only WithSuccessOutcome(). RenderAGUI is not handed the session repository, so the counts that RenderJSON already reports in its session_stats line (repo.GetSessionTokens(), repo.GetSessionCostStats()) are dropped on the AG-UI path.
The four token fields are what the desktop parser already expects (inputTokens, outputTokens, cacheReadTokens, totalToolCalls, read from either result or stats). cost, lastInputTokens and contextWindow unblock the desktop's context-percentage and cost indicators (inference-gateway/desktop#217, inference-gateway/desktop#218).
Acceptance
RUN_FINISHED carries the per-session totals after a successful run.
render_test.go asserts the fields are present and non-zero for a run with at least one request.
docs/ag-ui-output.md documents the exact key names.
Done. Issue #1186 is resolved by PR #1187 (ready for review, all CI checks pass).
What changed
RUN_FINISHED on the AG-UI headless path now carries the per-session stats in result, matching what docs/ag-ui-output.md already claimed:
internal/platform/render/render.go - RenderAGUI takes the conversation repository; after a successful run it builds sessionResult from the same repo calls RenderJSON uses (GetSessionTokens / GetSessionCostStats), plus totalToolCalls counted from the session's assistant messages and contextWindow from models.LookupContextWindow (omitted when unknown). Gated exactly like RenderJSON: no model requests means no result (e.g. shortcut answers).
internal/platform/render/agui.go - emitRunFinished attaches the stats via the AG-UI SDK's WithResult option on the terminal event.
Callers - headless renderStream and the browser extension bridge now pass their repos (the bridge's repo may be nil; the nil-guard keeps that path event-identical to before).
render_test.go - new TestRenderAGUI_RunFinishedCarriesSessionStats parses the RUN_FINISHED line and asserts inputTokens 4821, outputTokens 310, cacheReadTokens 3100, totalToolCalls 1, cost 0.042, lastInputTokens 4821, contextWindow 200000, plus the zero-request no-result case; all existing AG-UI tests pass a repo.
docs/ag-ui-output.md - documents the exact key names in a RUN_FINISHED result table.
Validation: render + browser-infrastructure tests pass, task fmt and task lint (purego type-check gate) clean, full pre-commit gate passed, and all PR CI checks pass (build, test, e2e, lint, vet, CodeQL, postgres).
Follow-ups filed: [DOCS] issue in inference-gateway/docs (#672) and a downstream tracking issue for the desktop parser in inference-gateway/desktop (#220). Board item moved to QA. PR: #1187
Activity
edenreich commentedon Sep 12, 2026
@infer Can you work on this? use /ponytail:ponytail /go /go-concurrency
inference-gateway-maintainer commentedon Sep 12, 2026
Model:
ollama_cloud/glm-5.3-flash· View JobTodos
Pull Request
#1187
✅ Infer Result: Success
Done. Issue #1186 is resolved by PR #1187 (ready for review, all CI checks pass).
What changed
RUN_FINISHEDon the AG-UI headless path now carries the per-session stats inresult, matching whatdocs/ag-ui-output.mdalready claimed:internal/platform/render/render.go-RenderAGUItakes the conversation repository; after a successful run it buildssessionResultfrom the same repo callsRenderJSONuses (GetSessionTokens/GetSessionCostStats), plustotalToolCallscounted from the session's assistant messages andcontextWindowfrommodels.LookupContextWindow(omitted when unknown). Gated exactly likeRenderJSON: no model requests means noresult(e.g. shortcut answers).internal/platform/render/agui.go-emitRunFinishedattaches the stats via the AG-UI SDK'sWithResultoption on the terminal event.renderStreamand the browser extension bridge now pass their repos (the bridge's repo may be nil; the nil-guard keeps that path event-identical to before).render_test.go- newTestRenderAGUI_RunFinishedCarriesSessionStatsparses theRUN_FINISHEDline and assertsinputTokens4821,outputTokens310,cacheReadTokens3100,totalToolCalls1,cost0.042,lastInputTokens4821,contextWindow200000, plus the zero-request no-resultcase; all existing AG-UI tests pass a repo.docs/ag-ui-output.md- documents the exact key names in aRUN_FINISHED resulttable.Validation: render + browser-infrastructure tests pass,
task fmtandtask lint(purego type-check gate) clean, full pre-commit gate passed, and all PR CI checks pass (build, test, e2e, lint, vet, CodeQL, postgres).Follow-ups filed: [DOCS] issue in inference-gateway/docs (#672) and a downstream tracking issue for the desktop parser in inference-gateway/desktop (#220). Board item moved to QA. PR: #1187
Model:
ollama_cloud/glm-5.3-flash· Exit Code:0· Duration: 15m 21sTokens: 4,129,366 in · 33,424 out · 4,162,790 total (45 requests)
Tool calls: 81 total · 100% success rate
Traces
Stats
Triggered by edenreich · Infer Action · OSS
inference-gateway-releaser commentedon Sep 12, 2026
🎉 This issue has been resolved in version 0.190.2 🎉
The release is available on:
Your semantic-release bot 📦🚀