@@ -75,6 +75,7 @@ public class JSONRPCTransport implements ClientTransport {
7575 private final String agentUrl ;
7676 private final List <ClientCallInterceptor > interceptors ;
7777 private AgentCard agentCard ;
78+ private boolean needsExtendedCard = false ;
7879
7980 public JSONRPCTransport (String agentUrl ) {
8081 this (null , null , agentUrl , null );
@@ -90,6 +91,7 @@ public JSONRPCTransport(A2AHttpClient httpClient, AgentCard agentCard,
9091 this .agentCard = agentCard ;
9192 this .agentUrl = agentUrl ;
9293 this .interceptors = interceptors ;
94+ this .needsExtendedCard = agentCard == null || agentCard .supportsAuthenticatedExtendedCard ();
9395 }
9496
9597 @ Override
@@ -332,8 +334,9 @@ public AgentCard getAgentCard(ClientCallContext context) throws A2AClientExcepti
332334 if (agentCard == null ) {
333335 resolver = new A2ACardResolver (httpClient , agentUrl , null , getHttpHeaders (context ));
334336 agentCard = resolver .getAgentCard ();
337+ needsExtendedCard = agentCard .supportsAuthenticatedExtendedCard ();
335338 }
336- if (!agentCard . supportsAuthenticatedExtendedCard () ) {
339+ if (!needsExtendedCard ) {
337340 return agentCard ;
338341 }
339342
@@ -349,7 +352,9 @@ public AgentCard getAgentCard(ClientCallContext context) throws A2AClientExcepti
349352 String httpResponseBody = sendPostRequest (payloadAndHeaders );
350353 GetAuthenticatedExtendedCardResponse response = unmarshalResponse (httpResponseBody ,
351354 GET_AUTHENTICATED_EXTENDED_CARD_RESPONSE_REFERENCE );
352- return response .getResult ();
355+ agentCard = response .getResult ();
356+ needsExtendedCard = false ;
357+ return agentCard ;
353358 } catch (IOException | InterruptedException e ) {
354359 throw new A2AClientException ("Failed to get authenticated extended agent card: " + e , e );
355360 }
0 commit comments