Fix code review issues and improve code quality #1

Merged
Pakobbix merged 3 commits from fixes/code-review-issues into main 2026-04-10 11:53:10 +00:00
Owner

This PR addresses all code review findings for the mem0-local-hermes-plugin.

Bug Fixes

  • Missing agent_id in sync_turn(): Added agent_id parameter to client.add() and used it in both mem0_conclude and sync_turn() for consistent memory scoping
  • Inconsistent field access: Fixed queue_prefetch_and_get() to check both text and memory fields (matching queue_prefetch())

Refactoring

  • Thread safety: Added dedicated _breaker_lock for thread-safe circuit breaker state access
  • DRY principle: Extracted _format_search_results() helper to eliminate duplicate search result formatting code
  • Cleanup: Removed unused _read_filters() and _write_filters() methods
  • Documentation: Documented unused session_id and query parameters for API compatibility

Testing

All fixes have been manually verified. The plugin continues to work correctly with:

  • Installing
  • Four tools (mem0_profile, mem0_search, mem0_conclude, mem0_delete)
  • pre-llm-hook
This PR addresses all code review findings for the mem0-local-hermes-plugin. ## Bug Fixes - **Missing agent_id in sync_turn()**: Added `agent_id` parameter to `client.add()` and used it in both `mem0_conclude` and `sync_turn()` for consistent memory scoping - **Inconsistent field access**: Fixed `queue_prefetch_and_get()` to check both `text` and `memory` fields (matching `queue_prefetch()`) ## Refactoring - **Thread safety**: Added dedicated `_breaker_lock` for thread-safe circuit breaker state access - **DRY principle**: Extracted `_format_search_results()` helper to eliminate duplicate search result formatting code - **Cleanup**: Removed unused `_read_filters()` and `_write_filters()` methods - **Documentation**: Documented unused `session_id` and `query` parameters for API compatibility ## Testing All fixes have been manually verified. The plugin continues to work correctly with: - Installing - Four tools (mem0_profile, mem0_search, mem0_conclude, mem0_delete) - pre-llm-hook
ARIA added 3 commits 2026-04-10 11:50:34 +00:00
- Add agent_id parameter to client.add() and use it in mem0_conclude
- Fix inconsistent field access in queue_prefetch_and_get (check both text and memory)
- Remove unused _read_filters() and _write_filters() methods
- Mark prefetch() query parameter as deprecated (was unused)
The sync_turn() method was not passing agent_id to client.add(),
causing inconsistent memory scoping compared to mem0_conclude.
- Add dedicated _breaker_lock for thread-safe circuit breaker state access
- Extract _format_search_results() helper to eliminate DRY violation
- Document unused session_id parameters for API compatibility
Collaborator

No issues found — changes look consistent with the stated intent.

The diff correctly implements all the described fixes:

  • Thread Safety: The _breaker_lock is correctly initialized and used via with statements in _is_breaker_open, _record_success, and _record_failure.
  • DRY Principle: The new _format_search_results helper correctly consolidates the duplicate logic for formatting search results (checking both text and memory fields) used in prefetch and queue_prefetch.
  • Bug Fixes: The agent_id parameter is correctly added to client.add() calls in sync_turn and mem0_conclude, and the LocalMem0Client.add method is updated to accept and payload this parameter.
  • Cleanup: The unused _read_filters and _write_filters methods are removed.
  • Documentation: Docstrings are updated to reflect parameter usage and compatibility notes.

No syntax errors, typos, or logic bugs were detected in the added lines.

✅ No issues found — changes look consistent with the stated intent. The diff correctly implements all the described fixes: * **Thread Safety**: The `_breaker_lock` is correctly initialized and used via `with` statements in `_is_breaker_open`, `_record_success`, and `_record_failure`. * **DRY Principle**: The new `_format_search_results` helper correctly consolidates the duplicate logic for formatting search results (checking both `text` and `memory` fields) used in `prefetch` and `queue_prefetch`. * **Bug Fixes**: The `agent_id` parameter is correctly added to `client.add()` calls in `sync_turn` and `mem0_conclude`, and the `LocalMem0Client.add` method is updated to accept and payload this parameter. * **Cleanup**: The unused `_read_filters` and `_write_filters` methods are removed. * **Documentation**: Docstrings are updated to reflect parameter usage and compatibility notes. No syntax errors, typos, or logic bugs were detected in the added lines.
Pakobbix merged commit bb5c5ce396 into main 2026-04-10 11:53:10 +00:00
Pakobbix deleted branch fixes/code-review-issues 2026-04-10 11:53:10 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ARIA/mem0-local-hermes-plugin#1