Spaces:
Sleeping
Sleeping
Claude Code commited on
Commit ·
a9a9890
1
Parent(s): 03ab14e
Claude Code: Emergency diagnostic: A2A communication is failing. Check Cain's health,
Browse files- app.py +74 -3
- openclaw/.openclaw/agents/cain_status.json +1 -1
app.py
CHANGED
|
@@ -65,6 +65,14 @@ async def api_health():
|
|
| 65 |
"active_agents": 1
|
| 66 |
}
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
@app.get("/hello")
|
| 69 |
async def hello():
|
| 70 |
"""Hello endpoint - lazy loads brain, graceful degradation if offline."""
|
|
@@ -270,7 +278,7 @@ async def a2a_health():
|
|
| 270 |
brain_ready = False
|
| 271 |
error_details = None
|
| 272 |
|
| 273 |
-
# Test brain import and availability
|
| 274 |
try:
|
| 275 |
import openclaw # Sets up sys.path
|
| 276 |
from agents import brain_minimal
|
|
@@ -289,18 +297,24 @@ async def a2a_health():
|
|
| 289 |
except ImportError as e:
|
| 290 |
brain_status = "import_error"
|
| 291 |
error_details = str(e)
|
|
|
|
|
|
|
|
|
|
| 292 |
except Exception as e:
|
| 293 |
brain_status = "error"
|
| 294 |
error_details = str(e)
|
| 295 |
|
|
|
|
|
|
|
| 296 |
return {
|
| 297 |
-
"status": "ok"
|
| 298 |
"agent": "Cain",
|
| 299 |
"a2a": {
|
| 300 |
"protocol": "jsonrpc",
|
| 301 |
"endpoint": "/a2a/jsonrpc",
|
| 302 |
"brain_status": brain_status,
|
| 303 |
-
"brain_ready": brain_ready
|
|
|
|
| 304 |
},
|
| 305 |
"uptime_seconds": time.time() - START_TIME,
|
| 306 |
"error": error_details
|
|
@@ -308,6 +322,63 @@ async def a2a_health():
|
|
| 308 |
|
| 309 |
print(">>> CAIN: FastAPI app created successfully", flush=True)
|
| 310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
|
| 312 |
if __name__ == "__main__":
|
| 313 |
import uvicorn
|
|
|
|
| 65 |
"active_agents": 1
|
| 66 |
}
|
| 67 |
|
| 68 |
+
@app.get("/a2a/ping")
|
| 69 |
+
async def a2a_ping():
|
| 70 |
+
"""
|
| 71 |
+
Minimal ping endpoint for liveness checks.
|
| 72 |
+
Always returns immediately without any imports or heavy operations.
|
| 73 |
+
"""
|
| 74 |
+
return {"pong": True, "uptime_seconds": time.time() - START_TIME}
|
| 75 |
+
|
| 76 |
@app.get("/hello")
|
| 77 |
async def hello():
|
| 78 |
"""Hello endpoint - lazy loads brain, graceful degradation if offline."""
|
|
|
|
| 278 |
brain_ready = False
|
| 279 |
error_details = None
|
| 280 |
|
| 281 |
+
# Test brain import and availability with timeout protection
|
| 282 |
try:
|
| 283 |
import openclaw # Sets up sys.path
|
| 284 |
from agents import brain_minimal
|
|
|
|
| 297 |
except ImportError as e:
|
| 298 |
brain_status = "import_error"
|
| 299 |
error_details = str(e)
|
| 300 |
+
except RecursionError as e:
|
| 301 |
+
brain_status = "recursion_error"
|
| 302 |
+
error_details = "Circular import detected - openclaw init issue"
|
| 303 |
except Exception as e:
|
| 304 |
brain_status = "error"
|
| 305 |
error_details = str(e)
|
| 306 |
|
| 307 |
+
# A2A endpoint is ALWAYS available (this endpoint responding proves it)
|
| 308 |
+
# Brain readiness is informational, not blocking
|
| 309 |
return {
|
| 310 |
+
"status": "ok", # A2A endpoint is working
|
| 311 |
"agent": "Cain",
|
| 312 |
"a2a": {
|
| 313 |
"protocol": "jsonrpc",
|
| 314 |
"endpoint": "/a2a/jsonrpc",
|
| 315 |
"brain_status": brain_status,
|
| 316 |
+
"brain_ready": brain_ready,
|
| 317 |
+
"endpoint_available": True
|
| 318 |
},
|
| 319 |
"uptime_seconds": time.time() - START_TIME,
|
| 320 |
"error": error_details
|
|
|
|
| 322 |
|
| 323 |
print(">>> CAIN: FastAPI app created successfully", flush=True)
|
| 324 |
|
| 325 |
+
# ============================================================================
|
| 326 |
+
# STARTUP DIAGNOSTIC ENDPOINT
|
| 327 |
+
# ============================================================================
|
| 328 |
+
@app.get("/a2a/diagnostics")
|
| 329 |
+
async def a2a_diagnostics():
|
| 330 |
+
"""
|
| 331 |
+
Diagnostic endpoint for troubleshooting A2A communication issues.
|
| 332 |
+
"""
|
| 333 |
+
import sys
|
| 334 |
+
from pathlib import Path
|
| 335 |
+
|
| 336 |
+
diagnostics = {
|
| 337 |
+
"timestamp": time.time(),
|
| 338 |
+
"uptime_seconds": time.time() - START_TIME,
|
| 339 |
+
"python": {
|
| 340 |
+
"version": sys.version.split()[0],
|
| 341 |
+
"executable": sys.executable
|
| 342 |
+
},
|
| 343 |
+
"paths": {
|
| 344 |
+
"cwd": os.getcwd(),
|
| 345 |
+
"sys_path_first": sys.path[:3],
|
| 346 |
+
"frontend_dir_exists": Path("/app/frontend").exists(),
|
| 347 |
+
"data_frontend_exists": Path("/data/frontend").exists(),
|
| 348 |
+
"app_py_exists": Path("/app/app.py").exists(),
|
| 349 |
+
"openclaw_init_exists": Path("/app/openclaw/__init__.py").exists()
|
| 350 |
+
},
|
| 351 |
+
"env": {
|
| 352 |
+
"port": os.environ.get('PORT', '7860'),
|
| 353 |
+
"openclaw_data_dir": os.environ.get('OPENCLAW_DATA_DIR'),
|
| 354 |
+
"cain_status_path": os.environ.get('CAIN_STATUS_PATH')
|
| 355 |
+
},
|
| 356 |
+
"modules": {
|
| 357 |
+
"fastapi": True,
|
| 358 |
+
"uvicorn": True
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
# Test brain import
|
| 363 |
+
try:
|
| 364 |
+
import openclaw
|
| 365 |
+
diagnostics["modules"]["openclaw"] = True
|
| 366 |
+
diagnostics["openclaw_path"] = str(openclaw.__file__)
|
| 367 |
+
diagnostics["openclaw_sys_path_added"] = str(Path(openclaw.__file__).parent / ".openclaw")
|
| 368 |
+
except Exception as e:
|
| 369 |
+
diagnostics["modules"]["openclaw"] = False
|
| 370 |
+
diagnostics["openclaw_error"] = str(e)
|
| 371 |
+
|
| 372 |
+
try:
|
| 373 |
+
from agents import brain_minimal
|
| 374 |
+
diagnostics["modules"]["brain_minimal"] = True
|
| 375 |
+
diagnostics["brain_has_get_brain"] = hasattr(brain_minimal, 'get_brain')
|
| 376 |
+
except Exception as e:
|
| 377 |
+
diagnostics["modules"]["brain_minimal"] = False
|
| 378 |
+
diagnostics["brain_minimal_error"] = str(e)
|
| 379 |
+
|
| 380 |
+
return diagnostics
|
| 381 |
+
|
| 382 |
|
| 383 |
if __name__ == "__main__":
|
| 384 |
import uvicorn
|
openclaw/.openclaw/agents/cain_status.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
"current_state": "idle",
|
| 3 |
-
"last_updated": "2026-03-16T07:
|
| 4 |
"agent": "cain"
|
| 5 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"current_state": "idle",
|
| 3 |
+
"last_updated": "2026-03-16T07:28:04.536278+00:00",
|
| 4 |
"agent": "cain"
|
| 5 |
}
|