Skip to content

Add system diagnostics health endpoint and UI#892

Open
RickyVishwakarma wants to merge 15 commits intoeigent-ai:mainfrom
RickyVishwakarma:feat/diagnostics-health-check
Open

Add system diagnostics health endpoint and UI#892
RickyVishwakarma wants to merge 15 commits intoeigent-ai:mainfrom
RickyVishwakarma:feat/diagnostics-health-check

Conversation

@RickyVishwakarma
Copy link

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

  • Extends the existing /health endpoint to report:
    • Database connectivity
    • Model configuration
    • Tool registry availability

Frontend

  • Adds a /diagnostics page to show system status
  • Protects the page behind authentication
  • Uses existing routing and layout

Why is this needed?

Right now there is no easy way to verify whether the system
is fully set up. This helps with:

  • Debugging setup issues
  • Onboarding new users
  • Understanding runtime state

How was this tested?

  • Checked /health endpoint response
  • Loaded diagnostics page when logged in
  • Verified redirect to login when logged out

@RickyVishwakarma
Copy link
Author

Hi maintainers 👋
This PR is ready for review.
Could someone please approve the workflow and review the changes when convenient?
Thanks!

@Wendong-Fan
Copy link
Contributor

thanks @RickyVishwakarma for the contribution!

Copy link
Contributor

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution, left some comments below

# -------------------------------
db_status = "unknown"
try:
from app.database import engine # adjust path ONLY if needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems in app no database

# -------------------------------
tools_available = False
try:
from app.tools.registry import TOOL_REGISTRY # adjust path if needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no TOOL_REGISTRY in our project

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +70 to +71
model_api_key = os.getenv("MODEL_API_KEY")
model_name = os.getenv("MODEL_NAME")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no MODEL_API_KEY, no MODEL_NAME

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no MODEL_API_KEY, no MODEL_NAME

Got it, thanks for clarifying. I’ll remove the model environment variable checks and avoid making assumptions about model configuration in this endpoint.

const [error, setError] = useState("");

useEffect(() => {
fetch("/health")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think use /health would not be able to access to the right backend

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think use /health would 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.

@RickyVishwakarma
Copy link
Author

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make these status as string enum?

Copy link
Contributor

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 engine

As 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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


useEffect(() => {
fetch("/api/health")
.then((res) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project uses centralized API utilities (fetchGet / proxyFetchGet from @/api/http) for all backend calls. Using raw fetch("/api/health") here will:

  1. Not resolve the correct backend URL (Electron uses a dynamic port via getBaseURL())
  2. Not include auth headers
  3. 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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the Apache 2.0 license header that all source files in this project use. Please add the standard copyright block at the top.

@RickyVishwakarma
Copy link
Author

Thanks for the review! I’ve addressed the comments and updated the backend and diagnostics page accordingly. Also resolved the merge conflicts.

@RickyVishwakarma
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants