From 26056fa965ebc0508503bc8844b7eb3c651bea82 Mon Sep 17 00:00:00 2001 From: LeonSGP43 <154585401+LeonSGP43@users.noreply.github.com> Date: Thu, 23 Apr 2026 17:27:56 +0800 Subject: [PATCH] fix(honcho): honor host-specific baseUrl --- plugins/memory/honcho/client.py | 4 +++- tests/honcho_plugin/test_client.py | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/memory/honcho/client.py b/plugins/memory/honcho/client.py index fef2e2d58f..954fe244bf 100644 --- a/plugins/memory/honcho/client.py +++ b/plugins/memory/honcho/client.py @@ -362,7 +362,9 @@ class HonchoClientConfig: ) base_url = ( - raw.get("baseUrl") + host_block.get("baseUrl") + or host_block.get("base_url") + or raw.get("baseUrl") or raw.get("base_url") or os.environ.get("HONCHO_BASE_URL", "").strip() or None diff --git a/tests/honcho_plugin/test_client.py b/tests/honcho_plugin/test_client.py index 7b6bd46f1a..21926f83f1 100644 --- a/tests/honcho_plugin/test_client.py +++ b/tests/honcho_plugin/test_client.py @@ -251,16 +251,17 @@ class TestFromGlobalConfig: config = HonchoClientConfig.from_global_config(config_path=config_file) assert config.base_url == "http://config-host:9000" - def test_base_url_not_read_from_host_block(self, tmp_path): - """baseUrl is a root-level connection setting, not overridable per-host (consistent with apiKey).""" + def test_base_url_host_block_overrides_root_and_env(self, tmp_path): + """Host-specific baseUrl should win for self-hosted Honcho deployments.""" config_file = tmp_path / "config.json" config_file.write_text(json.dumps({ "baseUrl": "http://root:9000", "hosts": {"hermes": {"baseUrl": "http://host-block:9001"}}, })) - config = HonchoClientConfig.from_global_config(config_path=config_file) - assert config.base_url == "http://root:9000" + with patch.dict(os.environ, {"HONCHO_BASE_URL": "http://env:8000"}, clear=False): + config = HonchoClientConfig.from_global_config(config_path=config_file) + assert config.base_url == "http://host-block:9001" def test_timeout_from_config_root(self, tmp_path): config_file = tmp_path / "config.json"