feat(gateway): expand runtime footer telemetry - #54988
Conversation
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
left a comment
There was a problem hiding this comment.
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:364callsfuture.result()synchronously, but the footer is built from the async gateway final-send path (gateway/run.py:10529in this PR). A slow provider request blocks the gateway event loop. Current/usageavoids this withawait asyncio.to_thread(...)atgateway/slash_commands.py:3981-3992.gateway/runtime_footer.py:80changes enabled footers with no explicitfieldsfrom 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.
| base_url=base_url, | ||
| api_key=api_key, | ||
| ) | ||
| snapshot = future.result(timeout=timeout_seconds) |
There was a problem hiding this comment.
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.
| resolved = {"enabled": False, "fields": list(_DEFAULT_FIELDS)} | ||
| resolved: dict[str, Any] = { | ||
| "enabled": False, | ||
| "fields": list(_DEFAULT_FIELDS), |
There was a problem hiding this comment.
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.
| """ | ||
| try: | ||
| token_data = _read_codex_tokens() | ||
| except Exception: |
There was a problem hiding this comment.
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.
Summary
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 byusage_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