-
Notifications
You must be signed in to change notification settings - Fork 395
Description
Duplicated well-known agent card handler
JSON-RPC and REST transports are defined via separate "apps" each including well-known agent card handler, supporting them both on one instance requires manual work for serving agent card at well-known path as otherwise it'd be registered twice under transport specific routes. In 0.3 the code serializing agent card for a well-known path is also different: JSON-RPC one uses JSON Schema based model and REST uses ProtoJSON, so depending on which app is used one gets different agent card format - it may not manifest itself for simple agent cards, example of the difference: a2aproject/a2a-js#344.
Current approach also doesn't support gRPC well, if one wants to serve agent card without any other HTTP based transports and only use gRPC.
FastAPI and Starlette
There is also independent FastAPI and Starlette code (likely due to OpenAPI UI integration in FastAPI, but with proto-based types it doesn't work out of the box either way). The logic is fragmented across different concepts which are not symmetric across transports: adapters, handlers and applications.
JSON-RPC
JSONRPCApplicationjsonrpc_app.py- base class for both FastAPI and Starlette, operates on Starlette data model, parses incoming request into JSON-RPC data model and invokes appropriate methods ofJSONRPCHandler(see below).A2AFastAPIApplicationfastapi_app.py- FastAPI implementation of the above. Hasbuildto create an app oradd_routes_to_appto update existing instance created externally.A2AStarletteApplicationstarlette_app.py- Starlette implementation of the above.JSONRPCHandlerjsonrpc_handler.py- operates on A2A data model for input and usesdictas output, doesn't have a dependency on starlette, invokes domain transport agnosticRequestHandler.
HTTP+JSON/REST
A2ARESTFastAPIApplicationfastapi_app.py- this one only has FastAPI app unlike JSON-RPC, also it doesn't haveadd_routes_to_app, but it still has agent card handler (see the first section), usesRESTAdapter(see below).RESTAdapterrest_adapter.py- operates on Starlette data model and contains some request routing, parsing and error shaping logic, usesRESTHandler(see below).RESTHandlerrest_handler.py- operates on Starlette data model and parses request into A2A data model, invokes domain transport agnosticRequestHandler.