Skip to content

Commit 4aae019

Browse files
committed
fix lint, self review comments, etc
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
1 parent a3acbba commit 4aae019

15 files changed

Lines changed: 41 additions & 26 deletions

File tree

go/adk/examples/byo/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import (
5050
"google.golang.org/adk/agent/llmagent"
5151
"google.golang.org/adk/agent/workflowagents/parallelagent"
5252
"google.golang.org/adk/runner"
53-
"google.golang.org/adk/server/adka2a"
53+
"google.golang.org/adk/server/adka2a" //nolint:staticcheck // TODO(0.11.0): migrate Go ADK runtime to adka2a/v2.
5454
adksession "google.golang.org/adk/session"
5555
)
5656

go/adk/pkg/a2a/agentcard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package a2a
33
import (
44
a2atype "github.com/a2aproject/a2a-go/a2a"
55
adkagent "google.golang.org/adk/agent"
6-
"google.golang.org/adk/server/adka2a"
6+
"google.golang.org/adk/server/adka2a" //nolint:staticcheck // TODO(0.11.0): migrate Go ADK runtime to adka2a/v2.
77
)
88

99
// EnrichAgentCard populates the agent card with skills derived from the ADK

go/adk/pkg/a2a/consts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package a2a
22

3-
import "google.golang.org/adk/server/adka2a"
3+
import "google.golang.org/adk/server/adka2a" //nolint:staticcheck // TODO(0.11.0): migrate Go ADK runtime to adka2a/v2.
44

55
const (
66
StateKeySessionName = "session_name"

go/adk/pkg/a2a/converter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"maps"
77

88
a2atype "github.com/a2aproject/a2a-go/a2a"
9-
"google.golang.org/adk/server/adka2a"
9+
"google.golang.org/adk/server/adka2a" //nolint:staticcheck // TODO(0.11.0): migrate Go ADK runtime to adka2a/v2.
1010
adksession "google.golang.org/adk/session"
1111
"google.golang.org/genai"
1212
)

go/adk/pkg/a2a/converter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66

77
a2atype "github.com/a2aproject/a2a-go/a2a"
8-
"google.golang.org/adk/server/adka2a"
8+
"google.golang.org/adk/server/adka2a" //nolint:staticcheck // TODO(0.11.0): migrate Go ADK runtime to adka2a/v2.
99
"google.golang.org/genai"
1010
)
1111

go/adk/pkg/a2a/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"go.opentelemetry.io/otel/attribute"
2020
adkagent "google.golang.org/adk/agent"
2121
"google.golang.org/adk/runner"
22-
"google.golang.org/adk/server/adka2a"
22+
"google.golang.org/adk/server/adka2a" //nolint:staticcheck // TODO(0.11.0): migrate Go ADK runtime to adka2a/v2.
2323
)
2424

2525
const (

go/core/internal/a2a/a2a_handler_mux.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package a2a
33
import (
44
"fmt"
55
"net/http"
6+
"slices"
67
"strings"
78
"sync"
89

@@ -59,7 +60,7 @@ func (a *handlerMux) SetAgentHandler(
5960
card a2atype.AgentCard,
6061
tracing middleware,
6162
) error {
62-
// TODO: Remove this in release 0.11.0 when all agents are migrated to v1
63+
// TODO(cleanup): Replace this protocol mux with the standard v1 handler stack once legacy clients/runtimes are unsupported.
6364
requestHandler := NewPassthroughRequestHandler(client, &card)
6465
legacyJSONRPCHandler := a2av0.NewJSONRPCHandler(requestHandler)
6566
v1JSONRPCHandler := a2asrv.NewJSONRPCHandler(requestHandler)
@@ -89,8 +90,8 @@ func (a *handlerMux) SetAgentHandler(
8990
if tracing != nil {
9091
middlewares = append(middlewares, tracing)
9192
}
92-
for i := len(middlewares) - 1; i >= 0; i-- {
93-
handler = middlewares[i].Wrap(handler)
93+
for _, middleware := range slices.Backward(middlewares) {
94+
handler = middleware.Wrap(handler)
9495
}
9596

9697
a.lock.Lock()

go/core/internal/a2a/a2a_registrar.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,15 @@ func (a *A2ARegistrar) upsertAgentHandler(ctx context.Context, agent v1alpha2.Ag
159159
httpClient := debugHTTPClient()
160160
client, err := a2aclient.NewFromEndpoints(
161161
ctx,
162-
// TODO: Switch this to 1.0 in release 0.11.0 when all agents are migrated to v1
162+
// TODO(0.11.0): Prefer A2A 1.0 interfaces by default once managed runtimes are v1-capable.
163+
// Keep legacy fallback during rollout so old agent pods continue to serve traffic.
163164
filterInterfacesByVersion(card.SupportedInterfaces, a2atype.ProtocolVersion("0.3")),
164165
a2aclient.WithJSONRPCTransport(httpClient),
165-
// TODO: Remove this in release 0.11.0 when all agents are migrated to v1
166+
// TODO(cleanup): Remove the compat transport after legacy runtimes are unsupported.
166167
a2aclient.WithCompatTransport(
167168
a2atype.ProtocolVersion("0.3"),
168169
a2atype.TransportProtocolJSONRPC,
170+
// This creates a legacy JSON-RPC transport that is used to forward traffic to agents that are still on the legacy A2A wire.
169171
a2aclient.TransportFactoryFn(func(_ context.Context, _ *a2atype.AgentCard, iface *a2atype.AgentInterface) (a2aclient.Transport, error) {
170172
return a2av0.NewJSONRPCTransport(a2av0.JSONRPCTransportConfig{
171173
URL: iface.URL,
@@ -224,6 +226,7 @@ func a2aRoutePath(agent v1alpha2.AgentObject) string {
224226
return routeKey(agent.GetWorkloadMode() == v1alpha2.WorkloadModeSandbox, agentRef.Namespace, agentRef.Name)
225227
}
226228

229+
// cloneInterfacesWithURL clones the interfaces and sets the URL to the given value.
227230
func cloneInterfacesWithURL(interfaces []*a2atype.AgentInterface, url string) []*a2atype.AgentInterface {
228231
if len(interfaces) == 0 {
229232
return []*a2atype.AgentInterface{
@@ -249,6 +252,8 @@ func cloneInterfacesWithURL(interfaces []*a2atype.AgentInterface, url string) []
249252
return result
250253
}
251254

255+
// filterInterfacesByVersion filters the interfaces to only include the ones that match the given version.
256+
// Currently, this is used to select the A2A 0.3 interface for managed agents.
252257
func filterInterfacesByVersion(interfaces []*a2atype.AgentInterface, version a2atype.ProtocolVersion) []*a2atype.AgentInterface {
253258
filtered := make([]*a2atype.AgentInterface, 0, len(interfaces))
254259
for _, i := range interfaces {

go/core/internal/a2a/passthrough_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/a2aproject/a2a-go/v2/a2asrv"
1010
)
1111

12+
// TODO(cleanup): once legacy traffic is unsupported, use the standard v1 handler
13+
// stack directly.
1214
type PassthroughRequestHandler struct {
1315
client *a2aclient.Client
1416
card *a2atype.AgentCard
@@ -21,8 +23,6 @@ var _ a2asrv.RequestHandler = (*PassthroughRequestHandler)(nil)
2123
// agent client and intentionally bypasses a2asrv.NewHandler, which would create
2224
// local task state and apply v1 task-processing invariants to legacy streams.
2325
// Keep this while the controller bridges mixed 0.3 and 1.0 clients/runtimes;
24-
// once all supported traffic is native v1, the controller can use the standard
25-
// v1 handler stack directly.
2626
func NewPassthroughRequestHandler(client *a2aclient.Client, card *a2atype.AgentCard) *PassthroughRequestHandler {
2727
return &PassthroughRequestHandler{
2828
client: client,

go/core/internal/controller/translator/agent/manifest_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (a *adkApiTranslator) buildConfigSecret(
149149
cfgJSON = string(bCfg)
150150
}
151151
if card != nil {
152-
// TODO: replace this with the v1 agent card producer in release 0.11.0
152+
// TODO(0.11.0): use the v1 agent card producer once managed runtimes no longer need legacy top-level fields.
153153
producer := a2av0.NewStaticAgentCardProducer(card)
154154
jsonProducer, ok := producer.(a2asrv.AgentCardJSONProducer)
155155
if !ok {

0 commit comments

Comments
 (0)