Add system diagnostics health endpoint and UI#892
Add system diagnostics health endpoint and UI#892RickyVishwakarma wants to merge 15 commits intoeigent-ai:mainfrom
Conversation
|
Hi maintainers 👋 |
|
thanks @RickyVishwakarma for the contribution! |
Wendong-Fan
left a comment
There was a problem hiding this comment.
thanks for the contribution, left some comments below
| # ------------------------------- | ||
| db_status = "unknown" | ||
| try: | ||
| from app.database import engine # adjust path ONLY if needed |
There was a problem hiding this comment.
seems in app no database
| # ------------------------------- | ||
| tools_available = False | ||
| try: | ||
| from app.tools.registry import TOOL_REGISTRY # adjust path if needed |
There was a problem hiding this comment.
no TOOL_REGISTRY in our project
There was a problem hiding this comment.
no TOOL_REGISTRY in our project
Thanks for pointing this out! You’re right — I assumed a tool registry that doesn’t exist in the current codebase. I’ll remove this check and keep the health endpoint aligned with existing project structures.
| model_api_key = os.getenv("MODEL_API_KEY") | ||
| model_name = os.getenv("MODEL_NAME") |
There was a problem hiding this comment.
no MODEL_API_KEY, no MODEL_NAME
There was a problem hiding this comment.
no
MODEL_API_KEY, noMODEL_NAME
Got it, thanks for clarifying. I’ll remove the model environment variable checks and avoid making assumptions about model configuration in this endpoint.
src/pages/Diagnostics.tsx
Outdated
| const [error, setError] = useState(""); | ||
|
|
||
| useEffect(() => { | ||
| fetch("/health") |
There was a problem hiding this comment.
i think use /health would not be able to access to the right backend
There was a problem hiding this comment.
i think use
/healthwould not be able to access to the right backend
Thanks for the note — makes sense. I’ll update the frontend to use the existing backend access pattern instead of calling /health directly.
|
Thanks for the review! I’ve updated the diagnostics page to use the proper backend path and removed assumptions about model and tool fields so it aligns with the current health endpoint. |
| return response | ||
|
|
||
| # Database connectivity check | ||
| db_status = "unknown" |
There was a problem hiding this comment.
Can we make these status as string enum?
Wendong-Fan
left a comment
There was a problem hiding this comment.
Thanks for working on the diagnostics feature! The idea of surfacing system health info is great. I found a few issues that need to be addressed before this can be merged.
| # Database connectivity check | ||
| db_status = "unknown" | ||
| try: | ||
| from app.database import engine # existing project database engine |
There was a problem hiding this comment.
This import will always fail because there is no app.database module in backend/. The backend/ is the local agent backend and has no database.
The database engine lives in server/app/component/database.py (the self-deploy server). If the goal is to add a DB health check for self-deploy users, this should be added to server/app/controller/health_controller.py instead, with:
from app.component.database import engineAs it stands, this silently catches the ImportError and always reports db_status = "error", which is misleading.
| db_status = "unknown" | ||
| try: | ||
| from app.database import engine # existing project database engine | ||
| with engine.connect() as conn: |
There was a problem hiding this comment.
Minor note: engine.connect() is a synchronous call inside an async def handler, which would block the event loop. If this gets moved to server/, consider either making the handler a regular def (FastAPI will run it in a threadpool automatically) or using run_in_executor.
src/pages/Diagnostics.tsx
Outdated
|
|
||
| useEffect(() => { | ||
| fetch("/api/health") | ||
| .then((res) => { |
There was a problem hiding this comment.
The project uses centralized API utilities (fetchGet / proxyFetchGet from @/api/http) for all backend calls. Using raw fetch("/api/health") here will:
- Not resolve the correct backend URL (Electron uses a dynamic port via
getBaseURL()) - Not include auth headers
- Not work in production
Should be something like:
import { fetchGet } from "@/api/http";
fetchGet("/health").then(setData).catch(...);| @@ -0,0 +1,45 @@ | |||
| import { useEffect, useState } from "react"; | |||
There was a problem hiding this comment.
Missing the Apache 2.0 license header that all source files in this project use. Please add the standard copyright block at the top.
|
Thanks for the review! I’ve addressed the comments and updated the backend and diagnostics page accordingly. Also resolved the merge conflicts. |
|
Thanks for the detailed review! I’ve updated the health endpoint to align with the backend structure, removed the database-related logic, and switched the diagnostics page to use the existing API utilities. I also cleaned up the routing changes and resolved conflicts. Please let me know if anything else needs adjustment. |
What does this PR do?
Adds a system diagnostics feature to make it easier to check if the backend
is ready before running workflows.
Backend
/healthendpoint to report:Frontend
/diagnosticspage to show system statusWhy is this needed?
Right now there is no easy way to verify whether the system
is fully set up. This helps with:
How was this tested?
/healthendpoint response