Skip to content

[Task]: Revisit server "apps" and handlers #797

@ishymko

Description

@ishymko

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

  • JSONRPCApplication jsonrpc_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 of JSONRPCHandler (see below).
  • A2AFastAPIApplication fastapi_app.py - FastAPI implementation of the above. Has build to create an app or add_routes_to_app to update existing instance created externally.
  • A2AStarletteApplication starlette_app.py - Starlette implementation of the above.
  • JSONRPCHandler jsonrpc_handler.py - operates on A2A data model for input and uses dict as output, doesn't have a dependency on starlette, invokes domain transport agnostic RequestHandler.

HTTP+JSON/REST

  • A2ARESTFastAPIApplication fastapi_app.py - this one only has FastAPI app unlike JSON-RPC, also it doesn't have add_routes_to_app, but it still has agent card handler (see the first section), uses RESTAdapter (see below).
  • RESTAdapter rest_adapter.py - operates on Starlette data model and contains some request routing, parsing and error shaping logic, uses RESTHandler (see below).
  • RESTHandler rest_handler.py - operates on Starlette data model and parses request into A2A data model, invokes domain transport agnostic RequestHandler.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions