|
12 | 12 | from starlette.responses import JSONResponse, Response |
13 | 13 | from starlette.routing import Route |
14 | 14 |
|
| 15 | +from a2a.server.context import ServerCallContext |
15 | 16 | from a2a.server.request_handlers.jsonrpc_handler import JSONRPCHandler |
16 | 17 | from a2a.server.request_handlers.request_handler import RequestHandler |
17 | | -from a2a.server.context import ServerCallContext |
18 | | -from a2a.types import ( |
19 | | - A2AError, |
20 | | - A2ARequest, |
21 | | - AgentCard, |
22 | | - CancelTaskRequest, |
23 | | - GetTaskPushNotificationConfigRequest, |
24 | | - GetTaskRequest, |
25 | | - InternalError, |
26 | | - InvalidRequestError, |
27 | | - JSONParseError, |
28 | | - JSONRPCError, |
29 | | - JSONRPCErrorResponse, |
30 | | - JSONRPCResponse, |
31 | | - SendMessageRequest, |
32 | | - SendStreamingMessageRequest, |
33 | | - SendStreamingMessageResponse, |
34 | | - SetTaskPushNotificationConfigRequest, |
35 | | - TaskResubscriptionRequest, |
36 | | - UnsupportedOperationError, |
37 | | -) |
| 18 | +from a2a.types import (A2AError, A2ARequest, AgentCard, CancelTaskRequest, |
| 19 | + GetTaskPushNotificationConfigRequest, GetTaskRequest, |
| 20 | + InternalError, InvalidRequestError, JSONParseError, |
| 21 | + JSONRPCError, JSONRPCErrorResponse, JSONRPCResponse, |
| 22 | + SendMessageRequest, SendStreamingMessageRequest, |
| 23 | + SendStreamingMessageResponse, |
| 24 | + SetTaskPushNotificationConfigRequest, |
| 25 | + TaskResubscriptionRequest, UnsupportedOperationError) |
38 | 26 | from a2a.utils.errors import MethodNotImplementedError |
39 | 27 |
|
40 | 28 | logger = logging.getLogger(__name__) |
@@ -80,6 +68,13 @@ def __init__( |
80 | 68 | self.handler = JSONRPCHandler( |
81 | 69 | agent_card=agent_card, request_handler=http_handler |
82 | 70 | ) |
| 71 | + if ( |
| 72 | + self.agent_card.supportsAuthenticatedExtendedCard |
| 73 | + and self.extended_agent_card is None |
| 74 | + ): |
| 75 | + logger.error( |
| 76 | + 'AgentCard.supportsAuthenticatedExtendedCard is True, but no extended_agent_card was provided. The /agent/authenticatedExtendedCard endpoint will return 404.' |
| 77 | + ) |
83 | 78 | self._context_builder = context_builder |
84 | 79 |
|
85 | 80 | def _generate_error_response( |
@@ -345,10 +340,12 @@ async def _handle_get_authenticated_extended_agent_card( |
345 | 340 | mode='json', exclude_none=True |
346 | 341 | ) |
347 | 342 | ) |
348 | | - # Otherwise, if supportsAuthenticatedExtendedCard is true but no specific |
349 | | - # extended card is set, serve the main agent_card. |
| 343 | + # If supportsAuthenticatedExtendedCard is true, but no specific |
| 344 | + # extended_agent_card was provided during server initialization, |
| 345 | + # return a 404 |
350 | 346 | return JSONResponse( |
351 | | - self.agent_card.model_dump(mode='json', exclude_none=True) |
| 347 | + {'error': 'Authenticated extended agent card is supported but not configured on the server.'}, |
| 348 | + status_code=404, |
352 | 349 | ) |
353 | 350 |
|
354 | 351 | def routes( |
|
0 commit comments