Skip to content

armgit / ax

Public Imported from GitHub
0

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

Go

Move axharness service to the ax binary (#42)

Jaana Dogan3887ea5c69bf
diff --git a/Makefile b/Makefile
index f638a9a..15425d4 100644
--- a/Makefile
+++ b/Makefile
@@ -91,14 +91,10 @@ axepp-image:
@echo "Building axepp container image with ko..."
GOFLAGS="-tags=ate" ko build --base-import-paths ./cmd/axepp
-axharness-image:
- @echo "Building axharness container image with ko..."
- ko build --base-import-paths ./cmd/axharness
-
ax-shell-image:
# Used to debug ax servers within a cluster.
@echo "Building ax shell container image with ko using busybox..."
KO_DOCKER_REPO=$(KO_DOCKER_REPO)/ax-shell KO_DEFAULTBASEIMAGE=busybox:1.36 GOFLAGS="-tags=ate" ko build --base-import-paths ./cmd/ax
# Build all container images
-images: ax-image axepp-image axharness-image ax-shell-image
+images: ax-image axepp-image ax-shell-image
diff --git a/cmd/axharness/service.go b/cmd/ax/harness.go
similarity index 54%
rename from cmd/axharness/service.go
rename to cmd/ax/harness.go
index 76fe954..51c53eb 100644
--- a/cmd/axharness/service.go
+++ b/cmd/ax/harness.go
@@ -15,11 +15,62 @@
package main
import (
+ "fmt"
"io"
+ "log"
+ "net"
+ "os"
+ "os/signal"
+ "syscall"
"github.com/google/ax/proto"
+ "github.com/spf13/cobra"
+ "google.golang.org/grpc"
)
+var (
+ harnessPort int
+)
+
+var harnessCmd = &cobra.Command{
+ Use: "harness",
+ Short: "Run the harness gRPC server",
+ Hidden: true,
+ RunE: runHarness,
+}
+
+func init() {
+ harnessCmd.Flags().IntVar(&harnessPort, "port", 50053, "The port for the gRPC HarnessService to listen on")
+ rootCmd.AddCommand(harnessCmd)
+}
+
+func runHarness(cmd *cobra.Command, args []string) error {
+ lis, err := net.Listen("tcp", fmt.Sprintf(":%d", harnessPort))
+ if err != nil {
+ return fmt.Errorf("failed to listen on port :%d: %w", harnessPort, err)
+ }
+
+ // Start gRPC Server
+ grpcServer := grpc.NewServer()
+ harnessServer := NewHarnessServiceServer()
+ proto.RegisterHarnessServiceServer(grpcServer, harnessServer)
+
+ // Graceful shutdown handling
+ sigChan := make(chan os.Signal, 1)
+ signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
+ go func() {
+ <-sigChan
+ log.Println("\nReceived shutdown signal, stopping gRPC HarnessService server gracefully...")
+ grpcServer.GracefulStop()
+ }()
+
+ log.Printf("gRPC HarnessService listening on port :%d...\n", harnessPort)
+ if err := grpcServer.Serve(lis); err != nil {
+ return fmt.Errorf("failed to serve gRPC: %w", err)
+ }
+ return nil
+}
+
// HarnessServiceServer implements the gRPC proto.HarnessServiceServer interface.
type HarnessServiceServer struct {
proto.UnimplementedHarnessServiceServer
@@ -33,6 +84,8 @@ func NewHarnessServiceServer() *HarnessServiceServer {
// Connect implements the bidirectional gRPC streaming capability.
// It receives client inputs and responds only with "Hello world".
func (s *HarnessServiceServer) Connect(stream proto.HarnessService_ConnectServer) error {
+ // TODO: Connect will be implemented to serve the built in harnesses
+ // as an isolated actor.
for {
_, err := stream.Recv()
if err == io.EOF {
diff --git a/cmd/axharness/main.go b/cmd/axharness/main.go
deleted file mode 100644
index f4fbd3b..0000000
--- a/cmd/axharness/main.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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 (
- "flag"
- "fmt"
- "log"
- "net"
- "os"
- "os/signal"
- "syscall"
-
- "google.golang.org/grpc"
-
- "github.com/google/ax/proto"
-)
-
-var (
- port = flag.Int("port", 50053, "The port for the gRPC HarnessService to listen on")
-)
-
-func main() {
- flag.Parse()
-
- lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
- if err != nil {
- log.Fatalf("Failed to listen on port :%d: %v", *port, err)
- }
-
- // Start gRPC Server
- grpcServer := grpc.NewServer()
- harnessServer := NewHarnessServiceServer()
- proto.RegisterHarnessServiceServer(grpcServer, harnessServer)
-
- // Graceful shutdown handling
- sigChan := make(chan os.Signal, 1)
- signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
- go func() {
- <-sigChan
- log.Println("\nReceived shutdown signal, stopping gRPC HarnessService server gracefully...")
- grpcServer.GracefulStop()
- }()
-
- log.Printf("gRPC HarnessService listening on port :%d...\n", *port)
- if err := grpcServer.Serve(lis); err != nil {
- log.Fatalf("Failed to serve gRPC: %v", err)
- }
-}
diff --git a/internal/SUBSTRATE_REFACTOR_CLEANUPS.md b/internal/SUBSTRATE_REFACTOR_CLEANUPS.md
index 93de9f5..a53a103 100644
--- a/internal/SUBSTRATE_REFACTOR_CLEANUPS.md
+++ b/internal/SUBSTRATE_REFACTOR_CLEANUPS.md
@@ -1,6 +1,7 @@
* Make internal/manifests/ax-deployment2.yaml the new templated ax-deployment.yaml.tmpl.
* Remove harnesstest package.
* Update HarnessService with the actual protocol.
+* Implement the ax harness to serve AGY and other harnesses.
* Remove axepp.
* Remove ate build tag.
* Remove harnessHandler once Exec RPC is revisited.
diff --git a/internal/manifests/ax-deployment2.yaml b/internal/manifests/ax-deployment2.yaml
index 0a917c0..e8bf391 100644
--- a/internal/manifests/ax-deployment2.yaml
+++ b/internal/manifests/ax-deployment2.yaml
@@ -47,7 +47,8 @@ spec:
pauseImage: "gcr.io/gke-release/pause@sha256:bcbd57ba5653580ec647b16d8163cdd1112df3609129b01f912a8032e48265da"
containers:
- name: "axharness"
- image: ko://github.com/google/ax/cmd/axharness
+ image: ko://github.com/google/ax/cmd/ax
+ command: ["/ko-app/ax", "harness"]
ports:
- containerPort: 50053
snapshotsConfig: