fix: gate retrieval-utility logging behind enabled config flag (#1480) - #1500
Merged
Conversation
The memory.retrieval_utility.enabled config flag defaults to False (opt-in), but _record_retrieval_utility and _record_retrieval_outcomes in MemoryManager ran unconditionally — writing a per-retrieval record to disk on every memory hit in every session despite the user never opting in. This adds a _retrieval_utility_enabled() check that reads the config flag via load_config_readonly() and gates both methods. When disabled (the default), no sidecar file is written and no pending retrievals accumulate. Identified in PR #1483 code review. Issue #1480 was closed as completed but the privacy gate fix was never landed — PR #1485 is stuck in a conflicting state. This is the minimal standalone fix. Co-Authored-By: Hermes Evolution <evolution@hermes.ai>
3 tasks
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
The
memory.retrieval_utility.enabledconfig flag defaults toFalse(opt-in), but_record_retrieval_utilityand_record_retrieval_outcomesinMemoryManagerran unconditionally — writing a per-retrieval record to disk on every memory hit in every session despite the user never opting in.This was identified in the PR #1483 code review but never fixed. PR #1485 attempted to fix it but is stuck in a conflicting/dirty state (834 additions, mergeable_state=dirty). This PR is the minimal standalone fix.
Changes
agent/memory_manager.py: Added_retrieval_utility_enabled()static method that readsmemory.retrieval_utility.enabledviaload_config_readonly(). Both_record_retrieval_utilityand_record_retrieval_outcomesnow early-return when the flag isFalse. When disabled,_pending_retrievalsis also cleared to prevent stale accumulation.tests/agent/test_memory_retrieval_utility.py: Existing test classes now mock_retrieval_utility_enabledtoTrue(autouse fixture) so the logging path is still exercised. AddedTestRetrievalUtilityGatewith 3 new tests verifying the disabled path: no sidecar written, no pending retrievals accumulated, sync does not record outcomes.Verification
ruff check✓ (both files)pytest tests/agent/test_memory_retrieval_utility.py✓ (10/10 passed)Design
The fix reads config lazily at call time via
load_config_readonly()rather than passing a config reference into theMemoryManagerconstructor — this avoids changing the constructor signature (which would ripple through all callers inrun_agent.py,cli.py, gateway, etc.). Thetry/exceptwrapper ensures a missing or corrupt config never breaks memory operations.