Repository navigation
Add Hermes model usage to the Agents panel - #13505
sccashma-hermes wants to merge 2 commits into
Conversation
Automated AI review
Outcome: The Hermes daily token chart shows prompt counts. Daily token series holds prompt counts
Suggested change: Sum the four token columns per Reproducer (fails at 5689583)Save as #!/bin/bash
# Reproducer for PR #13505: the Agents panel draws recentDays[].messageCount
# as "TOKENS BY DAY" (Panel.qml dayTooltip/DayRow; the claude, codex and
# fireworks collectors all put token totals there). With one session today
# that used 104 tokens, today's bar should read 104, not the prompt count.
source "$(dirname "$0")/base-test.sh"
require_command jq
require_command python3
TEST_HOME=$(mktemp -d)
trap 'rm -rf "$TEST_HOME"' EXIT
mkdir -p "$TEST_HOME/.hermes"
HOME="$TEST_HOME" python3 - <<'PY'
import os
import sqlite3
import time
from pathlib import Path
path = Path(os.environ["HOME"]) / ".hermes" / "state.db"
conn = sqlite3.connect(path)
conn.executescript(
"""
CREATE TABLE sessions (id TEXT PRIMARY KEY, started_at REAL NOT NULL);
CREATE TABLE messages (id INTEGER PRIMARY KEY, session_id TEXT NOT NULL, role TEXT NOT NULL, timestamp REAL NOT NULL);
CREATE TABLE session_model_usage (
session_id TEXT NOT NULL, model TEXT NOT NULL,
input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0,
cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_write_tokens INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (session_id, model)
);
"""
)
now = time.time()
conn.execute("INSERT INTO sessions VALUES (?, ?)", ("session-1", now))
conn.executemany(
"INSERT INTO messages VALUES (?, ?, ?, ?)",
[(1, "session-1", "user", now), (2, "session-1", "assistant", now)],
)
conn.execute("INSERT INTO session_model_usage VALUES (?, ?, ?, ?, ?, ?)", ("session-1", "gpt-6-sol", 11, 21, 31, 41))
conn.commit()
conn.close()
PY
record=$(HOME="$TEST_HOME" "$ROOT/bin/omarchy-agent-usage-hermes") ||
fail "Hermes collector exits successfully"
pass "Hermes collector exits successfully"
printf '%s\n' "$record" | jq -e '.recentDays[-1].messageCount == .todayTotalTokens' >/dev/null ||
fail "Hermes collector puts today's tokens in the tokens-by-day series" \
"$(printf '%s\n' "$record" | jq -c '{today: .recentDays[-1], todayTotalTokens, todayPrompts}')"
pass "Hermes collector puts today's tokens in the tokens-by-day series"Actual output at the PR head (5689583), stdout then stderr:
|
|
Thank you! Brought in with your authorship in #14039, adapted to read |
Summary
Hermes Agent sessions currently do not appear in Omarchy's Agents usage panel, so Hermes users only see usage from other collectors such as Codex. This adds a Hermes collector that exposes the existing local session totals and preserves each model's token usage, including models such as
gpt-6-sol.Changes
bin/omarchy-agent-usage-hermes, using read-only access to~/.hermes/state.db.--writeoutput for manual or timer-driven refreshes.Validation
python3 -m py_compile bin/omarchy-agent-usage-hermes./test/shell.d/agent-usage-hermes-test.sh./test/shell.d/agent-usage-update-test.sh./test/shell.d/agent-usage-fireworks-scanner-test.sh./test/shellThe focused tests pass. The full shell suite reached a pre-existing
passwordless-grant-lifecycle-test.shfailure (set OMARCHY_PKGS_PATH to the companion package checkout) and then timed out during later tests.Related: #9871