Spaces:
Sleeping
Sleeping
Claude Code Claude Opus 4.6 commited on
Commit ·
379a496
1
Parent(s): a17fe15
Claude Code: Fix health_monitor import paths and brain initialization
Browse files- Fix sys.path setup to use openclaw package import first
- Fix check_brain_health to use proper 'from agents import brain_minimal'
- Fix check_rbac_health to use proper 'from agents import rbac'
- Specify agent_name='cain' in get_brain() call
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
openclaw/.openclaw/agents/cain_status.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"current_state": "idle",
|
| 3 |
-
"last_updated": "2026-03-16T15:
|
| 4 |
"agent": "cain",
|
| 5 |
"stage": "RUNNING_A2A_READY",
|
| 6 |
"a2a": {
|
|
|
|
| 1 |
{
|
| 2 |
"current_state": "idle",
|
| 3 |
+
"last_updated": "2026-03-16T15:57:32.271790+00:00",
|
| 4 |
"agent": "cain",
|
| 5 |
"stage": "RUNNING_A2A_READY",
|
| 6 |
"a2a": {
|
openclaw/.openclaw/health_monitor.py
CHANGED
|
@@ -26,8 +26,22 @@ from pathlib import Path
|
|
| 26 |
from typing import Dict, List, Optional, Any, Callable
|
| 27 |
|
| 28 |
# Add agents directory to path for imports
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
AGENTS_DIR = Path(__file__).parent / "agents"
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
class HealthStatus(Enum):
|
|
@@ -278,9 +292,16 @@ class HealthMonitor:
|
|
| 278 |
}
|
| 279 |
|
| 280 |
try:
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
-
brain
|
|
|
|
| 284 |
info = brain.get_info()
|
| 285 |
|
| 286 |
result["details"] = {
|
|
@@ -317,17 +338,23 @@ class HealthMonitor:
|
|
| 317 |
}
|
| 318 |
|
| 319 |
try:
|
| 320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
|
| 322 |
-
|
| 323 |
|
| 324 |
result["details"] = {
|
| 325 |
-
"current_agent":
|
| 326 |
-
"current_role":
|
| 327 |
-
"legacy_mode":
|
| 328 |
-
"multi_agent_enabled":
|
| 329 |
-
"allowed_tools_count": len(
|
| 330 |
-
"peers_count": len(
|
| 331 |
}
|
| 332 |
|
| 333 |
result["status"] = HealthStatus.HEALTHY
|
|
|
|
| 26 |
from typing import Dict, List, Optional, Any, Callable
|
| 27 |
|
| 28 |
# Add agents directory to path for imports
|
| 29 |
+
# CRITICAL: In Docker, need to handle both nested and flat structures
|
| 30 |
+
# Priority 1: Try openclaw package import (sets up sys.path correctly)
|
| 31 |
+
try:
|
| 32 |
+
import openclaw # This sets up sys.path to include .openclaw
|
| 33 |
+
_agents_via_openclaw = Path(openclaw.__file__).parent / ".openclaw"
|
| 34 |
+
except ImportError:
|
| 35 |
+
_agents_via_openclaw = None
|
| 36 |
+
|
| 37 |
+
# Priority 2: Direct path relative to this file
|
| 38 |
AGENTS_DIR = Path(__file__).parent / "agents"
|
| 39 |
+
|
| 40 |
+
# Add to sys.path - try openclaw path first, then direct path
|
| 41 |
+
if _agents_via_openclaw and _agents_via_openclaw.exists():
|
| 42 |
+
sys.path.insert(0, str(_agents_via_openclaw))
|
| 43 |
+
elif str(AGENTS_DIR) not in sys.path:
|
| 44 |
+
sys.path.insert(0, str(AGENTS_DIR))
|
| 45 |
|
| 46 |
|
| 47 |
class HealthStatus(Enum):
|
|
|
|
| 292 |
}
|
| 293 |
|
| 294 |
try:
|
| 295 |
+
# Import via openclaw package first for proper path setup
|
| 296 |
+
try:
|
| 297 |
+
import openclaw # Ensure sys.path is set up
|
| 298 |
+
except ImportError:
|
| 299 |
+
pass # Continue - sys.path may already be set up
|
| 300 |
+
|
| 301 |
+
from agents import brain_minimal
|
| 302 |
|
| 303 |
+
# Get brain for Cain specifically
|
| 304 |
+
brain = brain_minimal.get_brain(agent_name="cain", legacy_mode=True)
|
| 305 |
info = brain.get_info()
|
| 306 |
|
| 307 |
result["details"] = {
|
|
|
|
| 338 |
}
|
| 339 |
|
| 340 |
try:
|
| 341 |
+
# Import via openclaw package first for proper path setup
|
| 342 |
+
try:
|
| 343 |
+
import openclaw # Ensure sys.path is set up
|
| 344 |
+
except ImportError:
|
| 345 |
+
pass # Continue - sys.path may already be set up
|
| 346 |
+
|
| 347 |
+
from agents import rbac
|
| 348 |
|
| 349 |
+
rbac_system = rbac.get_rbac_system()
|
| 350 |
|
| 351 |
result["details"] = {
|
| 352 |
+
"current_agent": rbac_system.current_agent,
|
| 353 |
+
"current_role": rbac_system.current_role.value if rbac_system.current_role else "unknown",
|
| 354 |
+
"legacy_mode": rbac_system.legacy_mode,
|
| 355 |
+
"multi_agent_enabled": rbac_system.is_multi_agent_enabled(),
|
| 356 |
+
"allowed_tools_count": len(rbac_system.get_allowed_tools()),
|
| 357 |
+
"peers_count": len(rbac_system.get_peers())
|
| 358 |
}
|
| 359 |
|
| 360 |
result["status"] = HealthStatus.HEALTHY
|