Skip to content

feat(status): rich /status snapshots across CLI and gateway#8355

Open
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:feat/rich-status-snapshots
Open

feat(status): rich /status snapshots across CLI and gateway#8355
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:feat/rich-status-snapshots

Conversation

@malaiwah

@malaiwah malaiwah commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the basic /status output with a comprehensive session snapshot showing model, provider, token breakdown, cost, context window, and more.

  • Token breakdown: input/output/cache read/cache write/reasoning with totals
  • Cost display: estimated or actual cost with human-readable labels
  • Context window: live usage from context_compressor when agent is running; idle fallback via get_model_context_length when agent is idle (inspired by feat(status): show model, provider, context, and cumulative tokens #4678)
  • Cache hit rate: percentage of cache reads vs total input
  • Compression tracking: compaction count from live agent OR persisted compression_count for idle sessions — idle sessions now show compression history instead of omitting it
  • Platform categorization: separates chat platforms from services (API, webhook)
  • Queue depth: pending messages and follow-up items
  • Model override awareness: shows session-level model overrides
  • Transport mode: webhook vs polling for Telegram

Fixes #5960 (Tokens: 0 regression — reads from SessionDB instead of stale SessionStore).
Closes #7317 (context/compression state in gateway-visible status).
Closes #7714 (usage display like OpenClaw).
Supersedes #4678 (model + context in /status — this PR is a strict superset).
Supersedes #5989 (get_session_token_totals — included here plus much more).

Changes

File Action
hermes_cli/status_format.py New — 6 shared formatting helpers (no duplication between CLI and gateway)
hermes_state.py Edit — add get_session_token_totals() and get_session_last_active()
gateway/run.py Edit — add _build_status_snapshot(), _get_status_platform_sections(), _get_status_queue_depth(); replace _handle_status_command(); persist compression_count after each turn
gateway/session.py Edit — add compression_count field to SessionEntry, wire through to_dict/from_dict/update_session
run_agent.py Edit — return compression_count from run_conversation() result dict
cli.py Edit — add _build_cli_status_snapshot(), _get_cli_status_queue_depth(); replace _show_session_status()
tests/hermes_cli/test_status_format.py New — 27 unit tests for shared helpers
tests/gateway/test_status_command.py Rewrite — 13 tests covering live agent, idle fallback with persisted compression, model override, platform split, queue depth
tests/cli/test_cli_status_command.py Rewrite — 3 tests covering live agent, persisted session fallback, pending title

Example output

Gateway (Telegram/Discord) — live agent:

⚕ Hermes Agent v0.8.0
Model: `anthropic/claude-sonnet-4` · Provider: anthropic
Usage: 25,000 in · 610 out · 50,730 total · Cost: $0.1234 est.
Cache: 25,000 read · 0 write · 50% hit · 120 reasoning
Context: 28,000 / 200,000 (14%) · Compactions: 1
Session: `agent:main:telegram:dm:12345` · updated 3m ago
ID: `20260412_104559_e1760b66`
Runtime: Chat Completions · Reasoning high · Transport webhook
Queue: depth 0 · State: running
Chats: telegram, discord

Gateway — idle session (compression history persisted):

⚕ Hermes Agent v0.8.0
Model: `openai/gpt-4o` · Provider: openai
Usage: 100 in · 200 out · 3,210 total · Cost: $1.2345 est.
Cache: 10 read · 5 write · 9% hit
Context: 45,000 / 200,000 (22%) · Compactions: 3
Session: `agent:main:telegram:dm:12345` · updated 7m ago
ID: `20260412_104559_e1760b66`
Runtime: Reasoning medium
Queue: depth 0 · State: idle
Chats: telegram

Design decisions

  • Shared helpers, not duplicated methods: hermes_cli/status_format.py holds all formatting logic. Both CLI and gateway import from it.
  • Graceful degradation: Every data source is wrapped in try/except with safe defaults. Missing SessionDB, missing agent, missing cache — all handled.
  • Idle context + compression fallback: When no live agent exists, uses get_model_context_length() + session_entry.last_prompt_tokens for context, and session_entry.compression_count for compaction history. Both are persisted via update_session() after each turn.
  • Backward-compatible persistence: compression_count defaults to 0 in SessionEntry.from_dict(), so existing sessions.json files load cleanly.
  • Backward-compatible attributes: Uses getattr() with defaults for optional runner attributes (_pending_hidden_turns, _agent_cache, etc.).

Test plan

  • pytest tests/cli/test_cli_status_command.py tests/gateway/test_status_command.py tests/hermes_cli/test_status_format.py — 42 tests pass
  • Live-tested on downstream fork with 59 regression tests passing
  • Idle compression count verified via test with compression_count=3 on SessionEntry

🤖 Generated with Claude Code

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 malaiwah force-pushed the feat/rich-status-snapshots branch from fb700c4 to 8636758 Compare April 12, 2026 12:50
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

2 participants