Skip to content

WebUI sessions are invisible to /insights #92

@kingfish65

Description

@kingfish65

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:

  1. /insights shows zero WebUI data -- no token counts, no costs, no model breakdown, no activity patterns from any browser session you've ever run
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions