feat(images): reuse named connections and image request settings

Preserve the reviewed tree while removing obsolete stacked branch history.

Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
Xubin Renandchengyongru committed 2026-10-12 21:22:35 +08:00
1 parent 105b772203
commit 23941355a8
27 files changed
+381 -44

No files matched your search

+14 -3
View File
@@ -118,13 +118,22 @@ def test_from_config_composes_configured_mcp_outside_agent_loop(tmp_path):
assert bot._mcp_provider._registry is bot._loop.tools
def test_from_config_uses_instance_image_settings(tmp_path, monkeypatch):
@pytest.mark.parametrize("provider_name", ["openrouter", "SenseNova"])
def test_from_config_uses_instance_image_settings(tmp_path, monkeypatch, provider_name):
from nanobot.agent.tools.image_generation import ImageGenerationTool
monkeypatch.setattr("nanobot.config.loader._current_config_path", tmp_path / "default.json")
config_path = _write_config(
tmp_path,
{"tools": {"imageGeneration": {"enabled": True, "model": "instance-image-model"}}},
{
"providers": {
"openrouter": {"apiKey": "sk-test-key"},
"SenseNova": {"apiKey": "named-image-key", "apiBase": "https://images.test/v1"},
},
"tools": {"imageGeneration": {
"enabled": True, "model": "instance-image-model", "provider": provider_name,
}},
},
)
bot = Nanobot.from_config(config_path, workspace=tmp_path)
@@ -132,7 +141,9 @@ def test_from_config_uses_instance_image_settings(tmp_path, monkeypatch):
tool = bot._loop.tools.get("generate_image")
assert isinstance(tool, ImageGenerationTool)
assert tool.config.model == "instance-image-model"
assert tool.provider_configs["openrouter"].api_key == "sk-test-key"
client = tool._provider_client()
assert client is not None
assert client.api_key == ("sk-test-key" if provider_name == "openrouter" else "named-image-key")
def test_from_config_accepts_default_model_override(tmp_path):