fix(honcho): guard against empty api_key in Honcho client construction - #61670
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(honcho): guard against empty api_key in Honcho client construction#61670liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
When config.api_key is None or empty string, the Honcho SDK receives an empty Authorization header (Bearer with no value), causing write operations (e.g., honcho_conclude) to fail with "AuthenticationError: Invalid API key". The fix: only pass api_key to the SDK constructor when it is non-empty. This allows the SDK to fall back to its own environment variable lookup (HONCHO_API_KEY) when the resolved key is missing. Fixes NousResearch#61661
Contributor
|
Thanks for the focused investigation. This automated hermes-sweeper review is closing the PR because the proposed change does not affect the reported path.
|
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?
Fixes the honcho_conclude tool failure when the resolved
api_keyisNoneor an empty string. In this case, the Honcho SDK receives an emptyAuthorizationheader (Bearerwith no value), causing write operations (e.g.,honcho_conclude) to fail withAuthenticationError: Invalid API key.The root cause:
plugins/memory/honcho/client.py:_build()always passesapi_keyto the SDK constructor, even when it's empty. This breaks LAN/VPN self-hosted instances where the user configures an empty or missing key and expects the SDK to fall back to environment variable lookup.The fix: only pass
api_keyto the SDK constructor wheneffective_api_keyis non-empty. This allows the SDK to fall back to its ownHONCHO_API_KEYenvironment variable lookup when the resolved key is missing.Related Issue
Fixes #61661
Type of Change
Changes Made
plugins/memory/honcho/client.py: Guard against emptyapi_keyinHonchoclient construction (lines 903-910). Changed from unconditionalapi_keyinkwargsto conditional: only setkwargs["api_key"]wheneffective_api_keyis truthy.How to Test
http://192.168.2.112:8000).apiKey: "local"in the host block in~/.hermes/honcho.json.honcho_concludewith a test fact.✅ honcho_conclude saved conclusion(or similar success indicator).Before the fix, the tool fails with
⚡ honcho_conclude [Failed to save conclusion.]and the Honcho server logs showAuthenticationError: Invalid API key. After the fix, the SDK correctly readsHONCHO_API_KEYfrom the environment and writes succeed.Regression test: the existing
test_honcho_client_config.pysuite (8 tests) all pass, confirming the fix doesn't break the normal config resolution flow.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (rantests/test_honcho_client_config.py: 8 passed)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/A