Skip to content

armgit / ax

Public Imported from GitHub
0

Agent Executor (AX) is Google's open agentic orchestration runtime

Go

Introduce ATE agents (#213)

Jaana Dogan392a19e7e5f2
diff --git a/Makefile b/Makefile
index d13ff55..0d3f575 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: all build proto test clean install
+.PHONY: all build proto test clean install install-ate
# Build all binaries
all: proto build
@@ -46,6 +46,12 @@ install:
@go install ./cmd/ax
@echo "Install complete!"
+# Install ax with ATE support to GOPATH/bin
+install-ate:
+ @echo "Installing ax with ATE support..."
+ @go install -tags ate ./cmd/ax
+ @echo "Install complete!"
+
# Run remote agent example
run-remote:
diff --git a/cmd/ax/serve.go b/cmd/ax/serve.go
index 3cfffad..74369ce 100644
--- a/cmd/ax/serve.go
+++ b/cmd/ax/serve.go
@@ -146,5 +146,12 @@ func newControllerFromConfig(ctx context.Context, cfg *config.Config) (*controll
return nil, fmt.Errorf("failed to register colab agent %s: %w", agentCfg.ID, err)
}
}
+
+ for _, agentCfg := range cfg.Registry.ATEAgents {
+ if err := c.Registry().RegisterATE(ctx, cfg.ATE.Endpoint, agentCfg); err != nil {
+ return nil, fmt.Errorf("failed to register ATE agent %s: %w", agentCfg.ID, err)
+ }
+ }
+
return c, nil
}
diff --git a/internal/agent/ate.go b/internal/agent/ate.go
new file mode 100644
index 0000000..b3edd6e
--- /dev/null
+++ b/internal/agent/ate.go
@@ -0,0 +1,114 @@
+//go:build ate
+
+// Copyright 2026 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package agent
+
+import (
+ "context"
+ "fmt"
+ "log"
+ "time"
+
+ "github.com/google/ax/internal/ate"
+ "github.com/google/ax/proto"
+)
+
+// ATEAgent manages execution in a SubstrATE actor.
+type ATEAgent struct {
+ ateClient *ate.Client
+ config ATEAgentConfig
+}
+
+// ATEAgentConfig configures an ATE agent client.
+type ATEAgentConfig struct {
+ Namespace string
+ Template string
+ Port int // Port where agent runs in the worker
+}
+
+// NewATEAgent creates a new ATE agent client.
+func NewATEAgent(endpoint string, config ATEAgentConfig) (*ATEAgent, error) {
+ if config.Port == 0 {
+ config.Port = 8494 // Default port
+ }
+ client, err := ate.NewClient(config.Namespace, config.Template, endpoint)
+ if err != nil {
+ return nil, fmt.Errorf("failed to create ATE client: %w", err)
+ }
+ return &ATEAgent{
+ ateClient: client,
+ config: config,
+ }, nil
+}
+
+// Connect handles processing of input content by creating an actor and delegating to RemoteAgent.
+func (a *ATEAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {
+ // 1. Create Actor
+ resp, err := a.ateClient.CreateActor(ctx, execID)
+ if err != nil {
+ return fmt.Errorf("failed to create actor: %w", err)
+ }
+ actor := resp.Actor
+ if actor == nil {
+ return fmt.Errorf("received nil actor in response")
+ }
+ worker := actor.ActiveWorker
+ if worker == nil {
+ return fmt.Errorf("actor has no active worker")
+ }
+ if worker.Ip == "" {
+ return fmt.Errorf("worker has no IP address")
+ }
+
+ remoteAddr := fmt.Sprintf("%s:%d", worker.Ip, a.config.Port)
+ remoteAgent, err := NewRemoteAgent(RemoteAgentConfig{
+ Address: remoteAddr,
+ Reconnect: true,
+ MaxRetries: 3,
+ })
+ if err != nil {
+ return fmt.Errorf("failed to create remote agent connection: %w", err)
+ }
+ defer remoteAgent.Close()
+
+ // 3. Suspend Actor when done.
+ defer func() {
+ // TODO(jbd): Actors need to be deleted when they are done.
+ // DeleteActor once deletion is possible. For now, suspending allows
+ // us to return the worker back to the pool.
+ log.Printf("Suspending ATE actor for execution %s", execID)
+ suspendCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ if _, err := a.ateClient.SuspendActor(suspendCtx, execID); err != nil {
+ log.Printf("Failed to suspend actor %s: %v", execID, err)
+ }
+ }()
+
+ return remoteAgent.Connect(ctx, execID, start, e, o)
+}
+
+// HealthCheck checks if the ATE agent is healthy.
+func (a *ATEAgent) HealthCheck(ctx context.Context) error {
+ return nil
+}
+
+// Close gracefully shuts down the ATE agent connection.
+func (a *ATEAgent) Close() error {
+ if a.ateClient != nil {
+ return a.ateClient.Close()
+ }
+ return nil
+}
diff --git a/internal/ate/client.go b/internal/ate/client.go
index 0a14c1e..6db289a 100644
--- a/internal/ate/client.go
+++ b/internal/ate/client.go
@@ -22,6 +22,7 @@ import (
"github.com/ai-on-gke/SubstrATE/proto/ateapipb"
"google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
)
type Client struct {
@@ -41,6 +42,9 @@ func NewClient(ns, template, target string, opts ...grpc.DialOption) (*Client, e
if target == "" {
target = "api.ate-system.svc:443"
}
+ if len(opts) == 0 {
+ opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
+ }
conn, err := grpc.NewClient(target, opts...)
if err != nil {
return nil, fmt.Errorf("error when creating Control client: %w", err)
diff --git a/internal/config/config.go b/internal/config/config.go
index a57989e..c8abbc9 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -29,6 +29,7 @@ type Config struct {
EventLog EventLogConfig `yaml:"eventlog"`
Planner PlannerConfig `yaml:"planner,omitempty"`
Registry RegistryConfig `yaml:"registry,omitempty"`
+ ATE ATEConfig `yaml:"ate,omitempty"`
}
// RegistryConfig allows registring agents.
@@ -36,6 +37,12 @@ type RegistryConfig struct {
RemoteAgents []RemoteAgentConfig `yaml:"remote_agents,omitempty"`
KubernetesSandboxAgents []SandboxAgentConfig `yaml:"k8s_sandbox_agents,omitempty"`
ColabAgents []ColabAgentConfig `yaml:"colab_agents,omitempty"`
+ ATEAgents []ATEAgentConfig `yaml:"ate_agents,omitempty"`
+}
+
+// ATEConfig configures the ATE integration.
+type ATEConfig struct {
+ Endpoint string `yaml:"endpoint"`
}
// ServerConfig configures the gRPC server.
@@ -69,10 +76,16 @@ type GeminiPlannerConfig struct {
SkillsDir string `yaml:"skills_dir,omitempty"` // Directory to discover skills from
}
-// ActorConfig represents actor configuration.
-type ActorConfig struct {
- Namespace string `yaml:"namespace"` // Actor namespace
- Template string `yaml:"template"` // Actor template name
+// ATEAgentConfig allows registering a new agent with an ATE actor template.
+type ATEAgentConfig struct {
+ ID string `yaml:"id"` // Unique agent identifier
+ Name string `yaml:"name"` // Human-readable name
+ Description string `yaml:"description"` // Description of agent capabilities
+ Port int `yaml:"port"` // Port the agent is listening on
+ Namespace string `yaml:"namespace"` // Namespace for actor
+ Template string `yaml:"template"` // Template for actor
+ Metadata map[string]string `yaml:"metadata,omitempty"` // Optional metadata
+ // TODO(jbd): Rename this struct before releasing.
}
// RemoteAgentConfig configures a remote agent to register on startup.
@@ -82,7 +95,6 @@ type RemoteAgentConfig struct {
Description string `yaml:"description"` // Description of agent capabilities
Address string `yaml:"address"` // gRPC address (e.g., "localhost:50051")
Metadata map[string]string `yaml:"metadata,omitempty"` // Optional metadata
- Actor ActorConfig `yaml:"actor,omitempty"`
}
// SandboxAgentConfig configures a Kubernetes Sandbox agent to register on startup.
diff --git a/internal/controller/registry.go b/internal/controller/registry.go
index ea9c323..942144d 100644
--- a/internal/controller/registry.go
+++ b/internal/controller/registry.go
@@ -23,22 +23,13 @@ import (
"github.com/google/ax/internal/config"
)
-// AgentType represents the type of agent (local or remote).
-type AgentType string
-
-const (
- AgentTypeLocal AgentType = "local"
- AgentTypeRemote AgentType = "remote"
- AgentTypeKubernetesSandbox AgentType = "k8s_sandbox"
- AgentTypeColab AgentType = "colab"
-)
+
// AgentInfo contains metadata about a registered agent.
type AgentInfo struct {
ID string
Name string
Description string
- Type AgentType
Metadata map[string]string
}
@@ -83,7 +74,6 @@ func (r *Registry) RegisterLocal(cfg config.LocalAgentConfig) error {
ID: cfg.ID,
Name: cfg.Name,
Description: cfg.Description,
- Type: AgentTypeLocal,
Metadata: cfg.Metadata,
}
@@ -118,7 +108,6 @@ func (r *Registry) RegisterRemote(cfg config.RemoteAgentConfig) error {
ID: cfg.ID,
Name: cfg.Name,
Description: cfg.Description,
- Type: AgentTypeRemote,
Metadata: cfg.Metadata,
}
@@ -153,7 +142,6 @@ func (r *Registry) RegisterKubernetesSandbox(ctx context.Context, cfg config.San
ID: cfg.ID,
Name: cfg.Name,
Description: cfg.Description,
- Type: AgentTypeKubernetesSandbox,
Metadata: cfg.Metadata,
}
@@ -194,7 +182,6 @@ func (r *Registry) RegisterColab(cfg config.ColabAgentConfig) error {
ID: cfg.ID,
Name: cfg.Name,
Description: cfg.Description,
- Type: AgentTypeColab,
Metadata: cfg.Metadata,
}
diff --git a/internal/controller/registry_ate.go b/internal/controller/registry_ate.go
new file mode 100644
index 0000000..52af058
--- /dev/null
+++ b/internal/controller/registry_ate.go
@@ -0,0 +1,59 @@
+//go:build ate
+
+// Copyright 2026 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package controller
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/google/ax/internal/agent"
+ "github.com/google/ax/internal/config"
+)
+
+// RegisterATE registers an ATE agent by creating an ATE agent client.
+func (r *Registry) RegisterATE(ctx context.Context, ateTarget string, cfg config.ATEAgentConfig) error {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+
+ if err := validateID(cfg.ID); err != nil {
+ return err
+ }
+
+ if _, ok := r.agents[cfg.ID]; ok {
+ return fmt.Errorf("agent %s already registered", cfg.ID)
+ }
+
+ // Create ATE agent client
+ ateAgent, err := agent.NewATEAgent(ateTarget, agent.ATEAgentConfig{
+ Namespace: cfg.Namespace,
+ Template: cfg.Template,
+ Port: cfg.Port,
+ })
+ if err != nil {
+ return fmt.Errorf("failed to create ATE agent: %w", err)
+ }
+
+ r.agents[cfg.ID] = ateAgent
+ r.agentInfo[cfg.ID] = &AgentInfo{
+ ID: cfg.ID,
+ Name: cfg.Name,
+ Description: cfg.Description,
+ Metadata: cfg.Metadata,
+ }
+
+ return nil
+}
diff --git a/internal/controller/registry_noate.go b/internal/controller/registry_noate.go
new file mode 100644
index 0000000..2991ee7
--- /dev/null
+++ b/internal/controller/registry_noate.go
@@ -0,0 +1,29 @@
+//go:build !ate
+
+// Copyright 2026 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package controller
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/google/ax/internal/config"
+)
+
+// RegisterATE returns an error stating that ATE support is not compiled in.
+func (r *Registry) RegisterATE(ctx context.Context, ateTarget string, cfg config.ATEAgentConfig) error {
+ return fmt.Errorf("ATE support not compiled in; rebuild with -tags ate")
+}
diff --git a/internal/examples/ate_agent/README.md b/internal/examples/ate_agent/README.md
new file mode 100644
index 0000000..dd863d2
--- /dev/null
+++ b/internal/examples/ate_agent/README.md
@@ -0,0 +1,27 @@
+# ATE Agents
+
+ATE agents are experimental, they can be removed or significantly
+changed any time.
+
+## Setup
+
+To install the manifests on your Kubernetes cluster, run:
+
+```bash
+export PROJECT_ID="YOUR_PROJECT_ID"
+export GCE_REGION="us-central1"
+export BUCKET_NAME="ate-agent-snapshots"
+
+gcloud storage buckets create --project=${PROJECT_ID} --location=${GCE_REGION} "gs://${BUCKET_NAME}" --uniform-bucket-level-access
+
+kubectl apply -f manifest.yaml
+```
+
+## Run AX with ATE
+
+```bash
+kubectl port-forward -n ate-system service/api '35601:443'
+
+make install-ate && \
+ ax --config-file ./internal/examples/ate_agent/ax.yaml --input "say hello world"
+```
diff --git a/internal/examples/ate_agent/ax.yaml b/internal/examples/ate_agent/ax.yaml
new file mode 100644
index 0000000..2b98a14
--- /dev/null
+++ b/internal/examples/ate_agent/ax.yaml
@@ -0,0 +1,38 @@
+# Copyright 2026 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+server:
+ address: ":8494"
+
+# Event log configuration
+eventlog:
+ sqlite:
+ filename: "eventlog/log.sqlite"
+
+planner:
+ gemini:
+ model: "gemini-3-flash-preview"
+ timeout: "60s"
+
+ate:
+ endpoint: "localhost:35601"
+
+registry:
+ ate_agents:
+ - id: "hello-world"
+ name: "Hello World"
+ description: "Responds with 'Hello World'"
+ port: 8494
+ namespace: "ate-agent-example"
+ template: "ate-agent-template"
diff --git a/internal/examples/ate_agent/main.go b/internal/examples/ate_agent/main.go
new file mode 100644
index 0000000..6d7d3af
--- /dev/null
+++ b/internal/examples/ate_agent/main.go
@@ -0,0 +1,109 @@
+// Copyright 2026 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "log"
+ "net"
+
+ "google.golang.org/grpc"
+
+ "github.com/google/ax/proto"
+)
+
+const port = ":8494" // Default port for ATE agent worker
+
+// server implements the AgentService gRPC server.
+type server struct {
+ proto.UnimplementedAgentServiceServer
+}
+
+// Connect implements bidirectional streaming for agent processing.
+func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, proto.AgentMessage]) error {
+ for {
+ incoming, err := stream.Recv()
+ if err == io.EOF {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+
+ start := incoming.GetStart()
+ if start == nil {
+ continue
+ }
+
+ msg := &proto.Message{
+ Role: "assistant",
+ Content: &proto.Content{
+ Type: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "Hello World",
+ },
+ },
+ },
+ }
+
+ if err := stream.Send(&proto.AgentMessage{
+ ExecId: incoming.ExecId,
+ Type: &proto.AgentMessage_Outputs{
+ Outputs: &proto.AgentOutputs{
+ Messages: []*proto.Message{msg},
+ },
+ },
+ }); err != nil {
+ return err
+ }
+
+ // Send AgentComplete to signal end of outputs.
+ if err := stream.Send(&proto.AgentMessage{
+ ExecId: incoming.ExecId,
+ Type: &proto.AgentMessage_Complete{
+ Complete: &proto.AgentComplete{},
+ },
+ }); err != nil {
+ return err
+ }
+ }
+}
+
+// HealthCheck checks if the agent is healthy.
+func (s *server) HealthCheck(ctx context.Context, req *proto.HealthCheckRequest) (*proto.HealthCheckResponse, error) {
+ log.Println("Health check requested")
+ return &proto.HealthCheckResponse{
+ Healthy: true,
+ Message: "ATE Agent is healthy",
+ }, nil
+}
+
+func main() {
+ fmt.Printf("Listening on port: %s\n", port)
+ lis, err := net.Listen("tcp", port)
+ if err != nil {
+ log.Fatalf("Failed to listen: %v", err)
+ }
+
+ grpcServer := grpc.NewServer()
+ proto.RegisterAgentServiceServer(grpcServer, &server{})
+
+ fmt.Println("\nATE Agent server is starting...")
+ if err := grpcServer.Serve(lis); err != nil {
+ log.Fatalf("Failed to serve: %v", err)
+ }
+}
diff --git a/internal/examples/ate_agent/manifest.yaml b/internal/examples/ate_agent/manifest.yaml
new file mode 100644
index 0000000..b098601
--- /dev/null
+++ b/internal/examples/ate_agent/manifest.yaml
@@ -0,0 +1,43 @@
+# Copyright 2026 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: ate-agent-example
+---
+apiVersion: ate.gke.io/v1alpha1
+kind: WorkerPool
+metadata:
+ name: ate-agent-workerpool
+ namespace: ate-agent-example
+spec:
+ replicas: 10
+ container:
+ image: ko://github.com/google/ax/internal/examples/ate_agent
+ ports:
+ - containerPort: 8494
+---
+apiVersion: ate.gke.io/v1alpha1
+kind: ActorTemplate
+metadata:
+ name: ate-agent-template
+ namespace: ate-agent-example
+spec:
+ workerPoolRef:
+ name: ate-agent-workerpool
+ snapshotsConfig:
+ location:
+ bucket: ate-agent-snapshots
+ folder: ate-agent-example