def test_create_cli_agent_accepts_host_backend_and_memory_options( monkeypatch, tmp_path ): import EvoScientist.EvoScientist as agent_module from EvoScientist.config.settings import EvoScientistConfig calls = {} workspace_backend = object() chat_model = object() class _CompositeBackend: def __init__(self, *, default, routes): calls["default_backend"] = default calls["routes"] = routes class _MemoryBackend: def __init__(self, **kwargs): calls["memory_backend_kwargs"] = kwargs class _SkillsBackend: def __init__(self, **kwargs): calls["skills_backend_kwargs"] = kwargs class _Agent: def with_config(self, config): calls["agent_config"] = config return self cfg = EvoScientistConfig(auto_approve=True, recursion_limit=321) monkeypatch.setattr("deepagents.backends.CompositeBackend", _CompositeBackend) monkeypatch.setattr("deepagents.create_deep_agent", lambda **kwargs: _Agent()) monkeypatch.setattr("EvoScientist.backends.MemoryFilesystemBackend", _MemoryBackend) monkeypatch.setattr("EvoScientist.backends.MergedSkillsBackend", _SkillsBackend) monkeypatch.setattr(agent_module, "set_active_workspace", lambda path: None) monkeypatch.setattr( agent_module, "_get_default_middleware", lambda **kwargs: calls.setdefault("middleware_kwargs", kwargs) or [], ) monkeypatch.setattr( agent_module, "load_mcp_and_build_kwargs", lambda *args, **kwargs: {"subagents": [{"name": "research"}]}, ) memory_dir = tmp_path / "memory" result = agent_module.create_cli_agent( workspace_dir=str(tmp_path / "workspace"), checkpointer=object(), config=cfg, chat_model=chat_model, workspace_backend=workspace_backend, memory_dir=memory_dir, tool_selector_threshold=8, memory_max_inline_profile_chars=1000, enable_subagents=False, enable_background_execution=False, ) assert isinstance(result, _Agent) assert calls["default_backend"] is workspace_backend assert calls["memory_backend_kwargs"] == { "root_dir": str(memory_dir), "virtual_mode": True, } assert calls["middleware_kwargs"]["memory_dir"] == str(memory_dir) assert calls["middleware_kwargs"]["tool_selector_threshold"] == 8 assert calls["middleware_kwargs"]["memory_max_inline_profile_chars"] == 1000 assert calls["middleware_kwargs"]["enable_background_execution"] is False assert calls["agent_config"] == {"recursion_limit": 321}