Agent Executor (AX) is Google's open agentic orchestration runtime
Go
Remove harness test fallback and delete harnesstest package (#138)
Jaana Dogan75f7232a0d9c
diff --git a/cmd/e2e/main.go b/cmd/e2e/main.goindex 676cf32..b72cc94 100644--- a/cmd/e2e/main.go+++ b/cmd/e2e/main.go@@ -28,6 +28,7 @@ package mainimport ("context""fmt"+ "log""net""os""time"@@ -36,7 +37,6 @@ import ("github.com/google/ax/internal/controller/executor/executortest""github.com/google/ax/internal/controller2""github.com/google/ax/internal/harness"- "github.com/google/ax/internal/harness/harnesstest""github.com/google/ax/proto")@@ -47,10 +47,10 @@ func main() {fmt.Println("==================================================")// -------------------------------------------------------------------------- // Demo 1: Runtime Fallback (No harness registered)+ // Demo 1: Unregistered Harness (Should fail)// -------------------------------------------------------------------------- fmt.Println("\n--- Demo 1: Runtime Fallback ---")- fmt.Println("Requesting 'unregistered-agent'. Should fallback to Test Harness (Hello World).")+ fmt.Println("\n--- Demo 1: Unregistered Harness ---")+ fmt.Println("Requesting 'unregistered-agent'. Exec should fail since no harness is registered.")runDemo(ctx, "unregistered-agent", func(reg *controller2.Registry) {// Do not register any harness})@@ -66,18 +66,15 @@ func main() {runDemo(ctx, "antigravity", func(reg *controller2.Registry) {// With the new stateful gRPC-based streaming harness, connectivity checks on the// server address replace the build-time checks for local script file presence.- var realHarness harness.Harnessaddress := "localhost:50053"conn, err := net.DialTimeout("tcp", address, 1*time.Second)if err != nil {- fmt.Printf("WARNING: Antigravity harness server not active at %s, falling back to test harness: %v\n", address, err)- realHarness = harnesstest.New()- } else {- conn.Close()- fmt.Printf("Connected to Antigravity gRPC harness server at %s\n", address)- realHarness = harness.NewAntigravityHarness(address)+ log.Fatalf("Antigravity harness server not active at %s: %v", address, err)}- reg.RegisterHarness("antigravity", realHarness)+ conn.Close()+ fmt.Printf("Connected to Antigravity gRPC harness server at %s\n", address)+ harness := harness.NewAntigravityHarness(address)+ reg.RegisterHarness("antigravity", harness)})}diff --git a/internal/controller2/controller.go b/internal/controller2/controller.goindex 8701e7c..c40c299 100644--- a/internal/controller2/controller.go+++ b/internal/controller2/controller.go@@ -22,7 +22,6 @@ import ("log/slog""github.com/google/ax/internal/controller/executor"- "github.com/google/ax/internal/harness/harnesstest""github.com/google/ax/proto")@@ -74,13 +73,7 @@ func (d *Controller) Exec(ctx context.Context, req *proto.ExecRequest, handler E// Adding harness registration support temporarily.h, err := d.registry.Harness(req.AgentId)if err != nil {- // Fallback to test harness- slog.WarnContext(ctx, "Harness not found in registry, falling back to test harness",- slog.String("agent_id", req.AgentId),- slog.String("conversation_id", req.ConversationId),- slog.Any("error", err),- )- h = harnesstest.New()+ return fmt.Errorf("failed to get harness for agent %q: %w", req.AgentId, err)}exec, err := h.Start(ctx, req.ConversationId)if err != nil {diff --git a/internal/controller2/controller_test.go b/internal/controller2/controller_test.goindex 3bf5f33..f51fd3d 100644--- a/internal/controller2/controller_test.go+++ b/internal/controller2/controller_test.go@@ -16,22 +16,65 @@ package controller2import ("context"- "os""testing""github.com/google/ax/internal/controller/executor""github.com/google/ax/internal/controller/executor/executortest""github.com/google/ax/internal/harness"- "github.com/google/ax/internal/harness/harnesstest""github.com/google/ax/proto")+type fakeHarness struct{}++func (f *fakeHarness) Start(ctx context.Context, conversationID string) (harness.Execution, error) {+ return &fakeExecution{id: "fake-exec-id"}, nil+}++type fakeExecution struct {+ id string+ queued []*proto.Message+}++func (f *fakeExecution) ID() string {+ return f.id+}++func (f *fakeExecution) Queue(ctx context.Context, msg ...*proto.Message) error {+ f.queued = append(f.queued, msg...)+ return nil+}++func (f *fakeExecution) Run(ctx context.Context, handler harness.Handler) error {+ msg := &proto.Message{+ Role: "assistant",+ Content: &proto.Content{+ Type: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "Hello world",+ },+ },+ },+ }+ if err := handler.OnMessage(ctx, f.id, msg); err != nil {+ return err+ }+ return handler.OnComplete(ctx, f.id)+}++func (f *fakeExecution) Close(ctx context.Context) error {+ return nil+}+func TestController2_ExecHelloWorld(t *testing.T) {ctx := context.Background()cid := "test-conversation-id"log := &executortest.MemoryEventLog{}reg := NewRegistry()+ if err := reg.RegisterHarness("", &fakeHarness{}); err != nil {+ t.Fatal(err)+ }+c, err := New(ctx, Config{Registry: reg,EventLogBuilder: func() (executor.EventLog, error) {@@ -127,22 +170,13 @@ func TestController2_ExecHelloWorld(t *testing.T) {}}-func TestController2_ExecAntigravityFallback(t *testing.T) {+func TestController2_ExecWithAgentID(t *testing.T) {ctx := context.Background()cid := "test-conversation-id"log := &executortest.MemoryEventLog{}reg := NewRegistry()-- // Build and register harness with bad path to trigger build-time fallback- var badHarness harness.Harness- scriptPath := "non-existent-script.py"- if _, err := os.Stat(scriptPath); err != nil {- badHarness = harnesstest.New() // Fallback- } else {- badHarness = harness.NewAntigravityHarness(scriptPath)- }- if err := reg.RegisterHarness("antigravity", badHarness); err != nil {+ if err := reg.RegisterHarness("my-agent", &fakeHarness{}); err != nil {t.Fatal(err)}@@ -174,11 +208,10 @@ func TestController2_ExecAntigravityFallback(t *testing.T) {},}- // Request "antigravity" agenterr = c.Exec(ctx, &proto.ExecRequest{ConversationId: cid,+ AgentId: "my-agent",Inputs: inputs,- AgentId: "antigravity",}, handler)if err != nil {t.Fatalf("Controller2.Exec failed: %v", err)@@ -190,16 +223,16 @@ func TestController2_ExecAntigravityFallback(t *testing.T) {gotText := outputs[0].GetContent().GetText().GetText()if gotText != "Hello world" {- t.Errorf("expected 'Hello world' output text response due to fallback, got %q", gotText)+ t.Errorf("expected 'Hello world' output text response, got %q", gotText)}}-func TestController2_ExecRuntimeFallback(t *testing.T) {+func TestController2_ExecHarnessNotFound(t *testing.T) {ctx := context.Background()cid := "test-conversation-id"log := &executortest.MemoryEventLog{}- reg := NewRegistry() // Empty registry, will force runtime fallback for any requested agent+ reg := NewRegistry() // Empty registry, will force error for any requested agentc, err := New(ctx, Config{Registry: reg,@@ -212,9 +245,7 @@ func TestController2_ExecRuntimeFallback(t *testing.T) {}defer c.Close()- var outputs []*proto.Messagehandler := ExecHandler(func(resp *proto.ExecResponse) error {- outputs = append(outputs, resp.Outputs...)return nil})@@ -229,22 +260,12 @@ func TestController2_ExecRuntimeFallback(t *testing.T) {},}- // Request "antigravity" agent, which is NOT registerederr = c.Exec(ctx, &proto.ExecRequest{ConversationId: cid,Inputs: inputs,AgentId: "antigravity",}, handler)- if err != nil {- t.Fatalf("Controller2.Exec failed: %v", err)- }-- if len(outputs) != 1 {- t.Fatalf("expected exactly 1 output message, got %d", len(outputs))- }-- gotText := outputs[0].GetContent().GetText().GetText()- if gotText != "Hello world" {- t.Errorf("expected 'Hello world' output text response due to runtime fallback, got %q", gotText)+ if err == nil {+ t.Fatal("expected error requesting unregistered agent, got nil")}}diff --git a/internal/controller2/registry_test.go b/internal/controller2/registry_test.goindex 07d43ad..a52717a 100644--- a/internal/controller2/registry_test.go+++ b/internal/controller2/registry_test.go@@ -15,14 +15,21 @@package controller2import (+ "context""testing"- "github.com/google/ax/internal/harness/harnesstest"+ "github.com/google/ax/internal/harness")+type dummyHarness struct{}++func (d *dummyHarness) Start(ctx context.Context, conversationID string) (harness.Execution, error) {+ return nil, nil+}+func TestRegistry_RegisterHarness(t *testing.T) {r := NewRegistry()- h := harnesstest.New()+ h := &dummyHarness{}if err := r.RegisterHarness("antigravity", h); err != nil {t.Fatalf("RegisterHarness(valid id): %v", err)@@ -46,7 +53,7 @@ func TestRegistry_RegisterHarness(t *testing.T) {func TestRegistry_FindHarness(t *testing.T) {r := NewRegistry()- h := harnesstest.New()+ h := &dummyHarness{}if err := r.RegisterHarness("antigravity", h); err != nil {t.Fatalf("RegisterHarness: %v", err)}diff --git a/internal/harness/harnesstest/harnesstest.go b/internal/harness/harnesstest/harnesstest.godeleted file mode 100644index 874ee68..0000000--- a/internal/harness/harnesstest/harnesstest.go+++ /dev/null@@ -1,95 +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 harnesstest--import (- "context"- "sync"-- "github.com/google/ax/internal/harness"- "github.com/google/ax/proto"- "github.com/google/uuid"-)--// TODO(jbd): Remove once the Harness refractor is done.--// Harness implements the harness.Harness interface for testing purposes.-type Harness struct {-}--// New creates a new Harness instance.-func New() *Harness {- return &Harness{}-}--// Start implements harness.Harness.-func (h *Harness) Start(ctx context.Context, conversationID string) (harness.Execution, error) {- execID := uuid.NewString()- exec := &Execution{- harness: h,- conversationID: conversationID,- id: execID,- }- return exec, nil-}--// Execution implements the harness.Execution interface.-type Execution struct {- harness *Harness- conversationID string- id string-- mu sync.Mutex- queued []*proto.Message-}--// ID implements harness.Execution.-func (e *Execution) ID() string {- return e.id-}--// Queue implements harness.Execution.-func (e *Execution) Queue(ctx context.Context, msg ...*proto.Message) error {- e.mu.Lock()- defer e.mu.Unlock()- e.queued = append(e.queued, msg...)- return nil-}--// Run implements harness.Execution.-// It generates a "Hello world" message and completes the turn.-func (e *Execution) Run(ctx context.Context, handler harness.Handler) error {- msg := &proto.Message{- Role: "assistant",- Content: &proto.Content{- Type: &proto.Content_Text{- Text: &proto.TextContent{- Text: "Hello world",- },- },- },- }-- if err := handler.OnMessage(ctx, e.id, msg); err != nil {- return err- }-- return handler.OnComplete(ctx, e.id)-}--// Close implements harness.Execution.-func (e *Execution) Close(ctx context.Context) error {- return nil-}