mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-22 05:22:09 +00:00
fix: make session search initialize session db
This commit is contained in:
parent
9c26297c80
commit
840ebe063e
8 changed files with 220 additions and 11 deletions
|
|
@ -419,6 +419,72 @@ def test_oneshot_distinguishes_disabled_mcp_from_unknown(monkeypatch, capsys):
|
|||
assert "mcp-off" in err
|
||||
|
||||
|
||||
def test_oneshot_wires_session_db_for_recall(monkeypatch):
|
||||
"""hermes -z bypasses HermesCLI, but recall still needs SessionDB."""
|
||||
from hermes_cli.oneshot import _run_agent
|
||||
|
||||
captured = {}
|
||||
sentinel_db = object()
|
||||
|
||||
class FakeAgent:
|
||||
def __init__(self, **kwargs):
|
||||
captured.update(kwargs)
|
||||
self.suppress_status_output = False
|
||||
self.stream_delta_callback = object()
|
||||
self.tool_gen_callback = object()
|
||||
|
||||
def chat(self, prompt):
|
||||
captured["prompt"] = prompt
|
||||
return "ok"
|
||||
|
||||
class FakeSessionDB:
|
||||
def __new__(cls):
|
||||
return sentinel_db
|
||||
|
||||
def mod(name, **attrs):
|
||||
module = types.ModuleType(name)
|
||||
for key, value in attrs.items():
|
||||
setattr(module, key, value)
|
||||
return module
|
||||
|
||||
monkeypatch.setitem(sys.modules, "run_agent", mod("run_agent", AIAgent=FakeAgent))
|
||||
monkeypatch.setitem(sys.modules, "hermes_state", mod("hermes_state", SessionDB=FakeSessionDB))
|
||||
monkeypatch.setitem(
|
||||
sys.modules,
|
||||
"hermes_cli.config",
|
||||
mod("hermes_cli.config", load_config=lambda: {"model": {"default": "m"}}),
|
||||
)
|
||||
monkeypatch.setitem(
|
||||
sys.modules,
|
||||
"hermes_cli.models",
|
||||
mod("hermes_cli.models", detect_provider_for_model=lambda *_args, **_kwargs: None),
|
||||
)
|
||||
monkeypatch.setitem(
|
||||
sys.modules,
|
||||
"hermes_cli.runtime_provider",
|
||||
mod(
|
||||
"hermes_cli.runtime_provider",
|
||||
resolve_runtime_provider=lambda **_kwargs: {
|
||||
"api_key": "k",
|
||||
"base_url": "u",
|
||||
"provider": "p",
|
||||
"api_mode": "chat_completions",
|
||||
"credential_pool": None,
|
||||
},
|
||||
),
|
||||
)
|
||||
monkeypatch.setitem(
|
||||
sys.modules,
|
||||
"hermes_cli.tools_config",
|
||||
mod("hermes_cli.tools_config", _get_platform_tools=lambda *_args, **_kwargs: {"session_search"}),
|
||||
)
|
||||
|
||||
assert _run_agent("recall this") == "ok"
|
||||
assert captured["session_db"] is sentinel_db
|
||||
assert captured["enabled_toolsets"] == ["session_search"]
|
||||
assert captured["prompt"] == "recall this"
|
||||
|
||||
|
||||
def test_launch_tui_exports_model_provider_and_toolsets(monkeypatch, main_mod):
|
||||
captured = {}
|
||||
active_path_during_call = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue