Refine memory system user-key flow and search output
This commit is contained in:
@ -30,7 +30,25 @@ class FakeClient:
|
||||
if path == "/memory-system/search":
|
||||
return {
|
||||
"status": "success",
|
||||
"items": [{"source": "openviking", "content": "likes latte", "score": 0.9}],
|
||||
"items": [
|
||||
{
|
||||
"source_backend": "openviking",
|
||||
"content": "likes latte",
|
||||
"score": 0.9,
|
||||
"uri": "viking://user/user-1/memories/a",
|
||||
"vector": [0.1, 0.2],
|
||||
},
|
||||
{
|
||||
"source_backend": "everos",
|
||||
"memory": "prefers warm coffee",
|
||||
"memory_type": "profile",
|
||||
"original_data": {"large": "payload"},
|
||||
},
|
||||
],
|
||||
"backends": {
|
||||
"openviking": {"status": "success", "result": {"verbose": True}},
|
||||
"everos": {"status": "success", "result": {"verbose": True}},
|
||||
},
|
||||
}
|
||||
if path.endswith("/commit"):
|
||||
return {"status": self.commit_status}
|
||||
@ -48,6 +66,8 @@ def make_provider():
|
||||
provider._endpoint = "http://127.0.0.1:1934"
|
||||
provider._user_id = "user-1"
|
||||
provider._session_id = "session-1"
|
||||
provider._commit_every_turns = 0
|
||||
provider._commit_interval_seconds = 0
|
||||
return provider
|
||||
|
||||
|
||||
@ -77,6 +97,7 @@ def test_initialize_loads_config_from_hermes_env_file(tmp_path, monkeypatch):
|
||||
for key in list(os.environ):
|
||||
if key.startswith("MEMORY_SYSTEM_"):
|
||||
monkeypatch.delenv(key, raising=False)
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
||||
class InitClient(FakeClient):
|
||||
def __init__(self, endpoint, api_key="", timeout=0):
|
||||
@ -183,7 +204,22 @@ def test_search_tool_uses_memory_system_api():
|
||||
result = json.loads(provider.handle_tool_call("memory_system_search", {"query": "coffee", "limit": 3}))
|
||||
|
||||
assert result["status"] == "success"
|
||||
assert result["items"][0]["content"] == "likes latte"
|
||||
assert result["items"] == [
|
||||
{
|
||||
"source_backend": "openviking",
|
||||
"score": 0.9,
|
||||
"text": "likes latte",
|
||||
"uri": "viking://user/user-1/memories/a",
|
||||
},
|
||||
{
|
||||
"source_backend": "everos",
|
||||
"memory_type": "profile",
|
||||
"text": "prefers warm coffee",
|
||||
},
|
||||
]
|
||||
assert "backends" not in result
|
||||
assert "vector" not in json.dumps(result)
|
||||
assert "original_data" not in json.dumps(result)
|
||||
assert provider._client.posts[-1] == (
|
||||
"/memory-system/search",
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user