Repository navigation
fix(hindsight): re-read on-disk config when recreating the embedded client - #110804
Closed
nikkoxgonzales wants to merge 1 commit into
Closed
nikkoxgonzales wants to merge 1 commit into
nikkoxgonzales wants to merge 1 commit into
Conversation
…lient A long-running gateway loads hindsight config.json once at provider initialize() and holds it in memory. When the embedded daemon later dies (idle shutdown, crash) and a stale-connection retry recreates the client, the embedded manager re-materializes ~/.hindsight/profiles/ <p>.env from the initialize()-time snapshot — silently reverting any config.json edits made since (observed: an llm_model bump undone by a pre-restart respawn). Client creation is the daemon (re)spawn boundary, so re-read the on-disk config there. File-gated via a new _load_file_config() helper (_load_config minus the env fallback): env-only setups keep their existing config, and a respawn only adopts disk state when a config file actually exists. Session-shaping fields (banks, recall tuning) deliberately keep initialize()-time values for in-session stability. Also makes the existing idle-timeout _get_client test hermetic against a real host config (it previously relied on no config.json existing at the real HERMES_HOME), and adds a regression test covering the edit-then-respawn sequence.
Collaborator
|
Closing: the bundled Hindsight provider this PR patches has moved out of this repo. Thanks @nikkoxgonzales for this contribution. In #119888 (merge Triage notes:
If you believe this was closed in error, comment and we will reopen. (Bulk-closed in the hindsight-move close pass.) |
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 does this PR do?
Supersedes #44805 (authored by @benegessarit, cherry-picked with authorship preserved — the commit is still
Author: David Beyer <bdavey163@gmail.com>). That PR was approved by two reviewers and then closed unmerged by its author; the underlying issue #44804 remains open. This re-lands the same fix, adapted to currentmain(the client-creation code it patched has since been refactored into_new_embedded_client/_new_cloud_client, and_load_confignow dedups file reads throughread_json_or_empty).The bug: a long-running gateway loads
hindsight/config.jsononce atinitialize()and holds it inself._config. When the embedded daemon later dies (idle shutdown, crash) and a stale-connection retry recreates the client (_run_hindsight_operation→self._client = None→_get_client()), the embedded manager re-materializes~/.hindsight/profiles/<p>.envfrom the initialize()-time snapshot — silently reverting anyconfig.jsonedits made since (observed: anllm_modelbump undone by a pre-restart respawn).The fix: client creation is the daemon (re)spawn boundary, so re-read the on-disk config there. File-gated via a new
_load_file_config()helper (_load_configminus the env fallback): env-only setups keep their existing config, and a respawn only adopts disk state when a config file actually exists. Session-shaping fields (banks, recall tuning) deliberately keep initialize()-time values for in-session stability.Related Issue
Fixes #44804
Type of Change
Changes Made
plugins/memory/hindsight/__init__.py_load_file_config() -> dict | None: disk-only config read (profile-scoped$HERMES_HOME/hindsight/config.json, then legacy~/.hindsight/config.json),Nonewhen no file parses._load_config()now delegates to it before the env fallback._new_embedded_client(): re-readsconfig.jsonat client (re)creation — the daemon respawn boundary — refreshingself._configandself._llm_base_urlwhen a file exists.tests/plugins/memory/test_hindsight_provider.pytest_get_client_rereads_disk_config_at_respawn: writes a config, snapshots it as initialize()-time state, edits the file on disk, recreates the client, and asserts the newllm_model/llm_base_urlreachHindsightEmbedded.test_get_client_passes_idle_timeout_to_hindsight_embedded: made hermetic — points the config lookup at an emptytmp_pathand stubs_ensure_client_dependencyso the fakehindsightmodule stands in for the optionalhindsight-clientdep.How to Test
local_embeddedmode; start a long-running gateway soinitialize()snapshotsconfig.json.~/.hermes/hindsight/config.json(e.g. bumpllm_model) while the gateway keeps running.~/.hindsight/profiles/<p>.envreverted to the oldllm_model; after, it picks up the edit.Automated:
scripts/run_tests.sh tests/plugins/memory/test_hindsight_provider.py -q -k test_get_client→ 2 passed. Full file: 79 passed; the 7 remaining failures are pre-existing onupstream/mainin this environment (hindsight_client_apioptional dep not installed — identical failures on a cleanupstream/maincheckout).Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass — see note above: the only failures are pre-existing environment issues identical onupstream/mainrun_tests.shrunner)Documentation & 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
N/A — not a skill.
Screenshots / Logs
Credit: original fix and regression test by @benegessarit in #44805 — preserved via cherry-pick (
git logshowsAuthor: David Beyer <bdavey163@gmail.com>); conflict resolution onto currentmainand test hermeticity only.