Skip to content

feat(gateway): refresh runtime footer metadata - #98180

Closed
sfire123 wants to merge 7 commits into
NousResearch:mainfrom
sfire123:refresh/runtime-footer-quota-18188
Closed

sfire123 wants to merge 7 commits into
NousResearch:mainfrom
sfire123:refresh/runtime-footer-quota-18188

Conversation

@sfire123

Copy link
Copy Markdown

What does this PR do?

This is a refreshed replacement for NousResearch/hermes-agent#18188, rebased onto the current upstream main.

It extends the opt-in runtime footer with model/reasoning metadata and provider account/quota information while preserving the legacy default footer. Quota refresh is non-blocking and uses stale-while-revalidate behavior so a slow or unavailable provider does not block message delivery.

The branch also carries the hardening originally proposed in lancecheney/hermes-agent#1: routed-profile and credential-scoped cache isolation, in-flight deduplication, stale preservation on transient failures, bounded cache size, and removal of raw credentials from agent_result.

The original #18188 branch belongs to lancecheney, so it cannot be rebased from this account. This PR keeps the original open and provides a current-main review target without force-pushing another user's branch.

Scope

  • Runtime footer remains opt-in.
  • Legacy default fields remain model, context_pct, and cwd.
  • Explicit fields can include reasoning, provider account/quota data, reset windows, and related metadata.
  • Account usage follows the configured provider/base URL behavior, including OpenAI-compatible proxies.
  • Profile and credential boundaries are preserved for multiplexed gateways.

Changes

  • Extend runtime footer configuration and rendering.
  • Add Codex window labels derived from the API's limit_window_seconds.
  • Add provider account/quota lookup and compact reset formatting.
  • Add non-blocking stale-while-revalidate quota caching.
  • Preserve profile/credential isolation and avoid raw credential propagation.
  • Update English and Chinese configuration documentation.
  • Add and update focused regression tests.

Validation

Rebased branch validation on Linux:

Focused runtime-footer/account-usage suite: 82 passed, 0 failed
ruff: passed
py_compile: passed
git diff --check: passed

Focused command:

uv run pytest -q tests/gateway/test_runtime_footer.py tests/gateway/test_runtime_footer_usage_cache.py tests/agent/test_account_usage.py tests/test_account_usage.py

Review request

Please review this refreshed current-main branch as a replacement review target for #18188. If maintainers prefer to keep #18188 as the canonical PR, its owner can transfer or refresh that branch and close this replacement.

lancecheney and others added 7 commits August 29, 2026 22:39
Rebase the runtime footer extension onto current main: provider/account/
context/quota fields, underline support, credential-scoped quota cache,
DeepSeek balance lookup, Anthropic runtime-key preference, run.py wiring,
docs, and regression tests.
Add an opt-in `reasoning` footer field that renders the live turn effort
as a compact label (off/min/low/med/high/xhi/max/ult), wired from the
agent reasoning_config including /reasoning overrides.
Resolve footer config and quota usage inside the routed profile scope, then
pass only the resolved snapshot/config to final rendering. This avoids
cross-profile config/auth reads in multiplexed gateways and keeps raw API
credentials out of agent_result.

Replace synchronous cache misses with profile- and credential-scoped
stale-while-revalidate: cold/stale entries schedule one daemon refresh and
return immediately, transient failures preserve the last valid snapshot,
and the cache is bounded to 64 entries.
API `primary_window` is no longer always 5 h; derive the compact label
(`5h` / `7d` / `15d` / `17h` / …) from the real `limit_window_seconds`
returned by the Codex usage endpoint instead of guessing from position.

- New helper `_codex_window_label(window, fallback)` reads the field,
  converts to an integral compact label, and falls back only when the
  field is missing or unusual.
- `_fetch_codex_account_usage` labels windows through the helper.
- `_quota_label` tightens label-matching to exact-set membership so
  labels that just contain "5" or "7" (e.g. `15d`, `17h`) are not
  mis-displayed as 5h/7d.
- Removed unused provider-text variable from `_quota_label`.
@sfire123

Copy link
Copy Markdown
Author

@teknium1 @lancecheney

This is the current-main replacement review target for #18188. The original branch cannot be refreshed from sfire123 because it is owned by lancecheney.

The refreshed branch keeps the same runtime-footer/quota scope and includes the hardening from the closed fork PR #1. Focused validation is 82 passed, with ruff, py_compile, and git diff --check passing.

Please review #98180 when convenient, or let us know if you prefer the original #18188 branch to remain canonical.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles area/billing Account usage, credit usage, billing (cross-cutting) area/profiles Multi-profile isolation, HERMES_HOME scoping area/usage-cost Token accounting, usage reporting, billing, cost tracking needs-decision Awaiting maintainer decision before any implementation duplicate This issue or pull request already exists 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 labels Aug 29, 2026
@alt-glitch

Copy link
Copy Markdown

This was generated by AI during triage.

Duplicate of #18188: the current-main replacement has the same nine-file, 1,291-addition/35-deletion runtime-footer and quota-cache implementation. #18188 remains the canonical review thread.

@sfire123 sfire123 closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing Account usage, credit usage, billing (cross-cutting) area/config Config system, migrations, profiles area/profiles Multi-profile isolation, HERMES_HOME scoping 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 needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have 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