1111from a2a .compat .v0_3 .grpc_handler import CompatGrpcHandler
1212from a2a .server .agent_execution .agent_executor import AgentExecutor
1313from a2a .server .agent_execution .context import RequestContext
14- from a2a .server .apps import A2ARESTFastAPIApplication
1514from a2a .server .events .event_queue import EventQueue
1615from a2a .server .request_handlers import GrpcHandler
1716from a2a .server .request_handlers .default_request_handler import (
1817 DefaultRequestHandler ,
1918)
20- from a2a .server .routes import create_agent_card_routes , create_jsonrpc_routes
19+ from a2a .server .routes import (
20+ create_agent_card_routes ,
21+ create_jsonrpc_routes ,
22+ create_rest_routes ,
23+ )
2124from a2a .server .tasks .inmemory_task_store import InMemoryTaskStore
2225from a2a .server .tasks .task_updater import TaskUpdater
2326from a2a .types import (
@@ -166,22 +169,22 @@ async def serve(
166169 AgentInterface (
167170 protocol_binding = 'JSONRPC' ,
168171 protocol_version = '1.0' ,
169- url = f'http://{ host } :{ port } /a2a/jsonrpc/ ' ,
172+ url = f'http://{ host } :{ port } /a2a/jsonrpc' ,
170173 ),
171174 AgentInterface (
172175 protocol_binding = 'JSONRPC' ,
173176 protocol_version = '0.3' ,
174- url = f'http://{ host } :{ port } /a2a/jsonrpc/ ' ,
177+ url = f'http://{ host } :{ port } /a2a/jsonrpc' ,
175178 ),
176179 AgentInterface (
177180 protocol_binding = 'HTTP+JSON' ,
178181 protocol_version = '1.0' ,
179- url = f'http://{ host } :{ port } /a2a/rest/ ' ,
182+ url = f'http://{ host } :{ port } /a2a/rest' ,
180183 ),
181184 AgentInterface (
182185 protocol_binding = 'HTTP+JSON' ,
183186 protocol_version = '0.3' ,
184- url = f'http://{ host } :{ port } /a2a/rest/ ' ,
187+ url = f'http://{ host } :{ port } /a2a/rest' ,
185188 ),
186189 ],
187190 )
@@ -191,25 +194,25 @@ async def serve(
191194 agent_executor = SampleAgentExecutor (), task_store = task_store
192195 )
193196
194- rest_app_builder = A2ARESTFastAPIApplication (
197+ rest_routes = create_rest_routes (
195198 agent_card = agent_card ,
196- http_handler = request_handler ,
199+ request_handler = request_handler ,
200+ path_prefix = '/a2a/rest' ,
197201 enable_v0_3_compat = True ,
198202 )
199- rest_app = rest_app_builder .build ()
200-
201203 jsonrpc_routes = create_jsonrpc_routes (
202204 agent_card = agent_card ,
203205 request_handler = request_handler ,
204- rpc_url = '/a2a/jsonrpc/' ,
206+ rpc_url = '/a2a/jsonrpc' ,
207+ enable_v0_3_compat = True ,
205208 )
206209 agent_card_routes = create_agent_card_routes (
207210 agent_card = agent_card ,
208211 )
209212 app = FastAPI ()
210213 app .routes .extend (jsonrpc_routes )
211214 app .routes .extend (agent_card_routes )
212- app .mount ( '/a2a/rest' , rest_app )
215+ app .routes . extend ( rest_routes )
213216
214217 grpc_server = grpc .aio .server ()
215218 grpc_server .add_insecure_port (f'{ host } :{ grpc_port } ' )
0 commit comments