Skip to content

feat(gateway): add opt-in tokens_in/tokens_out/effort runtime footer fields - #83553

Open
vanhci wants to merge 1 commit into
NousResearch:mainfrom
vanhci:feat/runtime-footer-tokens-effort
Open

feat(gateway): add opt-in tokens_in/tokens_out/effort runtime footer fields#83553
vanhci wants to merge 1 commit into
NousResearch:mainfrom
vanhci:feat/runtime-footer-tokens-effort

Conversation

@vanhci

@vanhci vanhci commented Aug 11, 2026

Copy link
Copy Markdown

What does this PR do?

Extends the gateway runtime footer (display.runtime_footer.fields) with three opt-in metadata fields: tokens_in, tokens_out, and effort. Also improves context_pct rendering and gives Feishu a card-style footer.

Related Issue

This PR complements those: it exposes tokens/effort as opt-in footer fields (not auto-appended), and is the only one covering per-platform card rendering for Feishu.

Type of Change

  • ✨ New feature (non-breaking change that adds functionality)

Changes Made

  • gateway/runtime_footer.py:
    • _fmt_tokens(n) — compact token formatting (15932 -> 15.9k, 28 -> 28)
    • format_runtime_footer / build_footer_line accept tokens_in, tokens_out, effort; new field branches render in 15.9k, out 1.2k, effort:high
    • context_pct now renders as ctx 12% (cc-connect style)
  • gateway/run.py:
    • passes tokens_in (last_prompt_tokens), tokens_out (output_tokens), effort (agent.reasoning_effort) into the footer builder
    • Feishu renders the footer as a divider + quote block (--- + > ) so it reads as a metadata card instead of inline text

How to Test

  1. Set display.runtime_footer.enabled: true and fields: [model, context_pct, tokens_in, tokens_out, effort] in config
  2. Restart the gateway and send any message
  3. Footer renders like: deepseek-v4-flash · ctx 12% · in 15.9k · out 1.2k · effort:high
  4. On Feishu it appears as a card-style quote block; other platforms keep the inline format

Checklist

Code

  • I have read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs — see Related Issue section
  • My PR contains only changes related to this feature
  • I have run pytest tests/ -q and all tests pass — full suite blocked by local env (Python 3.9 vs 3.11 requirement); footer logic verified directly via unit invocation
  • I have added tests for my changes — verified via direct unit calls
  • I have tested on my platform: macOS

Documentation & Housekeeping

  • I have updated docstrings in gateway/runtime_footer.py
  • Updated cli-config.yaml.example — N/A (no new config keys; reuses existing runtime_footer fields)
  • Updated CONTRIBUTING.md/AGENTS.md — N/A
  • Considered cross-platform impact — pure Python, no platform-specific code

…fields

Extend display.runtime_footer with token-count and reasoning-effort fields:
- tokens_in / tokens_out: compact k-formatted (15.9k) per-turn token usage
- effort: agent reasoning effort label from agent.reasoning_effort
- context_pct now renders as 'ctx N%' (aligns with cc-connect style)
- Feishu renders the footer as a card-style quote block (divider + '> ')
  instead of plain inline text

All new fields are opt-in: the default field set is unchanged.
Related: NousResearch#19922, NousResearch#17592, NousResearch#64526, NousResearch#28978
daltino

This comment was marked as resolved.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter area/config Config system, migrations, profiles sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 11, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference, author can ignore or act on any point.

feat(gateway): add opt-in tokens_in/tokens_out/effort runtime footer fields

  1. gateway/run.pyeffort=(_load_gateway_config().get("agent") or {}).get("reasoning_effort") is evaluated eagerly on every turn, including when the runtime footer is disabled, because it is an argument to build_footer_line(...) which is called unconditionally inside the try. That is a full config YAML re-parse per message just to compute a usually-unused argument. Consider reading the config only when the footer feature is enabled, or caching the resolved reasoning_effort value.
  2. gateway/runtime_footer.py — the context_pct field now renders as ctx 42% instead of 42%. This changes the output of an existing, already-enabled field — not just the new opt-in fields — so users who configured context_pct get a different footer after upgrade. If the prefix is intended, a release-note mention would help; otherwise keep the old rendering for context_pct and add prefixes only for the new fields.
  3. gateway/run.py — the Feishu-specific card formatting (---\n> {_footer_line}) is hardcoded in the core gateway loop. Platform-specific rendering usually lives in the platform adapter; consider passing the plain footer line and letting the Feishu adapter wrap it, so other card-style platforms can reuse the pattern without editing core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter 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.

4 participants