Skip to content

feat(gateway): expand runtime footer telemetry - #54988

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

feat(gateway): expand runtime footer telemetry#54988
aerbaser wants to merge 1 commit into
NousResearch:mainfrom
aerbaser:feat/runtime-footer-usage-fields

Conversation

@aerbaser

Copy link
Copy Markdown

Summary

  • expand the gateway runtime footer with configurable fields for full context usage, account limit windows, token totals, cost, and cwd
  • fetch provider account-limit telemetry with bounded timeout + cache so final replies are not blocked
  • preserve the actual chat route in turn metadata so footer telemetry is not polluted by auxiliary/compression model routes
  • make Codex usage lookup resilient when runtime credentials resolve outside the legacy singleton token store
  • update runtime-footer docs and slash-command references

Notes

The feature stays opt-in behind display.runtime_footer.enabled. Account-limit fields (session_limit, weekly_limit) are skipped silently when telemetry is unavailable. Provider usage fetches are cached and time-bounded by usage_cache_seconds / usage_timeout_seconds.

Tests

  • python -m pytest tests/agent/test_turn_finalizer_chat_metadata.py tests/gateway/test_runtime_footer.py tests/test_account_usage.py -q

@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 labels Jun 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: this is the broadest open implementation of the runtime-footer expansion umbrella #19922 (full context usage, account limits, token totals, cost, cwd). It overlaps the open footer-usage cluster — issues #35427 / #52288 / #27536 / #26877 and competing PRs #52600 / #49300 / #49026. Not a duplicate; flagging the cluster so a maintainer can pick the canonical footer-expansion 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 the comprehensive footer expansion. The underlying feature remains absent from current main: gateway/runtime_footer.py:105-118 and the call at gateway/run.py:11827-11834 currently support only model, context percentage, and cwd.

Problems

  • gateway/runtime_footer.py:364 calls future.result() synchronously, but the footer is built from the async gateway final-send path (gateway/run.py:10529 in this PR). A slow provider request blocks the gateway event loop. Current /usage avoids this with await asyncio.to_thread(...) at gateway/slash_commands.py:3981-3992.
  • gateway/runtime_footer.py:80 changes enabled footers with no explicit fields from the legacy three fields to account-limit lookups. Gateway loads raw YAML (gateway/run.py:2315-2358), so existing opt-in footer users acquire new requests and output without selecting those fields.
  • The Codex credential portion is superseded by 130e2337c (agent/account_usage.py:439-494), which preserves pool support while guarding against wrong-account fallback.

Suggested changes

  • Make account telemetry refresh non-blocking and render cached data immediately.
  • Keep legacy implicit fields; require explicit account/token/cost field selection.
  • Salvage the footer work without restoring the superseded Codex path.

Automated hermes-sweeper review.

Comment thread gateway/runtime_footer.py
base_url=base_url,
api_key=api_key,
)
snapshot = future.result(timeout=timeout_seconds)

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.

build_footer_line() is invoked synchronously from the async gateway final-send path, so future.result() stalls the entire gateway event loop until timeout. Please make this refresh non-blocking (cache-only render plus background refresh, or an async bounded await); /usage already uses await asyncio.to_thread(...) for this reason.

Comment thread gateway/runtime_footer.py
resolved = {"enabled": False, "fields": list(_DEFAULT_FIELDS)}
resolved: dict[str, Any] = {
"enabled": False,
"fields": list(_DEFAULT_FIELDS),

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.

This changes existing enabled footers that omit fields into account-usage fetches. Gateway reads raw user YAML, so runtime_footer: {enabled: true} does not receive a migration/default merge. Preserve the legacy implicit fields and require explicit selection of account-limit/token/cost fields.

Comment thread agent/account_usage.py
"""
try:
token_data = _read_codex_tokens()
except Exception:

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.

This account-id resilience is now covered by mainline 130e2337c through _resolve_codex_usage_credentials, including guards against incorrect pool-account fallback. Do not restore a parallel legacy path during salvage; retain the current resolver and its tests.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform 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 sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants