#5023·hindsight

Hermes integration: local_embedded client never sends tenant API key

Author: torch817Created Oct 1, 2026Updated Oct 1, 2026

Summary

The Hermes memory integration cannot talk to an embedded daemon that has a TenantExtension enabled: _new_embedded_client() builds the client without api_key, while _new_cloud_client() passes one. Enabling ApiKeyTenantExtension on a local_embedded profile therefore cuts Hermes off from its own memory — auto-recall and auto-retain fail with 401.

A second, related problem: the profile-env reconciliation would strip a manually configured tenant key, so there is no supported way to work around this from the outside.

Environment

  • Plugin: hindsight-integrations/hermes, upstream main @ eb021da3b2501911e4b57c82b3de1123572a200e (plugin.yaml version 1.2.1)
  • hindsight-api / hindsight-embed / hindsight-all: 0.10.2
  • hindsight-client: 0.6.1
  • Mode: local_embedded (pg0 embedded Postgres), Linux x86_64, Python 3.11

Problem 1 — the embedded client never sends a key

hindsight-integrations/hermes/__init__.py, end of _new_embedded_client() (line 740 on current main):

python
self._embedded_url = _start_daemon(daemon_config, profile)
logger.info("Connected to embedded Hindsight daemon at %s", self._embedded_url)
return Hindsight(base_url=self._embedded_url)        # <-- no api_key

versus _new_cloud_client() immediately below (lines 742-747):

python
kwargs = {"base_url": self._api_url, "timeout": float(self._timeout or _DEFAULT_TIMEOUT)}
if self._api_key:
    kwargs["api_key"] = self._api_key                # <-- key is sent here

grep -c api_key over the body of _new_embedded_client() returns 0, and grep -ci tenant over the whole plugin returns 0 — the integration has no notion of daemon-side authentication.

Reproduction

Daemon profile (~/.hindsight/profiles/<profile>.env):

HINDSIGHT_API_TENANT_EXTENSION=hindsight_api.extensions.builtin.tenant:ApiKeyTenantExtension
HINDSIGHT_API_TENANT_API_KEY=<key>

The daemon starts cleanly and enforces auth as documented (Tenant extension started in the log):

request result
GET /v1/default/banks no key 401 {"detail":"Authentication failed: Invalid API key"}
same, Authorization: Bearer <key> 200
same, wrong bearer 401
same, X-API-Key: <key> 401

Then reproduce both client constructions against that daemon:

python
from hindsight_client import Hindsight

# exactly what _new_embedded_client() does
Hindsight(base_url=URL).recall(bank_id="test-bank", query="test")
# -> UnauthorizedException: (401) Reason: Unauthorized

# exactly what _new_cloud_client() does
Hindsight(base_url=URL, api_key=KEY).recall(bank_id="test-bank", query="test")
# -> OK, returns results

So hindsight-client supports the key fine; only the embedded branch omits it.

Problem 2 — a manual tenant key gets wiped by profile-env reconciliation

_build_embedded_profile_env() (embedded.py:316) returns only:

HINDSIGHT_API_LLM_PROVIDER, HINDSIGHT_API_LLM_API_KEY, HINDSIGHT_API_LLM_MODEL, HINDSIGHT_API_LOG_LEVEL, optionally HINDSIGHT_API_LLM_BASE_URL and HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT.

__init__.py:1200 compares the on-disk profile env against that dict and rewrites on any difference:

python
if _load_simple_env(_embedded_profile_env_path(self._config)) != _build_embedded_profile_env(self._config):
    if _may_rewrite_profile_env(self._config):
        _materialize_embedded_profile_env(self._config)

_secure_write_profile_env() opens with os.O_TRUNC, i.e. a full overwrite. Any hand-added HINDSIGHT_API_TENANT_* line is therefore both (a) permanently a diff, forcing a rewrite on every init, and (b) discarded by that rewrite. Operators cannot enable daemon auth out-of-band and keep it.

(Problem 1 is verified by live request; problem 2 is read off the code path above — I did not exercise the reconciliation against an auth-enabled profile, since that path runs against the production profile.)

Suggested fix

  1. Pass the configured key in the embedded branch too, mirroring the cloud branch:
python
kwargs = {"base_url": self._embedded_url}
if self._api_key:
    kwargs["api_key"] = self._api_key
return Hindsight(**kwargs)
  1. Let the tenant settings be part of the embedded profile config, so _build_embedded_profile_env() emits HINDSIGHT_API_TENANT_EXTENSION / HINDSIGHT_API_TENANT_API_KEY and reconciliation preserves instead of strips them. A local_embedded config key (e.g. tenant_api_key) plus config_schema.py exposure would make the whole thing configurable through hermes memory setup.

Impact / workaround

Not a security hole by itself — the embedded daemon binds loopback, which is what protects the banks today. It does mean defence-in-depth is unavailable: on a multi-user or shared host there is no supported way to require a key on the memory daemon without breaking the agent that owns it.

Current workaround: leave the tenant extension off and rely on the loopback bind.