Skip to content

fix(gateway): show context window and reasoning in /status - #64859

Open
bcarrillo11 wants to merge 1 commit into
NousResearch:mainfrom
bcarrillo11:fix/status-context-reasoning
Open

fix(gateway): show context window and reasoning in /status#64859
bcarrillo11 wants to merge 1 commit into
NousResearch:mainfrom
bcarrillo11:fix/status-context-reasoning

Conversation

@bcarrillo11

Copy link
Copy Markdown

What does this PR do?

Improves the gateway /status response in two related ways:

  • shows the effective reasoning effort for the current session, honoring the live/cached agent configuration and session overrides;
  • resolves the model context window from model metadata when neither the resident agent nor model.context_length provides it.

The metadata fallback is bounded to 3 seconds, handles lookup failures, validates that the result is a positive non-boolean integer, and gracefully falls back to the existing used-context-only line.

Example:

Model: gpt-5.6-sol (openai-codex)
Reasoning: high
Context: 46,737 / 272,000 (17%)

Why?

For gateway sessions without a resident agent and without an explicit model.context_length, /status showed only the used token estimate even though Hermes can resolve the model's full context window through its metadata catalog. The command also did not expose the session's effective reasoning level, making session overrides hard to inspect.

Related work

Type of change

  • Bug fix / robustness improvement
  • Non-breaking gateway status enhancement

Changes

  • gateway/slash_commands.py
    • resolve missing context totals with get_model_context_length_async();
    • bound the lookup with asyncio.wait_for() and degrade safely;
    • render the effective session reasoning configuration.
  • locales/*.yaml
    • add gateway.status.reasoning for all 16 catalogs.
  • tests/gateway/test_status_command.py
    • cover reasoning display, successful metadata fallback, exception, timeout, and invalid metadata values.

Verification

  • tests/gateway/test_status_command.py: 23 passed
  • tests/agent/test_i18n.py: 47 passed
  • Combined focused suite: 70 passed
  • 16 locale catalogs parsed successfully
  • git diff --check
  • Python compile check
  • Added-line security scan: clean
  • Independent review: no blocking findings

Checklist

  • I read the contributing guide
  • I searched open issues and PRs for duplicates/overlap
  • The PR contains only related changes
  • Tests cover the new behavior and failure modes
  • Tested on Linux with a live Telegram gateway

Resolve missing context totals from bounded model metadata lookups and display the effective session reasoning level. Add localized labels and regression coverage for success, timeout, failure, and invalid metadata paths.
@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have labels Jul 15, 2026

@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 focused gateway status improvement. Current main still lacks both the metadata fallback and reasoning display (gateway/slash_commands.py:602-606, 638-641).

Problems

  • gateway/slash_commands.py:664-667 resolves reasoning without model=model_name. The shared resolver intentionally derives an omitted model from config.model.default before applying agent.reasoning_overrides (hermes_constants.py:970-995). Thus an inactive session whose effective/persisted model differs from the global default can display the wrong effort.

Suggested changes

  • Pass model=model_name to _resolve_session_reasoning_config.
  • Add a no-resident-agent regression test where the status model differs from config.model.default and each has a distinct per-model reasoning override.

The target files have not changed between the PR base and current main's parent; this is a focused salvage with a small correction. Automated hermes-sweeper review.

Comment thread gateway/slash_commands.py
if reasoning_config is None:
reasoning_config = self._resolve_session_reasoning_config(
source=source,
session_key=session_key,

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.

Pass model=model_name here. Without it, the shared resolver falls back to config.model.default before applying per-model overrides, so an inactive session on a different effective model can report the wrong reasoning effort.

@teknium1 teknium1 added 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 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants