fix: boot-time patch for Hermes ACP session restore with stale provider#27
Merged
Merged
Conversation
Adds a custom-cont-init.d script that patches the installed Hermes agent's https://github.com/NousResearch/hermes-agent/blob/v2026.6.5/acp_adapter/session.py to retry session restoration with the current config's provider when the stored provider fails to resolve. When the VS Code extension reloads, it tries to restore the previous ACP session. If that session used a provider no longer in the current config (e.g. 'custom' after switching to 'omniroute'), the runtime resolution returns an empty api_key and init_agent raises 'No LLM provider configured'. The fallback in this script makes _restore retry without the stale requested_provider, so old sessions gracefully fall back to the live endpoint instead of blocking all new prompts.
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.
Summary
When the VS Code extension reloads, it tries to restore the previous ACP session. If that session used a provider no longer in the current config (e.g.
"custom"after switching to"omniroute"), the runtime resolution returns an emptyapi_keyandinit_agentraises"No LLM provider configured". The session restore fails silently, and the extension never gets a response to new prompts.This PR adds a boot-time cont-init script that patches the installed Hermes agent to retry session restoration with the current config provider when the stored provider fails.
What Changed
New file:
docker/hermes-acp-patch.shA cont-init.d script that:
_restore()except block in the installed Hermessession.pyThe patch targets the installed Hermes at
/usr/local/lib/hermes-agent/acp_adapter/session.py, which is placed there by thescripts/install.shduring Docker build.How It Works
Original behavior (broken):
Patched behavior:
Root Cause
The runtime provider resolver
resolve_runtime_provider(requested="custom")returns an emptyapi_keywhen:custom_providers.customentry exists in configlocalhostdoes not match known provider host patterns for env-var key resolutionThis causes
init_agentatagent/agent_init.py:736to skip the explicit-credentials path (if api_key and base_url:→api_key=""is falsy), fall through to the router, which returns None, and raise"No LLM provider configured".Testing
Durability
The patch is a cont-init.d script so it survives container rebuilds. If Hermes is upgraded (the
scripts/install.shinstalls a new version), the Python string match will fail gracefully with"patch site not found -- Hermes may have been updated"and a non-zero exit code. No silent corruption — just a log entry that the patch needs regeneration.