Last one today, I promise. I noticed that my token use in WebUI was not showing up in Hermes /insights. I asked Hermes. See attached for details.
webui-state-db-integration.md
The WebUI stores all its token usage data in per-session JSON files, but /insights reads exclusively from ~/.hermes/state.db (SQLite). The gateway layer (used by CLI, Telegram, and cron) writes to state.db automatically. The WebUI bypasses the gateway entirely, calling AIAgent.run_conversation() directly. So WebUI sessions simply don't exist in state.db.
What that means in practice:
/insights shows zero WebUI data -- no token counts, no costs, no model breakdown, no activity patterns from any browser session you've ever run
hermes sessions list from the CLI also misses WebUI sessions -- same reason
The fix the document proposes:
A thin bridge module (api/state_sync.py) that mirrors WebUI session metadata into state.db at two points -- when a session starts (register it) and after each turn completes (update tokens + title). All wrapped in try/except so the WebUI keeps working fine if state.db is unavailable. Uses absolute=True on token updates because the WebUI Session object already accumulates totals (avoiding double-counting).
In short: it closes a data gap so that all Hermes usage stats are complete regardless of which interface you used.
Last one today, I promise. I noticed that my token use in WebUI was not showing up in Hermes /insights. I asked Hermes. See attached for details.
webui-state-db-integration.md
The WebUI stores all its token usage data in per-session JSON files, but
/insightsreads exclusively from~/.hermes/state.db(SQLite). The gateway layer (used by CLI, Telegram, and cron) writes to state.db automatically. The WebUI bypasses the gateway entirely, callingAIAgent.run_conversation()directly. So WebUI sessions simply don't exist in state.db.What that means in practice:
/insightsshows zero WebUI data -- no token counts, no costs, no model breakdown, no activity patterns from any browser session you've ever runhermes sessions listfrom the CLI also misses WebUI sessions -- same reasonThe fix the document proposes:
A thin bridge module (
api/state_sync.py) that mirrors WebUI session metadata into state.db at two points -- when a session starts (register it) and after each turn completes (update tokens + title). All wrapped in try/except so the WebUI keeps working fine if state.db is unavailable. Usesabsolute=Trueon token updates because the WebUI Session object already accumulates totals (avoiding double-counting).In short: it closes a data gap so that all Hermes usage stats are complete regardless of which interface you used.