@@ -49,20 +49,15 @@ class GrpcContextBuilder(ABC):
4949 def build (self , context : grpc .aio .ServicerContext ) -> ServerCallContext :
5050 """Builds a ServerCallContext from a gRPC ServicerContext."""
5151
52- @abstractmethod
53- def build_user (self , context : grpc .aio .ServicerContext ) -> User :
54- """Builds a User from a gRPC ServicerContext."""
55-
5652
5753class DefaultGrpcContextBuilder (GrpcContextBuilder ):
5854 """Default implementation of GrpcContextBuilder."""
5955
6056 def build (self , context : grpc .aio .ServicerContext ) -> ServerCallContext :
6157 """Builds a ServerCallContext from a gRPC ServicerContext."""
62- user = self .build_user (context )
6358 state = {'grpc_context' : context }
6459 return ServerCallContext (
65- user = user ,
60+ user = self . build_user ( context ) ,
6661 state = state ,
6762 requested_extensions = get_requested_extensions (
6863 _get_metadata_value (context , HTTP_EXTENSION_HEADER )
@@ -88,6 +83,7 @@ def _get_metadata_value(
8883 if k .lower () == lower_key
8984 ]
9085
86+
9187_ERROR_CODE_MAP = {
9288 types .InvalidRequestError : grpc .StatusCode .INVALID_ARGUMENT ,
9389 types .MethodNotFoundError : grpc .StatusCode .NOT_FOUND ,
@@ -125,8 +121,9 @@ def __init__(
125121 agent_card: The AgentCard describing the agent's capabilities.
126122 request_handler: The underlying `RequestHandler` instance to
127123 delegate requests to.
128- context_builder: Optional custom user builder to extract user from the
129- gRPC context.
124+ context_builder: The GrpcContextBuilder used to construct the
125+ ServerCallContext passed to the request_handler. If None the
126+ DefaultGrpcContextBuilder is used.
130127 card_modifier: An optional callback to dynamically modify the public
131128 agent card before it is served.
132129 """
0 commit comments