Skip to content

feat(gateway): expand runtime footer usage stats - #58677

Open
gittuyn wants to merge 1 commit into
NousResearch:mainfrom
gittuyn:feat/runtime-footer-usage-stats
Open

feat(gateway): expand runtime footer usage stats#58677
gittuyn wants to merge 1 commit into
NousResearch:mainfrom
gittuyn:feat/runtime-footer-usage-stats

Conversation

@gittuyn

@gittuyn gittuyn commented Jul 5, 2026

Copy link
Copy Markdown

What does this PR do?

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #54988 — both expand the gateway runtime footer with per-session/per-turn usage stats (token totals, cache-hit %, turn count) in gateway/runtime_footer.py with the same agent-side per-turn token plumbing. #54988 is the earlier, more comprehensive implementation of umbrella #19922 (the saturated footer-usage cluster). Flagging as a duplicate so a reviewer can consolidate onto the canonical PR.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new gateway/run.py call reads session_tokens, session_cache_read_tokens, session_prompt_tokens, turn_count, last_turn_prompt_tokens, and last_turn_cached_tokens from agent_result. The normal result built in agent/turn_finalizer.py:449-457 exposes none of those names; it provides total_tokens, cache_read_tokens, prompt_tokens, and last_prompt_tokens. The added footer values therefore default to zero on the primary completed-turn path.
  • PR commit de5ca99 formats turns as f"{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.

Comment thread gateway/run.py
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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users area/usage-cost Token accounting, usage reporting, billing, cost tracking labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/usage-cost Token accounting, usage reporting, billing, cost tracking comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants