hermes - ✅(Solved) Fix [Feature]: Centralize SessionDB construction for future backend extension [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#20268Fetched 2026-05-06 06:37:44
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×1

Fix Action

Fix / Workaround

Keeping direct SessionDB() construction everywhere preserves current behavior, but any external storage experiment has to patch many unrelated call sites.

PR fix notes

PR #20283: feat(hermes_state): add create_session_db() factory boundary

Description (problem / solution / changelog)

Summary

Adds a centralized factory function in as the minimal first step toward centralizing construction.

Motivation

Hermes currently creates directly in several runtime paths (CLI startup/resume, web server, etc.). This works for the default SQLite implementation but makes it difficult to introduce external DB-backed session state without scattering backend-specific logic everywhere.

Changes

  • **New function ** in

    • Returns a fully initialized SQLite-backed instance
    • Accepts an optional override
    • Serves as the single construction boundary for future backend extension
  • New tests in :

    • : verifies factory returns a working with correct path and basic operations
    • : verifies factory behavior when called with default path

Why this as a first PR

This is intentionally minimal — no new backend, no new dependencies, no new user-facing config. It only makes the construction point explicit, establishing the boundary before routing existing call sites through it.

Follow-up work (also labeled ): route one or two high-value call sites through the factory to validate the pattern.

References

  • Fixes #20268

Changed files

  • hermes_state.py (modified, +16/-0)
  • tests/hermes_state/test_resolve_resume_session_id.py (modified, +26/-0)

Code Example

def create_session_db():
    from hermes_state import SessionDB
    return SessionDB()

---

self._session_db = create_session_db()
RAW_BUFFERClick to expand / collapse

Problem or Use Case

English is not my first language, so apologies if this reads a bit ChatGPT-ish. I will try to keep the request concrete.

Hermes currently creates hermes_state.SessionDB() directly in several runtime paths. That works for the default SQLite implementation, but it also means there is no single construction boundary for session-state reliability work or future backend extension.

The immediate change I am suggesting is small: centralize SessionDB construction behind one helper/provider boundary while keeping the existing SQLite SessionDB behavior unchanged.

The longer-term motivation is to make external DB-backed session state possible without scattering backend-specific logic across CLI, gateway, MCP, dashboard, cron, and plugin code paths.

Related storage/reliability issues include #5563, #2914, #8042, and #19816.

Proposed Solution

Add a small SessionDB construction boundary.

For the first PR, this could be intentionally minimal:

def create_session_db():
    from hermes_state import SessionDB
    return SessionDB()

Then route one high-value path, such as CLI startup/resume, through it:

self._session_db = create_session_db()

This first step would not add a new backend, new dependency, or new user-facing config. It would only make the construction point explicit.

If the boundary proves useful, follow-up work could discuss a provider/adapter shape for external DB-backed implementations.

Alternatives Considered

Keeping direct SessionDB() construction everywhere preserves current behavior, but any external storage experiment has to patch many unrelated call sites.

Adding a specific DB backend directly to Hermes would be a bigger product and maintenance decision. A construction boundary seems like a smaller first step.

A plugin hook may be useful later, but session state is needed early across CLI/gateway/MCP flows, so starting with a small core helper seems lower-risk.

Feature Type

Performance / reliability

Scope

Small for the first PR.

Contribution

I can submit a focused PR that only adds the construction helper, routes the CLI path through it, and tests that the default SQLite behavior is unchanged.

extent analysis

TL;DR

Create a centralized SessionDB construction boundary using a helper function to improve session-state reliability and future backend extension.

Guidance

  • Introduce a small create_session_db function to centralize SessionDB construction, as proposed in the issue.
  • Route high-value paths, such as CLI startup/resume, through the new create_session_db function to test its effectiveness.
  • Verify that the default SQLite behavior remains unchanged after implementing the construction boundary.
  • Consider follow-up work to discuss a provider/adapter shape for external DB-backed implementations if the boundary proves useful.

Example

def create_session_db():
    from hermes_state import SessionDB
    return SessionDB()

Notes

The proposed solution is intentionally minimal and does not add new dependencies or user-facing configurations, making it a low-risk first step towards improving session-state reliability.

Recommendation

Apply the proposed workaround by introducing the create_session_db helper function, as it provides a clear construction boundary for future backend extensions without altering the existing SQLite behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Feature]: Centralize SessionDB construction for future backend extension [1 pull requests, 1 participants]