@@ -464,18 +464,28 @@ class A2AStarletteRouter:
464464 the `build()` method.
465465 """
466466
467- def __init__ (self , agent_card : AgentCard , http_handler : RequestHandler ):
467+ def __init__ (
468+ self ,
469+ agent_card : AgentCard ,
470+ http_handler : RequestHandler ,
471+ agent_card_path : str = '/agent.json' ,
472+ rpc_path : str = '/' ,
473+ ):
468474 """Initializes the A2AStarletteRouter.
469475
470476 Args:
471477 agent_card: The AgentCard describing the agent's capabilities.
472478 http_handler: The handler instance responsible for processing A2A
473479 requests via http.
480+ agent_card_path: The URL path for the agent card endpoint.
481+ rpc_path: The URL path for the A2A JSON-RPC endpoint (POST requests).
474482 """
475483 self .agent_card = agent_card
476484 self .handler = JSONRPCHandler (
477485 agent_card = agent_card , request_handler = http_handler
478486 )
487+ self .agent_card_path = agent_card_path
488+ self .rpc_path = rpc_path
479489
480490 def _generate_error_response (
481491 self , request_id : str | int | None , error : JSONRPCError | A2AError
@@ -698,29 +708,21 @@ async def _handle_get_agent_card(self, request: Request) -> JSONResponse:
698708 self .agent_card .model_dump (mode = 'json' , exclude_none = True )
699709 )
700710
701- def routes (
702- self ,
703- agent_card_path : str = '/agent.json' ,
704- rpc_path : str = '/' ,
705- ) -> list [Route ]:
711+ def routes (self ) -> list [Route ]:
706712 """Returns the Starlette Routes for handling A2A requests.
707713
708- Args:
709- agent_card_path: The URL path for the agent card endpoint.
710- rpc_path: The URL path for the A2A JSON-RPC endpoint (POST requests).
711-
712714 Returns:
713715 A list of Starlette Route objects.
714716 """
715717 return [
716718 Route (
717- rpc_path ,
719+ self . rpc_path ,
718720 self ._handle_requests ,
719721 methods = ['POST' ],
720722 name = 'a2a_handler' ,
721723 ),
722724 Route (
723- agent_card_path ,
725+ self . agent_card_path ,
724726 self ._handle_get_agent_card ,
725727 methods = ['GET' ],
726728 name = 'agent_card' ,
0 commit comments