4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from integrations.hermes.tools.hermes_session_evidence_tool import (
|
|
get_hermes_cron_state,
|
|
get_hermes_kv_cache_state,
|
|
get_hermes_message_history,
|
|
get_hermes_runtime_state,
|
|
get_hermes_session_log,
|
|
get_hermes_session_topology,
|
|
)
|
|
|
|
|
|
class _FakeHermesBackend:
|
|
def get_session_log(self, session_id: str = "", **_: Any) -> dict[str, Any]:
|
|
return {"source": "hermes", "available": True, "session_id": session_id, "events": []}
|
|
|
|
def get_message_history(self, session_id: str = "", **_: Any) -> dict[str, Any]:
|
|
return {"source": "hermes", "available": True, "session_id": session_id, "messages": []}
|
|
|
|
def get_kv_cache_state(self, session_id: str = "", **_: Any) -> dict[str, Any]:
|
|
return {
|
|
"source": "hermes",
|
|
"available": True,
|
|
"session_id": session_id,
|
|
"cache_hits": 1,
|
|
"cache_misses": 0,
|
|
"messages_with_cache_miss": [],
|
|
}
|
|
|
|
def get_runtime_state(self, session_id: str = "", **_: Any) -> dict[str, Any]:
|
|
return {
|
|
"source": "hermes",
|
|
"available": True,
|
|
"session_id": session_id,
|
|
"is_blocked": False,
|
|
}
|
|
|
|
def get_cron_state(self, session_id: str = "", **_: Any) -> dict[str, Any]:
|
|
return {
|
|
"source": "hermes",
|
|
"available": True,
|
|
"session_id": session_id,
|
|
"last_run": {"delivery_status": "ok"},
|
|
}
|
|
|
|
def get_session_topology(self, session_id: str = "", **_: Any) -> dict[str, Any]:
|
|
return {
|
|
"source": "hermes",
|
|
"available": True,
|
|
"session_id": session_id,
|
|
"visible_session_id": session_id,
|
|
"all_sessions": [],
|
|
}
|
|
|
|
|
|
def test_tools_delegate_to_backend() -> None:
|
|
backend = _FakeHermesBackend()
|
|
|
|
assert get_hermes_session_log("s1", hermes_backend=backend)["available"] is True
|
|
assert get_hermes_message_history("s1", hermes_backend=backend)["available"] is True
|
|
assert get_hermes_kv_cache_state("s1", hermes_backend=backend)["cache_hits"] == 1
|
|
assert get_hermes_runtime_state("s1", hermes_backend=backend)["is_blocked"] is False
|
|
assert (
|
|
get_hermes_cron_state("s1", hermes_backend=backend)["last_run"]["delivery_status"] == "ok"
|
|
)
|
|
assert get_hermes_session_topology("s1", hermes_backend=backend)["visible_session_id"] == "s1"
|
|
|
|
|
|
def test_tools_require_backend_when_not_configured() -> None:
|
|
result = get_hermes_session_log(session_id="")
|
|
assert result["available"] is False
|
|
assert "requires a Hermes backend" in str(result["error"])
|