Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,31 +1306,6 @@ def __init__(
try:
_mem_provider_name = mem_config.get("provider", "") if mem_config else ""

# Auto-migrate: if Honcho was actively configured (enabled +
# credentials) but memory.provider is not set, activate the
# honcho plugin automatically. Just having the config file
# is not enough — the user may have disabled Honcho or the
# file may be from a different tool.
if not _mem_provider_name:
try:
from plugins.memory.honcho.client import HonchoClientConfig as _HCC
_hcfg = _HCC.from_global_config()
if _hcfg.enabled and (_hcfg.api_key or _hcfg.base_url):
_mem_provider_name = "honcho"
# Persist so this only auto-migrates once
try:
from hermes_cli.config import load_config as _lc, save_config as _sc
_cfg = _lc()
_cfg.setdefault("memory", {})["provider"] = "honcho"
_sc(_cfg)
except Exception:
pass
if not self.quiet_mode:
print(" ✓ Auto-migrated Honcho to memory provider plugin.")
print(" Your config and data are preserved.\n")
except Exception:
pass

if _mem_provider_name:
from agent.memory_manager import MemoryManager as _MemoryManager
from plugins.memory import load_memory_provider as _load_mem
Expand Down
39 changes: 39 additions & 0 deletions tests/run_agent/test_memory_provider_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Regression tests for memory provider selection during AIAgent init."""

from types import SimpleNamespace
from unittest.mock import patch


def test_blank_memory_provider_does_not_auto_enable_honcho():
"""Blank memory.provider should remain opt-out even if Honcho fallback looks configured."""
cfg = {"memory": {"provider": ""}, "agent": {}}
honcho_cfg = SimpleNamespace(enabled=True, api_key="stale-key", base_url=None)

with (
patch("hermes_cli.config.load_config", return_value=cfg),
patch("hermes_cli.config.save_config") as save_config,
patch(
"plugins.memory.honcho.client.HonchoClientConfig.from_global_config",
return_value=honcho_cfg,
) as from_global_config,
patch("plugins.memory.load_memory_provider") as load_memory_provider,
patch("agent.model_metadata.get_model_context_length", return_value=204_800),
patch("run_agent.get_tool_definitions", return_value=[]),
patch("run_agent.check_toolset_requirements", return_value={}),
patch("run_agent.OpenAI"),
):
from run_agent import AIAgent

agent = AIAgent(
api_key="test-key-1234567890",
base_url="https://openrouter.ai/api/v1",
quiet_mode=True,
skip_context_files=True,
skip_memory=False,
)

assert agent._memory_manager is None
from_global_config.assert_not_called()
load_memory_provider.assert_not_called()
save_config.assert_not_called()

Loading