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
- Start WebUI with multiple profiles configured
- Switch to a non-default profile (e.g. zhangtingban)
- Create a session and send messages
- In TUI, switch to the same non-default profile
- Run session_search — the WebUI session is not found
- 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
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
Environment
• Hermes Agent: v0.14.0
• WebUI: v0.51.92
• OS: WSL2 (Ubuntu)
• Profiles: default, zhangtingban, us-stock