feat(session): thread agent_id through session identity & DB schema (2/6)#37496
Open
davidgut1982 wants to merge 2 commits into
Open
feat(session): thread agent_id through session identity & DB schema (2/6)#37496davidgut1982 wants to merge 2 commits into
davidgut1982 wants to merge 2 commits into
Conversation
This was referenced Jun 2, 2026
Open
24b05f5 to
7bb5da3
Compare
Introduce AgentProfile dataclass and a ContextVar (_current_agent_profile) that lets path getters (get_hermes_home, get_skills_dir, get_memory_dir) resolve to the active agent's home directory under asyncio. - agent/profile.py: AgentProfile, use_profile() context manager, load_agent_registry() from GatewayConfig - hermes_constants.py: get_hermes_home() reads ContextVar before env fallback - tests/agent/test_profile_contextvar.py: ContextVar isolation under asyncio.gather, nested contexts, registry loading Single-agent installs see zero change — no profile bound means fallback to HERMES_HOME env var as before.
Add agent_id field to SessionSource and SessionEntry, prefix session keys with agent:<id>: in build_session_key. Default "main" preserves every historical key string for single-agent installs. - gateway/session.py: SessionSource.agent_id, SessionEntry.agent_id, build_session_key prefixing - hermes_state.py: sessions table migration (agent_id TEXT DEFAULT 'main'), new idx_sessions_agent index - tests/gateway/test_session.py: build_session_key prefixing for all chat_type × agent_id combinations - tests/*/test_session_boundary_hooks.py: hook payload agent_id kwarg
7bb5da3 to
34e1e12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Thread
agent_idthrough session identity and the SQLite session schema (newagent_idcolumn + index, INSERT path, and session helpers).Why
Sessions must be attributable to a specific agent so routing, history, and per-agent behavior stay isolated when one gateway serves multiple agents.
How to test
Platforms tested
Linux (CT 133 / Proxmox LXC)
Part 2 of 6 in the multi-agent gateway decomposition (replaces #34741). Depends on: #37495
Note on conflict resolution: cherry-picking onto current
mainconflicted inhermes_state.pywheremainhad since added thefts5_available-guarded FTS5/trigram setup and acwdsession column. Resolved by keeping both — the newagent_idindex is created before the FTS block, and the INSERT column list/placeholders now carry bothagent_idandcwd(10 columns).