AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
refactor(backend): remove the unused chat health route (#15697)
Reinier van der Leer83b73e0a8573
diff --git a/autogpt_platform/backend/backend/api/features/chat/routes.py b/autogpt_platform/backend/backend/api/features/chat/routes.pyindex d0247a0b3d..4df99b3a30 100644--- a/autogpt_platform/backend/backend/api/features/chat/routes.py+++ b/autogpt_platform/backend/backend/api/features/chat/routes.py@@ -2646,49 +2646,6 @@ async def get_ttl_config() -> dict:}-# ========== Health Check ==========--[email protected]("/health", status_code=200)-async def health_check() -> dict:- """- Health check endpoint for the chat service.-- Performs a full cycle test of session creation and retrieval. Should always return healthy- if the service and data layer are operational.-- Returns:- dict: A status dictionary indicating health, service name, and API version.-- """- from backend.data.user import get_or_create_user-- # Ensure health check user exists (required for FK constraint)- health_check_user_id = "health-check-user"- await get_or_create_user(- {- "sub": health_check_user_id,- "email": "[email protected]",- "user_metadata": {"name": "Health Check User"},- }- )-- # Create and retrieve session to verify full data layer- session = await create_chat_session(health_check_user_id, dry_run=False)- fetched = await get_chat_session_metadata(session.session_id, health_check_user_id)- if fetched is None:- raise HTTPException(- status_code=503,- detail="Chat read path unhealthy: session not found after create",- )-- return {- "status": "healthy",- "service": "chat",- "version": "0.1.0",- }--# ========== Schema Export (for OpenAPI / Orval codegen) ==========ToolResponseUnion = (diff --git a/autogpt_platform/backend/backend/api/features/chat/routes_test.py b/autogpt_platform/backend/backend/api/features/chat/routes_test.pyindex 760212508c..c462aae003 100644--- a/autogpt_platform/backend/backend/api/features/chat/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/chat/routes_test.py@@ -4709,66 +4709,6 @@ def test_create_session_rejects_unknown_fields(assert response.status_code == 422-def test_health_check_returns_503_when_metadata_read_returns_none(- mocker: pytest_mock.MockerFixture,-) -> None:- # Round-trips create-then-read; if the read path returns None despite- # a successful create, the health endpoint must surface the failure.- from backend.copilot.model import ChatSession-- mocker.patch(- "backend.data.user.get_or_create_user",- new_callable=AsyncMock,- return_value=None,- )- mocker.patch(- "backend.api.features.chat.routes.create_chat_session",- new_callable=AsyncMock,- side_effect=lambda uid, *, dry_run: ChatSession.new(uid, dry_run=dry_run),- )- mocker.patch(- "backend.api.features.chat.routes.get_chat_session_metadata",- new_callable=AsyncMock,- return_value=None,- )-- response = client.get("/health")- assert response.status_code == 503- assert "unhealthy" in response.json()["detail"].lower()---def test_health_check_returns_healthy_on_round_trip_success(- mocker: pytest_mock.MockerFixture,-) -> None:- # Happy path: create + read both succeed → 200 with healthy body.- from backend.copilot.model import ChatSession, ChatSessionInfo-- mocker.patch(- "backend.data.user.get_or_create_user",- new_callable=AsyncMock,- return_value=None,- )- fake_session = ChatSession.new("health-check-user", dry_run=False)- mocker.patch(- "backend.api.features.chat.routes.create_chat_session",- new_callable=AsyncMock,- return_value=fake_session,- )- mocker.patch(- "backend.api.features.chat.routes.get_chat_session_metadata",- new_callable=AsyncMock,- return_value=ChatSessionInfo(- **{**fake_session.model_dump(exclude={"messages"})}- ),- )-- response = client.get("/health")- assert response.status_code == 200- body = response.json()- assert body["status"] == "healthy"- assert body["service"] == "chat"--def test_resolve_session_permissions_blocks_out_of_scope_tools() -> None:"""Builder-bound sessions return a blacklist of the three tools thatconflict with the panel's graph-bound scope. Regular sessions returndiff --git a/autogpt_platform/backend/backend/api/paywall_routes_test.py b/autogpt_platform/backend/backend/api/paywall_routes_test.pyindex 49382ce2cd..55f8b262aa 100644--- a/autogpt_platform/backend/backend/api/paywall_routes_test.py+++ b/autogpt_platform/backend/backend/api/paywall_routes_test.py@@ -292,7 +292,6 @@ OPEN_WHILE_PAYWALLED = {"POST /api/auth/email/send","POST /api/auth/user/preferences/from-email","GET /api/chat/config/ttl",- "GET /api/chat/health","GET /api/chat/schema/tool-responses","POST /api/credits/stripe_webhook","POST /api/email/",diff --git a/autogpt_platform/backend/backend/util/tracing.py b/autogpt_platform/backend/backend/util/tracing.pyindex 214bf9c0d8..0f98756db8 100644--- a/autogpt_platform/backend/backend/util/tracing.py+++ b/autogpt_platform/backend/backend/util/tracing.py@@ -53,8 +53,6 @@ _UNTRACED_PATHS = frozenset(# Every RPC service (AppService): Kubernetes probe."/health_check","/health_check_async",- # Chat service health check.- "/api/chat/health",# Codex compatibility gateway."/healthz",}diff --git a/autogpt_platform/backend/backend/util/tracing_test.py b/autogpt_platform/backend/backend/util/tracing_test.pyindex 09ab9c5b65..51b219c985 100644--- a/autogpt_platform/backend/backend/util/tracing_test.py+++ b/autogpt_platform/backend/backend/util/tracing_test.py@@ -38,7 +38,6 @@ def _http(path: str, *, parent_sampled: bool | None = None) -> dict:"/health","/health_check","/health_check_async",- "/api/chat/health","/healthz",],)diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.jsonindex c3e601fe19..574dad00d7 100644--- a/autogpt_platform/frontend/src/app/api/openapi.json+++ b/autogpt_platform/frontend/src/app/api/openapi.json@@ -3818,28 +3818,6 @@"security": [{ "HTTPBearerJWT": [] }]}},- "/api/chat/health": {- "get": {- "tags": ["v2", "chat", "chat"],- "summary": "Health Check",- "description": "Health check endpoint for the chat service.\n\nPerforms a full cycle test of session creation and retrieval. Should always return healthy\nif the service and data layer are operational.\n\nReturns:\n dict: A status dictionary indicating health, service name, and API version.",- "operationId": "getV2HealthCheck",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "additionalProperties": true,- "type": "object",- "title": "Response Getv2Healthcheck"- }- }- }- }- }- }- },"/api/chat/model-tiers": {"get": {"tags": ["v2", "chat", "chat"],