Skip to content

Commit 25ec2c6

Browse files
wuliang229copybara-github
authored andcommitted
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
1 parent 2f0fe97 commit 25ec2c6

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/google/adk/cli/adk_web_server.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import json
2121
import logging
2222
import os
23+
import sys
2324
import time
2425
import traceback
2526
import typing
@@ -88,6 +89,7 @@
8889
from ..sessions.base_session_service import BaseSessionService
8990
from ..sessions.session import Session
9091
from ..utils.context_utils import Aclosing
92+
from ..version import __version__
9193
from .cli_eval import EVAL_SESSION_ID_PREFIX
9294
from .utils import cleanup
9395
from .utils import common
@@ -757,6 +759,18 @@ async def internal_lifespan(app: FastAPI):
757759
allow_headers=["*"],
758760
)
759761

762+
@app.get("/health")
763+
async def health() -> dict[str, str]:
764+
return {"status": "ok"}
765+
766+
@app.get("/version")
767+
async def version() -> dict[str, str]:
768+
return {
769+
"version": __version__,
770+
"language": "python",
771+
"language_version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
772+
}
773+
760774
@app.get("/list-apps")
761775
async def list_apps(
762776
detailed: bool = Query(

tests/unittests/cli/test_fast_api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,5 +1530,23 @@ def test_builder_save_rejects_traversal(builder_test_client, tmp_path):
15301530
assert not (tmp_path / "app" / "tmp" / "escape.yaml").exists()
15311531

15321532

1533+
def test_health_endpoint(test_app):
1534+
"""Test the health endpoint."""
1535+
response = test_app.get("/health")
1536+
assert response.status_code == 200
1537+
assert response.json() == {"status": "ok"}
1538+
1539+
1540+
def test_version_endpoint(test_app):
1541+
"""Test the version endpoint."""
1542+
response = test_app.get("/version")
1543+
assert response.status_code == 200
1544+
data = response.json()
1545+
assert "version" in data
1546+
assert "language" in data
1547+
assert data["language"] == "python"
1548+
assert "language_version" in data
1549+
1550+
15331551
if __name__ == "__main__":
15341552
pytest.main(["-xvs", __file__])

0 commit comments

Comments
 (0)