@@ -23,7 +23,6 @@ import (
2323
2424 a2atype "github.com/a2aproject/a2a-go/v2/a2a"
2525 a2aclient "github.com/a2aproject/a2a-go/v2/a2aclient"
26- "github.com/a2aproject/a2a-go/v2/a2aclient/agentcard"
2726 "github.com/kagent-dev/kagent/go/api/v1alpha2"
2827 "github.com/kagent-dev/kagent/go/core/internal/a2a"
2928 "github.com/kagent-dev/kagent/go/core/internal/utils"
@@ -232,6 +231,9 @@ func setupSandboxAgentWithOptions(t *testing.T, cli client.Client, modelConfigNa
232231 return agent
233232}
234233
234+ // newA2AClient creates a v2 A2A client targeting baseURL directly via JSON-RPC.
235+ // The controller always serves both wire versions at the agent's path prefix; the
236+ // A2A-Version header (default: 1.0) tells the mux which handler to use.
235237func newA2AClient (t * testing.T , baseURL string , httpClient * http.Client , headers map [string ]string ) * a2aclient.Client {
236238 t .Helper ()
237239 if httpClient == nil {
@@ -240,22 +242,22 @@ func newA2AClient(t *testing.T, baseURL string, httpClient *http.Client, headers
240242 if headers == nil {
241243 headers = map [string ]string {}
242244 }
243- if _ , ok := headers ["A2A-Version" ]; ! ok {
244- headers ["A2A-Version" ] = string (a2atype .Version )
245- }
246-
247- resolver := agentcard .NewResolver (httpClient )
248- resolveOpts := make ([]agentcard.ResolveOption , 0 , len (headers ))
249- for k , v := range headers {
250- resolveOpts = append (resolveOpts , agentcard .WithRequestHeader (k , v ))
251- }
252-
253- card , err := resolver .Resolve (t .Context (), baseURL , resolveOpts ... )
254- require .NoError (t , err )
245+ // TODO(0.11.0): Uncomment these lines to set v1 header after 0.11.0 to test v1 clients after migration
246+ // if _, ok := headers["A2A-Version"]; !ok {
247+ // headers["A2A-Version"] = string(a2atype.Version)
248+ // }
255249
256- a2aClient , err := a2aclient .NewFromCard (
250+ // Use NewFromEndpoints with the explicit base URL rather than NewFromCard:
251+ // the card's SupportedInterfaces contain the controller's internal cluster URL,
252+ // which is unreachable from the test machine via port-forward.
253+ endpointURL := strings .TrimRight (baseURL , "/" ) + "/"
254+ a2aClient , err := a2aclient .NewFromEndpoints (
257255 t .Context (),
258- card ,
256+ []* a2atype.AgentInterface {{
257+ URL : endpointURL ,
258+ ProtocolVersion : a2atype .Version ,
259+ ProtocolBinding : a2atype .TransportProtocolJSONRPC ,
260+ }},
259261 a2aclient .WithJSONRPCTransport (httpClient ),
260262 a2aclient .WithCallInterceptors (a2a .NewStaticHeadersInterceptor (headers )),
261263 )
0 commit comments