feat(gateway): Add gateway startup auto-resume from recent session history#9328
Open
Jiawen-lee wants to merge 1 commit into
Open
feat(gateway): Add gateway startup auto-resume from recent session history#9328Jiawen-lee wants to merge 1 commit into
Jiawen-lee wants to merge 1 commit into
Conversation
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.
…story
What does this PR do?
This PR adds startup session recovery for the messaging gateway so Hermes can resume recent conversational context after a restart.
Today, if the gateway restarts and a new session is created, the agent starts fresh even though recent context still exists in
state.db. This breaks continuity and forces the user to restate context. This PR fixes that by loading the most recent resumable non-infrastructure session fromstate.db, extracting the last N user/assistant turns, and seeding that history into the first truly new empty gateway session after startup.I implemented this by rewriting the new session transcript once at startup recovery time instead of using
prefill_messages. That approach fits the existingload_transcript() -> conversation_historyflow and avoids re-injecting the same history on every API call.Related Issue
Fixes #9286
Type of Change
Changes Made
hermes_state.pyto:gateway/config.pyfor:gateway.auto_resume_last_sessiongateway.auto_resume_message_limithermes_cli/config.pygateway/run.pytests/gateway/test_startup_resume.pytests/test_hermes_state.pyHow to Test
~/.hermes/config.yaml:Start the gateway, send a few messages on a messaging platform, then stop and restart the gateway.
Send a message that creates a new session and confirm Hermes still has the recent prior context.
Confirm recovery only happens once and does not keep injecting old history into later fresh sessions.
Run targeted tests:
source venv/bin/activate python -m pytest tests/test_hermes_state.py tests/gateway/test_startup_resume.py tests/gateway/test_status_command.py -qChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs