Skip to content
7 changes: 3 additions & 4 deletions src/a2a/compat/v0_3/rest_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def event_generator(
)

async def handle_get_agent_card(
self, request: Request, call_context: ServerCallContext | None = None
self, request: Request, call_context: ServerCallContext
) -> dict[str, Any]:
"""Handles GET requests for the agent card endpoint."""
card_to_serve = self.agent_card
Expand All @@ -119,7 +119,7 @@ async def handle_get_agent_card(
return v03_card.model_dump(mode='json', exclude_none=True)

async def handle_authenticated_agent_card(
self, request: Request, call_context: ServerCallContext | None = None
self, request: Request, call_context: ServerCallContext
) -> dict[str, Any]:
"""Hook for per credential agent card response."""
if not self.agent_card.capabilities.extended_agent_card:
Expand All @@ -132,9 +132,8 @@ async def handle_authenticated_agent_card(
card_to_serve = self.agent_card

if self.extended_card_modifier:
context = self._context_builder.build(request)
card_to_serve = await maybe_await(
self.extended_card_modifier(card_to_serve, context)
self.extended_card_modifier(card_to_serve, call_context)
)
elif self.card_modifier:
card_to_serve = await maybe_await(self.card_modifier(card_to_serve))
Expand Down
4 changes: 2 additions & 2 deletions src/a2a/server/routes/jsonrpc_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ def __init__( # noqa: PLR0913
extended_agent_card: An optional, distinct AgentCard to be served
at the authenticated extended card endpoint.
context_builder: The CallContextBuilder used to construct the
ServerCallContext passed to the request_handler. If None, no
ServerCallContext is passed.
ServerCallContext passed to the request_handler. If None the
DefaultCallContextBuilder is used.
card_modifier: An optional callback to dynamically modify the public
agent card before it is served.
extended_card_modifier: An optional callback to dynamically modify
Expand Down
4 changes: 2 additions & 2 deletions src/a2a/server/routes/jsonrpc_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def create_jsonrpc_routes( # noqa: PLR0913
extended_agent_card: An optional, distinct AgentCard to be served
at the authenticated extended card endpoint.
context_builder: The CallContextBuilder used to construct the
ServerCallContext passed to the request_handler. If None, no
ServerCallContext is passed.
ServerCallContext passed to the request_handler. If None the
DefaultCallContextBuilder is used.
card_modifier: An optional callback to dynamically modify the public
agent card before it is served.
extended_card_modifier: An optional callback to dynamically modify
Expand Down
10 changes: 4 additions & 6 deletions src/a2a/server/routes/rest_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def create_rest_routes( # noqa: PLR0913
extended_agent_card: An optional, distinct AgentCard to be served
at the authenticated extended card endpoint.
context_builder: The CallContextBuilder used to construct the
ServerCallContext passed to the request_handler. If None, no
ServerCallContext is passed.
ServerCallContext passed to the request_handler. If None the
DefaultCallContextBuilder is used.
card_modifier: An optional callback to dynamically modify the public
agent card before it is served.
extended_card_modifier: An optional callback to dynamically modify
Expand Down Expand Up @@ -176,7 +176,7 @@ async def event_generator() -> AsyncIterator[str]:
return EventSourceResponse(event_generator())

async def _handle_authenticated_agent_card(
request: 'Request', call_context: ServerCallContext | None = None
request: 'Request', call_context: ServerCallContext
) -> dict[str, Any]:
if not agent_card.capabilities.extended_agent_card:
raise ExtendedAgentCardNotConfiguredError(
Expand All @@ -185,10 +185,8 @@ async def _handle_authenticated_agent_card(
card_to_serve = extended_agent_card or agent_card

if extended_card_modifier:
# Re-generate context if none passed to replicate RESTAdapter exact logic
context = call_context or _build_call_context(request)
card_to_serve = await maybe_await(
extended_card_modifier(card_to_serve, context)
extended_card_modifier(card_to_serve, call_context)
)
elif card_modifier:
card_to_serve = await maybe_await(card_modifier(card_to_serve))
Expand Down
Loading