feat(web): Add /health and /version endpoints to ADK web server

These endpoints provide basic health checks and version information for the running ADK server, including the ADK version and Python runtime details. The version information will be used to generate ADK conformance test report.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 868283421
This commit is contained in:
Liang Wu
2026-02-10 13:06:47 -08:00
committed by Copybara-Service
parent 2f0fe97729
commit 25ec2c6b61
2 changed files with 32 additions and 0 deletions
+14
View File
@@ -20,6 +20,7 @@ import importlib
import json
import logging
import os
import sys
import time
import traceback
import typing
@@ -88,6 +89,7 @@ from ..runners import Runner
from ..sessions.base_session_service import BaseSessionService
from ..sessions.session import Session
from ..utils.context_utils import Aclosing
from ..version import __version__
from .cli_eval import EVAL_SESSION_ID_PREFIX
from .utils import cleanup
from .utils import common
@@ -757,6 +759,18 @@ class AdkWebServer:
allow_headers=["*"],
)
@app.get("/health")
async def health() -> dict[str, str]:
return {"status": "ok"}
@app.get("/version")
async def version() -> dict[str, str]:
return {
"version": __version__,
"language": "python",
"language_version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
}
@app.get("/list-apps")
async def list_apps(
detailed: bool = Query(
+18
View File
@@ -1530,5 +1530,23 @@ def test_builder_save_rejects_traversal(builder_test_client, tmp_path):
assert not (tmp_path / "app" / "tmp" / "escape.yaml").exists()
def test_health_endpoint(test_app):
"""Test the health endpoint."""
response = test_app.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
def test_version_endpoint(test_app):
"""Test the version endpoint."""
response = test_app.get("/version")
assert response.status_code == 200
data = response.json()
assert "version" in data
assert "language" in data
assert data["language"] == "python"
assert "language_version" in data
if __name__ == "__main__":
pytest.main(["-xvs", __file__])