Skip to content

WebUI non-default profile sessions written to default state.db (DEFAULT_DB_PATH module-level constant) #2965

@yeeyuny

Description

@yeeyuny

Bug Description

When using WebUI with a non-default profile (e.g. switching to zhangtingban via the profile dropdown), sessionsare incorrectly written to the default profile's state.db instead of the correct profile's state.db.

This means:

• In WebUI UI: sessions appear correctly under the switched profile (the _index.json metadata has the correctprofile field)
• In Hermes Agent TUI: sessions are missing from the expected profile and appear under the default profileinstead
• session_search in TUI for the target profile returns no results for WebUI-created sessions

Root Cause

In api/streaming.py line ~3556:

─ python
_session_db = SessionDB()

SessionDB() with no arguments uses the module-level constant DEFAULT_DB_PATH:

─ python

hermes_state.py line 34

DEFAULT_DB_PATH = get_hermes_home() / "state.db"

This constant is computed at import time and never changes, even though streaming.py correctly updatesos.environ['HERMES_HOME'] to the target profile home before the agent runs (lines 3201-3209). The module-levelconstant is already frozen to the default profile's path.

Fix

Pass db_path explicitly based on the already-resolved _profile_home:

─ python

streaming.py ~line 3556

_state_db_path = Path(_profile_home) / "state.db" if _profile_home else None
_session_db = SessionDB(db_path=_state_db_path)

This ensures SessionDB connects to the correct profile's state.db.

Reproduction

  1. Start WebUI with multiple profiles configured
  2. Switch to a non-default profile (e.g. zhangtingban)
  3. Create a session and send messages
  4. In TUI, switch to the same non-default profile
  5. Run session_search — the WebUI session is not found
  6. Switch TUI to default profile — the WebUI session appears there instead

Environment

• Hermes Agent: v0.14.0
• WebUI: v0.51.92
• OS: WSL2 (Ubuntu)
• Profiles: default, zhangtingban, us-stock

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