fix: make session search initialize session db

This commit is contained in:
HenkDz 2026-05-03 17:43:53 +01:00 committed by Teknium
parent 9c26297c80
commit 840ebe063e
8 changed files with 220 additions and 11 deletions

View file

@ -1,4 +1,5 @@
from types import SimpleNamespace
import sys
from types import ModuleType, SimpleNamespace
import pytest
from acp.schema import TextContentBlock
@ -66,6 +67,53 @@ def make_agent_and_state():
return acp_agent, state, fake, conn
def test_acp_real_agent_gets_session_db_for_recall(monkeypatch):
"""ACP sessions persist to SessionDB; recall must receive the same DB handle."""
captured = {}
sentinel_db = NoopDb()
class CapturingAgent(FakeAgent):
def __init__(self, **kwargs):
super().__init__()
captured.update(kwargs)
def mod(name, **attrs):
module = ModuleType(name)
for key, value in attrs.items():
setattr(module, key, value)
return module
monkeypatch.setitem(sys.modules, "run_agent", mod("run_agent", AIAgent=CapturingAgent))
monkeypatch.setitem(
sys.modules,
"hermes_cli.config",
mod("hermes_cli.config", load_config=lambda: {"model": {"default": "m", "provider": "p"}}),
)
monkeypatch.setitem(
sys.modules,
"hermes_cli.runtime_provider",
mod(
"hermes_cli.runtime_provider",
resolve_runtime_provider=lambda **_kwargs: {
"provider": "p",
"api_mode": "chat_completions",
"base_url": "u",
"api_key": "k",
"command": None,
"args": [],
},
),
)
manager = SessionManager(db=sentinel_db)
agent = manager._make_agent(session_id="acp-session", cwd=".")
assert isinstance(agent, CapturingAgent)
assert captured["session_db"] is sentinel_db
assert captured["platform"] == "acp"
assert captured["session_id"] == "acp-session"
@pytest.mark.asyncio
async def test_acp_steer_slash_command_injects_into_running_agent():
acp_agent, state, fake, _conn = make_agent_and_state()