@@ -1018,12 +1018,45 @@ async def internal_lifespan(app: FastAPI):
10181018 allowed_origin_regex = compiled_origin_regex ,
10191019 )
10201020
1021- @app .get ("/health" )
1021+ @app .get (
1022+ "/health" ,
1023+ summary = "Health check" ,
1024+ response_description = "Basic liveness check for the API server." ,
1025+ responses = {
1026+ 500 : {"description" : "Internal server error." },
1027+ },
1028+ )
10221029 async def health () -> dict [str , str ]:
1030+ """Check whether the API server is running.
1031+
1032+ **Returns**
1033+ - `dict[str, str]`: A small status payload.
1034+
1035+ **Errors**
1036+ - `500 Internal Server Error`: Unexpected internal error.
1037+ """
10231038 return {"status" : "ok" }
10241039
1025- @app .get ("/version" )
1040+ @app .get (
1041+ "/version" ,
1042+ summary = "Get version information" ,
1043+ response_description = "Version information for ADK and Python runtime." ,
1044+ responses = {
1045+ 500 : {"description" : "Internal server error." },
1046+ },
1047+ )
10261048 async def version () -> dict [str , str ]:
1049+ """Return version information for the server runtime.
1050+
1051+ **Returns**
1052+ - `dict[str, str]`: Version metadata containing:
1053+ - `version`: ADK package version.
1054+ - `language`: Always `python`.
1055+ - `language_version`: Python runtime version.
1056+
1057+ **Errors**
1058+ - `500 Internal Server Error`: Unexpected internal error.
1059+ """
10271060 return {
10281061 "version" : __version__ ,
10291062 "language" : "python" ,
@@ -1032,12 +1065,35 @@ async def version() -> dict[str, str]:
10321065 ),
10331066 }
10341067
1035- @app .get ("/list-apps" )
1068+ @app .get (
1069+ "/list-apps" ,
1070+ response_model_exclude_none = True ,
1071+ summary = "List available apps" ,
1072+ response_description = (
1073+ "Either a list of app names, or detailed app information when"
1074+ " detailed=true."
1075+ ),
1076+ responses = {
1077+ 500 : {"description" : "Internal server error." },
1078+ },
1079+ )
10361080 async def list_apps (
10371081 detailed : bool = Query (
10381082 default = False , description = "Return detailed app information"
10391083 )
10401084 ) -> list [str ] | ListAppsResponse :
1085+ """List the apps available to the server.
1086+
1087+ **Query parameters**
1088+ - `detailed` (optional): When true, returns structured app metadata.
1089+
1090+ **Returns**
1091+ - `list[str]`: App names when `detailed` is false.
1092+ - `ListAppsResponse`: App metadata when `detailed` is true.
1093+
1094+ **Errors**
1095+ - `500 Internal Server Error`: Unexpected internal error.
1096+ """
10411097 if detailed :
10421098 apps_info = self .agent_loader .list_agents_detailed ()
10431099 return ListAppsResponse (apps = [AppInfo (** app ) for app in apps_info ])
@@ -2442,7 +2498,32 @@ async def patch_memory(
24422498 },
24432499 )
24442500 async def run_agent (req : RunAgentRequest ) -> list [Event ]:
2445- """Run an agent against a session and return all generated events."""
2501+ """Run an agent against a session and return all generated events.
2502+
2503+ This endpoint runs the app identified by `req.app_name` using the
2504+ provided session identifiers. Events are returned as a list after the
2505+ invocation finishes.
2506+
2507+ **Request body**
2508+ - `req.app_name`: Application name to run.
2509+ - `req.user_id`: User ID that owns the session.
2510+ - `req.session_id`: Session ID to run against.
2511+ - `req.new_message` (optional): New user message to append before
2512+ running. If provided without a role, it is treated as a user message.
2513+ - `req.state_delta` (optional): Session state changes to apply before
2514+ running.
2515+ - `req.invocation_id` (optional): Invocation ID to resume (resumable
2516+ apps only). Either `new_message` or `invocation_id` must be provided.
2517+
2518+ **Returns**
2519+ - `list[Event]`: Ordered events generated for the invocation.
2520+
2521+ **Errors**
2522+ - `404 Not Found`: Session not found when the runner is not configured
2523+ to auto-create sessions.
2524+ - `422 Unprocessable Entity`: Invalid request payload.
2525+ - `500 Internal Server Error`: Unexpected internal error.
2526+ """
24462527 runner = await self .get_runner_async (req .app_name )
24472528 try :
24482529 async with Aclosing (
@@ -2475,7 +2556,38 @@ async def run_agent(req: RunAgentRequest) -> list[Event]:
24752556 },
24762557 )
24772558 async def run_agent_sse (req : RunAgentRequest ) -> StreamingResponse :
2478- """Run an agent and stream generated events using SSE."""
2559+ """Run an agent and stream generated events using server-sent events.
2560+
2561+ This endpoint streams events as they are generated using the
2562+ `text/event-stream` media type. Each SSE message is formatted as:
2563+ `data: <json>\n \n `, where `<json>` is an `Event` serialized with camelCase
2564+ field names.
2565+
2566+ **Request body**
2567+ - `req.app_name`: Application name to run.
2568+ - `req.user_id`: User ID that owns the session.
2569+ - `req.session_id`: Session ID to run against.
2570+ - `req.new_message` (optional): New user message to append before
2571+ running.
2572+ - `req.state_delta` (optional): Session state changes to apply before
2573+ running.
2574+ - `req.invocation_id` (optional): Invocation ID to resume (resumable
2575+ apps only).
2576+ - `req.streaming` (optional): Controls the runner streaming mode. The
2577+ response itself is always SSE.
2578+ - `req.function_call_event_id` (optional): When omitted, some artifact
2579+ updates may be split into two SSE events (content-only and action-only)
2580+ to match the ADK Web UI rendering behavior.
2581+
2582+ **Returns**
2583+ - `StreamingResponse`: SSE stream of `Event` payloads.
2584+
2585+ **Errors**
2586+ - `404 Not Found`: Session not found when the runner is not configured
2587+ to auto-create sessions.
2588+ - `422 Unprocessable Entity`: Invalid request payload.
2589+ - `500 Internal Server Error`: Unexpected internal error.
2590+ """
24792591 stream_mode = StreamingMode .SSE if req .streaming else StreamingMode .NONE
24802592 runner = await self .get_runner_async (req .app_name )
24812593
0 commit comments