66from collections .abc import AsyncIterable
77
88import grpc
9+ import grpc .aio
910
1011import a2a .grpc .a2a_pb2_grpc as a2a_grpc
1112
1415from a2a .grpc import a2a_pb2
1516from a2a .server .context import ServerCallContext
1617from a2a .server .request_handlers .request_handler import RequestHandler
17- from a2a .types import (
18- AgentCard ,
19- TaskNotFoundError ,
20- )
18+ from a2a .types import AgentCard , TaskNotFoundError
2119from a2a .utils import proto_utils
2220from a2a .utils .errors import ServerError
2321from a2a .utils .helpers import validate , validate_async_generator
@@ -32,14 +30,14 @@ class CallContextBuilder(ABC):
3230 """A class for building ServerCallContexts using the Starlette Request."""
3331
3432 @abstractmethod
35- def build (self , context : grpc .ServicerContext ) -> ServerCallContext :
33+ def build (self , context : grpc .aio . ServicerContext ) -> ServerCallContext :
3634 """Builds a ServerCallContext from a gRPC Request."""
3735
3836
3937class DefaultCallContextBuilder (CallContextBuilder ):
4038 """A default implementation of CallContextBuilder."""
4139
42- def build (self , context : grpc .ServicerContext ) -> ServerCallContext :
40+ def build (self , context : grpc .aio . ServicerContext ) -> ServerCallContext :
4341 """Builds the ServerCallContext."""
4442 user = UnauthenticatedUser ()
4543 state = {}
@@ -301,7 +299,7 @@ async def GetAgentCard(
301299 return proto_utils .ToProto .agent_card (self .agent_card )
302300
303301 async def abort_context (
304- self , error : ServerError , context : grpc .ServicerContext
302+ self , error : ServerError , context : grpc .aio . ServicerContext
305303 ) -> None :
306304 """Sets the grpc errors appropriately in the context."""
307305 match error .error :
0 commit comments