66from a2a .server .apps import A2AStarletteApplication
77from a2a .server .request_handlers import DefaultRequestHandler
88from a2a .server .tasks import InMemoryTaskStore
9+ from a2a .utils .constants import AGENT_CARD_WELL_KNOWN_PATH
910from google .adk .a2a .executor .a2a_agent_executor import A2aAgentExecutor
1011from google .adk .a2a .utils .agent_card_builder import AgentCardBuilder
1112from google .adk .agents .base_agent import BaseAgent
1718from google .adk .sessions .in_memory_session_service import InMemorySessionService
1819from opentelemetry .instrumentation .starlette import StarletteInstrumentor
1920from starlette .applications import Starlette
20- from starlette .requests import Request
21- from starlette .responses import JSONResponse
22- from starlette .routing import Route
2321
2422from .callback_tracer_plugin import CallbackTracerPlugin
2523
2624
25+ class HealthCheckFilter (logging .Filter ):
26+ def filter (self , record : logging .LogRecord ) -> bool :
27+ # Check if the log message contains the well known path of the card, which is used for health checks
28+ return record .getMessage ().find (AGENT_CARD_WELL_KNOWN_PATH ) == - 1
29+
30+
2731def to_a2a (agent : BaseAgent ) -> Starlette :
2832 """Convert an ADK agent to a A2A Starlette application.
2933 This is an adaption of google.adk.a2a.utils.agent_to_a2a.
@@ -44,6 +48,10 @@ def to_a2a(agent: BaseAgent) -> Starlette:
4448 setup_adk_logger (log_level ) # type: ignore
4549 logger = logging .getLogger (__name__ )
4650
51+ # Filter out health check logs from uvicorn access logger
52+ uvicorn_access_logger = logging .getLogger ("uvicorn.access" )
53+ uvicorn_access_logger .addFilter (HealthCheckFilter ())
54+
4755 async def create_runner () -> Runner :
4856 """Create a runner for the agent."""
4957 return Runner (
@@ -65,10 +73,6 @@ async def create_runner() -> Runner:
6573
6674 request_handler = DefaultRequestHandler (agent_executor = agent_executor , task_store = task_store )
6775
68- # Add a simple health check endpoint for readiness/liveness probes
69- def health (_ : Request ) -> JSONResponse :
70- return JSONResponse (content = {"status" : "healthy" })
71-
7276 # Get the agent card URL from environment variable *only*
7377 # At this point, we don't know the applications port and the host is unknown when running in k8s or similar
7478 # A2A_AGENT_CARD_URL is deprecated but still supported for backwards compatibility
@@ -100,7 +104,7 @@ async def lifespan(app: Starlette) -> AsyncIterator[None]:
100104 yield
101105
102106 # Create a Starlette app that will be configured during startup
103- starlette_app = Starlette (lifespan = lifespan , routes = [ Route ( "/health" , health )] )
107+ starlette_app = Starlette (lifespan = lifespan )
104108
105109 # Instrument the Starlette app with OpenTelemetry
106110 StarletteInstrumentor ().instrument_app (starlette_app )
0 commit comments