fix(embed): skip profile .env overwrite when config has no HINDSIGHT_API_* keys (#896)

When the daemon is already running, ensure_running() calls _register_profile()
with a config dict using short keys (llm_api_key, llm_provider, etc.) that do
not match the HINDSIGHT_API_* prefix filter. This caused api_config to always
be empty, and create_profile() would overwrite the existing .env with an empty
file on every CLI command.

Add an early return guard so _register_profile() skips the create_profile()
call when api_config is empty, preserving any existing profile configuration.

Fixes #894
This commit is contained in:
Octopus 2026-04-07 02:28:53 -05:00 committed by GitHub
parent e0e65c44f6
commit 9e2890ba81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -419,6 +419,8 @@ class DaemonEmbedManager(EmbedManager):
"""
try:
api_config = {k: v for k, v in config.items() if k.startswith("HINDSIGHT_API_")}
if not api_config:
return
self._profile_manager.create_profile(profile, port, api_config)
except Exception as e:
logger.debug(f"Failed to register profile '{profile}' in metadata: {e}")