Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(langchain): recognize SDK system health flag (#5878)

Evoda5e61b18cd1
diff --git a/examples/langchain/src/langchain_openviking/tools.py b/examples/langchain/src/langchain_openviking/tools.py
index 591380abd..85a0805bd 100644
--- a/examples/langchain/src/langchain_openviking/tools.py
+++ b/examples/langchain/src/langchain_openviking/tools.py
@@ -643,6 +643,8 @@ def _infer_health_state(status: Any) -> str:
return "unhealthy"
if state in {"degraded", "initializing", "starting", "pending"}:
return state
+ if isinstance(status.get("is_healthy"), bool):
+ return "healthy" if status["is_healthy"] else "unhealthy"
return "unknown"
@@ -651,7 +653,7 @@ def _safe_status_summary(status: Any) -> dict[str, Any]:
return {"type": type(status).__name__}
summary: dict[str, Any] = {}
- for key in ("healthy", "ok", "status", "state", "state_detail"):
+ for key in ("healthy", "ok", "status", "state", "state_detail", "is_healthy"):
if key in status:
value = _safe_status_value(status[key])
if value is not None:
diff --git a/tests/unit/test_langchain_integration.py b/tests/unit/test_langchain_integration.py
index c182032d9..e9321a161 100644
--- a/tests/unit/test_langchain_integration.py
+++ b/tests/unit/test_langchain_integration.py
@@ -366,14 +366,28 @@ def test_openviking_tool_schemas_describe_model_visible_arguments():
)
-def test_openviking_health_tool_returns_safe_summary():
+ ("status", "expected_state"),
+ [
+ ({"status": "degraded"}, "degraded"),
+ ({"is_healthy": True}, "healthy"),
+ ({"is_healthy": False}, "unhealthy"),
+ ({"healthy": False, "is_healthy": True}, "unhealthy"),
+ ({"ok": True, "is_healthy": False}, "healthy"),
+ ({"status": "degraded", "is_healthy": True}, "degraded"),
+ ({"state": "ready", "is_healthy": False}, "healthy"),
+ ({"is_healthy": "true"}, "unknown"),
+ ],
+)
+def test_openviking_health_tool_returns_safe_summary(status, expected_state):
class StatusClient(InMemoryOpenVikingClient):
def get_status(self) -> dict[str, Any]:
return {
- "status": "degraded",
+ **status,
"state_detail": "service is starting up and loading initial data from the persistence layer",
"hostname": "internal-openviking.local",
"database_url": "postgres://user:[email protected]/db",
+ "errors": ["postgres://user:[email protected]/db"],
"components": {"storage": {"status": "ok"}},
}
@@ -381,10 +395,10 @@ def test_openviking_health_tool_returns_safe_summary():
payload = json.loads(tools["viking_health"].invoke({}))
assert payload["backend"] == "OpenViking"
- assert payload["state"] == "degraded"
- assert payload["healthy"] is False
+ assert payload["state"] == expected_state
+ assert payload["healthy"] is (expected_state == "healthy")
assert payload["summary"] == {
- "status": "degraded",
+ **status,
"state_detail": "service is starting up and loading initial data from the pers...",
"component_count": 1,
}