feat(gateway): expand runtime footer usage stats - #58677
Conversation
Duplicate of #54988 — both expand the gateway runtime footer with per-session/per-turn usage stats (token totals, cache-hit %, turn count) in |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for expanding the opt-in gateway footer. The feature is not already on current main: gateway/runtime_footer.py:31 still supports only model, context_pct, and cwd.
Problems
- In PR commit
de5ca99, the newgateway/run.pycall readssession_tokens,session_cache_read_tokens,session_prompt_tokens,turn_count,last_turn_prompt_tokens, andlast_turn_cached_tokensfromagent_result. The normal result built inagent/turn_finalizer.py:449-457exposes none of those names; it providestotal_tokens,cache_read_tokens,prompt_tokens, andlast_prompt_tokens. The added footer values therefore default to zero on the primary completed-turn path. - PR commit
de5ca99formats turns asf"{turn_count}轮", which hard-codes Chinese in the otherwise language-configurable gateway output.
Suggested changes
- Align the finalizer result schema and gateway consumer, then add a gateway-level test for that actual result-to-footer path.
- Localize the turn label or use a language-neutral rendering.
Automated hermes-sweeper review.
| context_tokens=agent_result.get("last_prompt_tokens", 0) or 0, | ||
| context_length=agent_result.get("context_length") or None, | ||
| cwd=os.environ.get("TERMINAL_CWD", ""), | ||
| session_tokens=agent_result.get("session_tokens", 0) or 0, |
There was a problem hiding this comment.
agent_result from agent/turn_finalizer.py:449-457 has total_tokens, cache_read_tokens, prompt_tokens, and last_prompt_tokens, not these new session_*/last_turn_* keys. This primary path will pass zeroes and suppress the new fields; either extend the finalizer result contract or consume its existing key names.
What does this PR do?
Related Issue
Fixes #
Type of Change
Changes Made
How to Test
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs