fix(hindsight): correct client constructor, add configurable base_url, and fix sequential tool dispatch#4762
Conversation
…able base_url The Hindsight cloud-mode client was broken: _make_client() passed api_key as the first positional argument to Hindsight(), but the constructor expects base_url first. This meant the plugin never worked in cloud mode. Additionally, add support for self-hosted Hindsight instances by: - Reading api_url from config.json (HINDSIGHT_API_URL env var) - Adding api_url to get_config_schema() for hermes setup wizard - Falling back to _DEFAULT_API_URL when no custom URL is set - Increasing timeout from 30s to 120s (Hindsight extraction can be slow)
Memory provider tools (e.g. hindsight_retain/recall/reflect) were only dispatched in the concurrent path (_invoke_tool) but not in the sequential path (_execute_tool_calls_sequential). All sequential calls fell through to handle_function_call() which returned 'Unknown tool'. Add the same memory_manager.has_tool() guard in the sequential path, matching the pattern used in the concurrent path.
Code ReviewFix 1: Hindsight Client ConstructorThe fix correctly addresses the broken cloud mode. The constructor was passing api_key as the first positional argument when Hindsight expects base_url first. Changes look good:
Note: The diff references _DEFAULT_API_URL but I dont see it defined in the repository. Please verify this constant exists or should be defined. Fix 2: Sequential Tool DispatchThe fix correctly adds memory tool handling to the sequential path. The memory tools were only being dispatched in the concurrent path, causing them to return Unknown tool in sequential mode. Changes look good:
Note: Please verify that has_tool() and handle_tool_call() methods exist on the memory manager interface. I could not find these methods in the current codebase - they may need to be added or may already exist in a different location. OverallBoth fixes address real bugs that would prevent the Hindsight memory plugin from working properly. The changes are minimal and focused. Approve pending verification of _DEFAULT_API_URL constant and memory manager methods. |
This constant already exists on # plugins/memory/hindsight/__init__.py:32
_DEFAULT_API_URL = "https://api.hindsight.vectorize.io"The diff context was likely truncated by GitHub since the file is large. You can verify directly on gh api 'repos/NousResearch/hermes-agent/contents/plugins/memory/hindsight/__init__.py?ref=main' -q '.content' | base64 -d | grep -n '_DEFAULT_API_URL'
# Output: 32:_DEFAULT_API_URL = "https://api.hindsight.vectorize.io"
Both methods already exist on
You can verify: gh api 'repos/NousResearch/hermes-agent/contents/agent/memory_manager.py?ref=main' -q '.content' | base64 -d | grep -n 'def has_tool\|def handle_tool_call'
# Output:
# 207: def has_tool(self, tool_name: str) -> bool:
# 211: def handle_tool_call(Both notes are false positives — the referenced code is part of the existing codebase, not introduced by this PR. |
Code Review ✅Summary: Two related fixes for the Hindsight memory plugin - both look correct. Fix 1: Client constructor arguments
Fix 2: Sequential tool dispatch
Quality Notes
LGTM - ship it! 🚀 |
Code ReviewFix 1: Hindsight Client Constructor ✅The fix correctly addresses the broken cloud mode. The constructor was passing as the first positional argument when expects first. Changes look good:
One note: The diff references but I don't see it defined in the repository. Please verify this constant exists or should be defined (e.g., ). Fix 2: Sequential Tool Dispatch ✅The fix correctly adds memory tool handling to the sequential path. The memory tools were only being dispatched in the concurrent path (), causing them to return "Unknown tool" in sequential mode. Changes look good:
One note: Please verify that and methods exist on the memory manager interface. I couldn't find these methods in the current codebase - they may need to be added or may already exist in a different location. OverallBoth fixes address real bugs that would prevent the Hindsight memory plugin from working properly. The changes are minimal and focused. ✅ Approve pending verification of constant and memory manager methods. |
This constant already exists on # plugins/memory/hindsight/__init__.py:32
_DEFAULT_API_URL = "https://api.hindsight.vectorize.io"You can verify directly: gh api 'repos/NousResearch/hermes-agent/contents/plugins/memory/hindsight/__init__.py?ref=main' -q '.content' | base64 -d | grep -n _DEFAULT_API_URL
# Output: 32:_DEFAULT_API_URL = "https://api.hindsight.vectorize.io"
Both methods already exist on
You can verify: gh api 'repos/NousResearch/hermes-agent/contents/agent/memory_manager.py?ref=main' -q '.content' | base64 -d | grep -nE 'def has_tool|def handle_tool_call'
# Output:
# 207: def has_tool(self, tool_name: str) -> bool:
# 211: def handle_tool_call(Both notes are false positives — the referenced code is part of the existing codebase, not introduced by this PR. I've also updated the PR description with a "Pre-existing code" section and verified commands. |
|
Already fixed on main via PR #4803 (merged). The memory provider dispatch block in _execute_tool_calls_sequential is identical to this fix. Thanks for catching the same issue! |
…api_url The Hindsight() constructor expects base_url as the first positional argument, but _make_client() passed api_key in that position. This made cloud mode completely non-functional. Also adds configurable api_url (via config, HINDSIGHT_API_URL env var, or setup wizard) so self-hosted Docker instances can be used instead of the default cloud endpoint. Timeout increased from 30s to 120s. Fixes the remaining issue from PR NousResearch#4762 (sequential dispatch was already fixed by PR NousResearch#4803).
Summary
Two related fixes for the Hindsight memory plugin.
Fix 1: incorrect constructor arguments (broken in cloud mode)
_make_client()passedapi_keyas the first positional argument toHindsight(), but the constructor expectsbase_urlfirst. The plugin never worked in cloud mode.Also adds configurable
api_urlfor self-hosted Docker instances (config, env var, setup wizard).Fix 2: memory tools not dispatched in sequential path
Memory provider tools (
hindsight_retain/recall/reflect) were only dispatched in the concurrent tool call path (_invoke_tool). The sequential path (_execute_tool_calls_sequential) fell through tohandle_function_call()which returned"Unknown tool"— so the tools only worked when multiple tools were called concurrently.Changes
plugins/memory/hindsight/__init__.py_load_config(): addapi_urlfromHINDSIGHT_API_URLenv varget_config_schema(): addapi_urlfield with env var hint_make_client(): resolvebase_urlfrom config → env → default; pass as first arg; timeout 120srun_agent.py_execute_tool_calls_sequential(): addmemory_manager.has_tool()guard matching the concurrent pathPre-existing code referenced in this PR
These are not introduced by this PR — they already exist on
main:_DEFAULT_API_URL→plugins/memory/hindsight/__init__.py:32has_tool()→agent/memory_manager.py:207handle_tool_call()→agent/memory_manager.py:211(dispatcher, implemented by every memory plugin)Verifiable on
main:Testing
retain→recall→reflectall functional