Skip to content

feat(status): show model, context usage, and cumulative label in /status#4678

Open
WolframRavenwolf wants to merge 1 commit into
NousResearch:mainfrom
WolframRavenwolf:feat/status-model-context
Open

feat(status): show model, context usage, and cumulative label in /status#4678
WolframRavenwolf wants to merge 1 commit into
NousResearch:mainfrom
WolframRavenwolf:feat/status-model-context

Conversation

@WolframRavenwolf
Copy link
Copy Markdown

Summary

Enhances the /status slash command in the gateway to display:

  • Model: name and provider (e.g., "claude-opus-4-20250514 (anthropic)")
  • Context: approximate token usage vs limit with percentage (e.g., "~45,000 / 200,000 (23%)")
  • Tokens: now labeled "(cumulative)" for clarity

Motivation

Users had no way to see which model was active or how much context was consumed without checking config files or logs. This information is critical for understanding agent behavior and knowing when context compression might kick in.

Changes

gateway/run.py: Enhanced _handle_status_command with:

  • Live agent path: reads model, provider, context usage from the running agent instance and its context_compressor
  • Idle fallback: resolves model from config via _resolve_gateway_model(), context from session entry + DEFAULT_CONTEXT_LENGTHS fuzzy lookup
  • Correct sentinel check (agent is not _AGENT_PENDING_SENTINEL) — pending agents now correctly report as "not running", consistent with _handle_stop_command
  • Zero-context handling: context line shows even when context_used=0 (e.g., after /new) — only context_total is checked, avoiding the Python falsy-zero pitfall

Example Output

📊 Hermes Gateway Status

Session ID: a1b2c3d4e5f6...
Created: 2026-03-31 14:30
Last Activity: 2026-03-31 15:45
Model: claude-opus-4-20250514 (anthropic)
Context: ~45,231 / 200,000 (23%)
Tokens: 125,432 (cumulative)
Agent Running: Yes ⚡

Connected Platforms: telegram, discord, whatsapp

Design Decisions

  • No new config options — this is purely additive information display
  • Graceful degradation — if model isn't in DEFAULT_CONTEXT_LENGTHS, context line is simply omitted rather than showing incorrect data
  • Consistent patterns — reuses existing _load_gateway_config() and _resolve_gateway_model() for the idle path, same as /model and agent spawn
  • Minimal diff — single file, ~57 lines added, focused change

Test Plan

  • Model line appears when agent is running (reads from agent.model and agent.provider)
  • Context line shows "~0 / 200,000 (0%)" after /new (zero-context edge case)
  • Graceful degradation when model not in DEFAULT_CONTEXT_LENGTHS
  • Idle fallback resolves model from config and context from session entry
  • Pending agents (sentinel) correctly report "Agent Running: No"

Add Model line (from live agent or config fallback), Context line showing
approximate current context usage vs model limit with percentage, and
mark cumulative token count explicitly as '(cumulative)'.

Context tokens come from the agent's last_prompt_tokens (live) or
session_entry.last_prompt_tokens (idle). Context limit resolves from
the agent's context_compressor or DEFAULT_CONTEXT_LENGTHS lookup.

Inspired by OpenClaw's status format but kept simple and pragmatic.
malaiwah pushed a commit to malaiwah/hermes-agent that referenced this pull request Apr 12, 2026
Replace the basic /status output with a comprehensive session snapshot
showing model, provider, token breakdown (input/output/cache/reasoning),
cost, context window usage with idle fallback, compression count,
queue depth, and platform categorization.

- Extract shared formatting helpers to hermes_cli/status_format.py
- Add SessionDB.get_session_token_totals() — fixes Tokens: 0 (NousResearch#5960)
- Add SessionDB.get_session_last_active() for relative timestamps
- Idle context fallback via get_model_context_length (inspired by NousResearch#4678)
- 42 unit tests covering all code paths

Closes NousResearch#7317, closes NousResearch#7714, supersedes NousResearch#4678 and NousResearch#5989.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@malaiwah
Copy link
Copy Markdown
Contributor

Nice work on the idle context fallback — PR #8355 incorporates the same idea (using get_model_context_length() when no live agent exists) as part of a broader /status overhaul that also adds token breakdown, cost, cache stats, compression tracking, and CLI support. Credit to @WolframRavenwolf for the approach.

malaiwah pushed a commit to malaiwah/hermes-agent that referenced this pull request Apr 12, 2026
Replace the basic /status output with a comprehensive session snapshot
showing model, provider, token breakdown, cost, context window, and more.

- Extract shared formatting helpers to hermes_cli/status_format.py
- Add SessionDB.get_session_token_totals() — fixes Tokens: 0 (NousResearch#5960)
- Add SessionDB.get_session_last_active() for relative timestamps
- Idle context fallback via get_model_context_length (inspired by NousResearch#4678)
- Persist compression_count in SessionEntry so idle sessions show
  compression history (NousResearch#7317)
- 42 unit tests covering all code paths

Closes NousResearch#7317, closes NousResearch#7714, supersedes NousResearch#4678 and NousResearch#5989.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
malaiwah pushed a commit to malaiwah/hermes-agent that referenced this pull request Apr 13, 2026
When no live agent is running, estimate the context window limit from
model metadata (get_model_context_length) and show last_prompt_tokens
as current usage. Inspired by upstream PR NousResearch#4678.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery labels May 1, 2026
@alt-glitch
Copy link
Copy Markdown
Collaborator

Related to #16079 (also adds model/provider info to /status) — these likely overlap significantly.

@alt-glitch
Copy link
Copy Markdown
Collaborator

Related to #16079

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants