Agent Executor (AX) is Google's open agentic orchestration runtime
Go
Remove Agent.HealthCheck (#233)
Jaana Dogan60a7e370a8ee
diff --git a/examples/k8s_sandbox_agent/main.go b/examples/k8s_sandbox_agent/main.goindex 7c65428..a40236a 100644--- a/examples/k8s_sandbox_agent/main.go+++ b/examples/k8s_sandbox_agent/main.go@@ -35,7 +35,7 @@ type server struct {}func (s *server) HealthCheck(ctx context.Context, req *proto.HealthCheckRequest) (*proto.HealthCheckResponse, error) {- return &proto.HealthCheckResponse{Healthy: true, Message: "upper_case_agent is running"}, nil+ return &proto.HealthCheckResponse{Healthy: true, Message: "k8s sandbox agent is running"}, nil}func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, proto.AgentMessage]) error {diff --git a/internal/agent/agent.go b/internal/agent/agent.goindex 38c2bb4..1ee69a2 100644--- a/internal/agent/agent.go+++ b/internal/agent/agent.go@@ -38,10 +38,6 @@ type Agent interface {// The handler may be called multiple times during processing.Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error- // HealthCheck checks if the agent is healthy and responsive.- // Returns an error if the agent is unhealthy or unreachable.- HealthCheck(ctx context.Context) error-// Close gracefully shuts down the agent and releases resources.Close() error}diff --git a/internal/agent/ate.go b/internal/agent/ate.goindex b3edd6e..02dec07 100644--- a/internal/agent/ate.go+++ b/internal/agent/ate.go@@ -100,11 +100,6 @@ func (a *ATEAgent) Connect(ctx context.Context, execID string, start *proto.Agenreturn 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 {diff --git a/internal/agent/colab.go b/internal/agent/colab.goindex 88e9edf..15cecc5 100644--- a/internal/agent/colab.go+++ b/internal/agent/colab.go@@ -342,12 +342,7 @@ func (a *ColabAgent) isSessionAlive(ctx context.Context, sessionName string) booreturn err == nil}-// HealthCheck returns nil for Colab agents. Sessions are ephemeral and created-// on demand, so there is no persistent state to check. The colab CLI binary-// was already validated at registration time.-func (a *ColabAgent) HealthCheck(ctx context.Context) error {- return nil-}+// Close stops all currently active Colab sessions. This handles the case where// Close() is called (e.g. via SIGINT) while one or more Connect() calls arediff --git a/internal/agent/k8s_sandbox.go b/internal/agent/k8s_sandbox.goindex 97a223b..e11d333 100644--- a/internal/agent/k8s_sandbox.go+++ b/internal/agent/k8s_sandbox.go@@ -76,12 +76,6 @@ func newKubernetesSandboxAgentWithClient(ctx context.Context, client *sandboxclireturn agent, nil}-// HealthCheck always returns nil for ephemeral agents since health is checked during Process.-func (a *KubernetesSandboxAgent) HealthCheck(ctx context.Context) error {- // TODO: implement proper health check logic for sandbox agents.- return nil-}-func (a *KubernetesSandboxAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {ctx, cancel := context.WithTimeout(ctx, 5*time.Second)defer cancel()diff --git a/internal/agent/local.go b/internal/agent/local.goindex 7ef9a31..40e2759 100644--- a/internal/agent/local.go+++ b/internal/agent/local.go@@ -18,6 +18,7 @@ import ("context""fmt"+"github.com/google/ax/proto")@@ -25,13 +26,11 @@ import (// It implements the Agent interface for agents running in the same process as the controller.type LocalAgent struct {processFunc func(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error- healthCheckFunc func(ctx context.Context) error}// LocalAgentConfig configures a local agent.type LocalAgentConfig struct {ProcessFunc func(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error- HealthCheckFunc func(ctx context.Context) error}// NewLocalAgent creates a new local agent with the provided configuration.@@ -40,14 +39,8 @@ func NewLocalAgent(config LocalAgentConfig) (*LocalAgent, error) {return nil, fmt.Errorf("ProcessFunc cannot be nil")}- // Provide defaults for optional functions- if config.HealthCheckFunc == nil {- config.HealthCheckFunc = func(ctx context.Context) error { return nil }- }-return &LocalAgent{processFunc: config.ProcessFunc,- healthCheckFunc: config.HealthCheckFunc,}, nil}@@ -56,11 +49,6 @@ func (a *LocalAgent) Connect(ctx context.Context, execID string, start *proto.Agreturn a.processFunc(ctx, execID, start, e, o)}-// HealthCheck checks if the agent is healthy.-func (a *LocalAgent) HealthCheck(ctx context.Context) error {- return a.healthCheckFunc(ctx)-}-// Close gracefully shuts down the agent.func (a *LocalAgent) Close() error {// Local agents don't typically need cleanup, but this can be extendeddiff --git a/internal/agent/remote.go b/internal/agent/remote.goindex 74cf212..ece44ba 100644--- a/internal/agent/remote.go+++ b/internal/agent/remote.go@@ -19,7 +19,6 @@ import ("errors""fmt""io"- "time""google.golang.org/grpc""google.golang.org/grpc/credentials/insecure"@@ -127,30 +126,6 @@ func (a *RemoteAgent) Connect(ctx context.Context, execID string, start *proto.A}}-// HealthCheck checks if the remote agent is healthy.-func (a *RemoteAgent) HealthCheck(ctx context.Context) error {- ctx, cancel := context.WithTimeout(ctx, 5*time.Second)- defer cancel()-- conn, err := a.connect()- if err != nil {- return fmt.Errorf("failed to connect: %w", err)- }- defer conn.Close()-- client := proto.NewAgentServiceClient(conn)- resp, err := client.HealthCheck(ctx, &proto.HealthCheckRequest{})- if err != nil {- return fmt.Errorf("health check failed: %w", err)- }-- if !resp.Healthy {- return fmt.Errorf("agent unhealthy: %s", resp.Message)- }-- return nil-}-// Close gracefully shuts down the remote agent connection.func (a *RemoteAgent) Close() error {return nildiff --git a/internal/controller/controller_test.go b/internal/controller/controller_test.goindex 5769bdd..06a22ea 100644--- a/internal/controller/controller_test.go+++ b/internal/controller/controller_test.go@@ -29,7 +29,7 @@ type dummyAgent struct{}func (a *dummyAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {return nil}-func (a *dummyAgent) HealthCheck(ctx context.Context) error { return nil }+func (a *dummyAgent) Close() error { return nil }func TestController_Exec_ResumptionAndIDGeneration(t *testing.T) {@@ -453,6 +453,6 @@ type mockAgentFunc struct {func (m *mockAgentFunc) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {return m.connectFunc(ctx, execID, start, e, o)}-func (m *mockAgentFunc) HealthCheck(ctx context.Context) error { return nil }+func (m *mockAgentFunc) Close() error { return nil }diff --git a/internal/controller/executor/util.go b/internal/controller/executor/util.goindex ddf0f27..fbad7ff 100644--- a/internal/controller/executor/util.go+++ b/internal/controller/executor/util.go@@ -29,7 +29,6 @@ func (f agentFunc) Connect(ctx context.Context, execID string, start *proto.Agenreturn nil}-func (f agentFunc) HealthCheck(_ context.Context) error { return nil }func (f agentFunc) Close() error { return nil }func AgentFunc(fn func(input []*proto.Message, tm agent.Executor, o agent.OutputHandler)) agent.Agent {diff --git a/internal/controller/gemini.go b/internal/controller/gemini.goindex c4ad775..be4225d 100644--- a/internal/controller/gemini.go+++ b/internal/controller/gemini.go@@ -135,10 +135,6 @@ func (a *GeminiAgent) Connect(ctx context.Context, execID string, start *proto.Areturn nil}-func (a *GeminiAgent) HealthCheck(ctx context.Context) error {- return nil-}-func (a *GeminiAgent) Close() error {return nil}diff --git a/internal/controller/gemini_planner.go b/internal/controller/gemini_planner.goindex 4267464..0dbcfa7 100644--- a/internal/controller/gemini_planner.go+++ b/internal/controller/gemini_planner.go@@ -108,10 +108,6 @@ func (p *geminiPlannerAgent) Connect(ctx context.Context, execID string, start *return p.loop(ctx, start, e, handler)}-func (p *geminiPlannerAgent) HealthCheck(ctx context.Context) error {- return nil-}-func (p *geminiPlannerAgent) Close() error {return nil}diff --git a/internal/controller/registry_test.go b/internal/controller/registry_test.goindex 59fd78a..cdc7210 100644--- a/internal/controller/registry_test.go+++ b/internal/controller/registry_test.go@@ -17,7 +17,6 @@ package controller// TODO(lhuan): Setup a better automated testing frameworkimport (- "context""fmt""net""testing"@@ -33,10 +32,6 @@ type mockAgentServer struct {healthy bool}-func (s *mockAgentServer) HealthCheck(ctx context.Context, req *proto.HealthCheckRequest) (*proto.HealthCheckResponse, error) {- return &proto.HealthCheckResponse{Healthy: s.healthy}, nil-}-func startMockGRPCServer(t *testing.T, healthy bool) (string, func()) {lis, err := net.Listen("tcp", "localhost:0")if err != nil {diff --git a/internal/examples/ate_agent/main.go b/internal/examples/ate_agent/main.goindex 5b76808..21936da 100644--- a/internal/examples/ate_agent/main.go+++ b/internal/examples/ate_agent/main.go@@ -15,7 +15,6 @@package mainimport (- "context""fmt""io""log"@@ -83,14 +82,7 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro}}-// 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)diff --git a/internal/multi_test.go b/internal/multi_test.goindex 2e47317..2f0ee30 100644--- a/internal/multi_test.go+++ b/internal/multi_test.go@@ -177,7 +177,6 @@ func createLocalAgent(transform func(string) string) (*agent.LocalAgent, error)return agent.NewLocalAgent(agent.LocalAgentConfig{ProcessFunc: processFunc,- HealthCheckFunc: func(ctx context.Context) error { return nil },})}@@ -185,7 +184,7 @@ type mockPlanner struct{}func (m *mockPlanner) ID() string { return "__planner" }func (m *mockPlanner) Name() string { return "Mock Planner" }-func (m *mockPlanner) HealthCheck(ctx context.Context) error { return nil }+func (m *mockPlanner) Close() error { return nil }func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {var lastText stringdiff --git a/internal/testagent/agent.go b/internal/testagent/agent.goindex 1e1b4f1..874965d 100644--- a/internal/testagent/agent.go+++ b/internal/testagent/agent.go@@ -167,11 +167,6 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.Areturn nil}-// HealthCheck checks if the agent is healthy.-func (a *CodingAgent) HealthCheck(ctx context.Context) error {- return nil-}-// Close gracefully shuts down the agent.func (a *CodingAgent) Close() error {return nil@@ -304,9 +299,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star})}-func (a *KubernetesDeployAgent) HealthCheck(ctx context.Context) error {- return nil-}+// Close gracefully shuts down the agent.func (a *KubernetesDeployAgent) Close() error {diff --git a/internal/testagent/docker.go b/internal/testagent/docker.goindex da6f0d2..5b797a2 100644--- a/internal/testagent/docker.go+++ b/internal/testagent/docker.go@@ -68,9 +68,7 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *return nil}-func (a *DockerBuilderAgent) HealthCheck(ctx context.Context) error {- return nil-}+// Close gracefully shuts down the agent.func (a *DockerBuilderAgent) Close() error {@@ -109,10 +107,6 @@ func (a *DockerMirrorAgent) Connect(ctx context.Context, execID string, start *preturn nil}-func (a *DockerMirrorAgent) HealthCheck(ctx context.Context) error {- return nil-}-// Close gracefully shuts down the agent.func (a *DockerMirrorAgent) Close() error {return nil