Skip to content

armgit / ax

Public Imported from GitHub
0

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

Go

Add gRPC Streaming for Harness interface and integration (#34)

anj-sc388c4c2e446
diff --git a/e2e.go b/cmd/e2e/main.go
similarity index 66%
rename from e2e.go
rename to cmd/e2e/main.go
index 68727b6..676cf32 100644
--- a/e2e.go
+++ b/cmd/e2e/main.go
@@ -14,13 +14,23 @@
// Package main implements an end-to-end demonstration of the Antigravity harness
// integration with AX Controller V2.
+//
+// TO RUN THIS E2E DEMONSTRATION:
+//
+// Step 1: Start the Python gRPC Harness Server (in a separate terminal or background):
+// PYTHONPATH=python:. /Users/anjalisridhar/.gemini/jetski/worktrees/harness-interface-3/implement-agy-sdk-streaming-20260528/.venv/bin/python python/antigravity/harness_server.py --port 50053
+//
+// Step 2: Run this Go E2E client:
+// go run cmd/e2e/main.go
package main
+
import (
"context"
"fmt"
+ "net"
"os"
- "os/exec"
+ "time"
"github.com/google/ax/internal/controller/executor"
"github.com/google/ax/internal/controller/executor/executortest"
@@ -46,46 +56,26 @@ func main() {
})
// -------------------------------------------------------------------------
- // Demo 2: Build-time Fallback (Antigravity with bad script path)
- // -------------------------------------------------------------------------
- fmt.Println("\n--- Demo 2: Build-time Fallback ---")
- fmt.Println("Registering 'antigravity' with non-existent script. Should fallback to Test Harness.")
- runDemo(ctx, "antigravity", func(reg *controller2.Registry) {
- // Build harness with bad path, manually implementing fallback check
- var badHarness harness.Harness
- scriptPath := "non-existent-script.py"
- if _, err := exec.LookPath("python3"); err != nil {
- fmt.Printf("WARNING: python3 not found, falling back to test harness: %v\n", err)
- badHarness = harnesstest.New()
- } else if _, err := os.Stat(scriptPath); err != nil {
- fmt.Printf("WARNING: Antigravity agent script not found at %s, falling back to test harness: %v\n", scriptPath, err)
- badHarness = harnesstest.New()
- } else {
- badHarness = harness.NewAntigravityHarness(scriptPath)
- }
- reg.RegisterHarness("antigravity", badHarness)
- })
-
- // -------------------------------------------------------------------------
- // Demo 3: Antigravity Execution (Requires google-antigravity & GEMINI_API_KEY)
+ // Demo 2: Antigravity Execution (Requires google-antigravity & GEMINI_API_KEY)
// -------------------------------------------------------------------------
- fmt.Println("\n--- Demo 3: Antigravity Execution ---")
+ fmt.Println("\n--- Demo 2: Antigravity Execution ---")
fmt.Println("Registering 'antigravity' with real script. Attempting execution.")
if os.Getenv("GEMINI_API_KEY") == "" {
fmt.Println("WARNING: GEMINI_API_KEY is not set. Execution will likely fail if dependencies are missing, but we will try anyway.")
}
runDemo(ctx, "antigravity", func(reg *controller2.Registry) {
- // Build harness with real path, manually implementing fallback check
+ // 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.Harness
- scriptPath := "examples/antigravity_agent/agent.py"
- if _, err := exec.LookPath("python3"); err != nil {
- fmt.Printf("WARNING: python3 not found, falling back to test harness: %v\n", err)
- realHarness = harnesstest.New()
- } else if _, err := os.Stat(scriptPath); err != nil {
- fmt.Printf("WARNING: Antigravity agent script not found at %s, falling back to test harness: %v\n", scriptPath, err)
+ address := "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 {
- realHarness = harness.NewAntigravityHarness(scriptPath)
+ conn.Close()
+ fmt.Printf("Connected to Antigravity gRPC harness server at %s\n", address)
+ realHarness = harness.NewAntigravityHarness(address)
}
reg.RegisterHarness("antigravity", realHarness)
})
@@ -112,6 +102,8 @@ func runDemo(ctx context.Context, agentID string, setupRegistry func(reg *contro
for _, out := range resp.Outputs {
if textContent := out.GetContent().GetText().GetText(); textContent != "" {
fmt.Printf("Agent Output: %s\n", textContent)
+ } else if toolCall := out.GetContent().GetToolCall(); toolCall != nil {
+ fmt.Printf("Agent Triggered Tool Call: %s (ID: %s)\n", toolCall.GetFunctionCall().Name, toolCall.Id)
}
}
return nil
@@ -122,7 +114,7 @@ func runDemo(ctx context.Context, agentID string, setupRegistry func(reg *contro
Role: "user",
Content: &proto.Content{
Type: &proto.Content_Text{
- Text: &proto.TextContent{Text: "Who are you?"},
+ Text: &proto.TextContent{Text: "What is the weather in New York?"},
},
},
},
diff --git a/examples/antigravity_agent/agent.py b/examples/antigravity_agent/agent.py
index 41b4474..b5bf538 100644
--- a/examples/antigravity_agent/agent.py
+++ b/examples/antigravity_agent/agent.py
@@ -12,21 +12,80 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# NOTE ON ARCHITECTURE:
+# This file plays a dual-purpose role:
+# 1. Standalone Sandbox: Can be run directly via CLI (python agent.py "prompt") for local L2 debugging.
+# 2. Declarative Config Module: Exposes 'agent_config' globally, which python/antigravity/harness_server.py
+# dynamically imports to serve this agent over production gRPC.
+
import asyncio
+
import sys
-from google.antigravity import Agent, LocalAgentConfig
+from google.antigravity import LocalAgentConfig
+from google.antigravity.connections.local import LocalConnectionStrategy
+from google.antigravity.conversation.conversation import Conversation
+from google.antigravity.tools.tool_runner import ToolRunner
+from google.antigravity.types import Text, Thought, ToolCall
+
+# 1. Define a custom local python tool
+def get_weather(city: str) -> str:
+ """Retrieves the current weather report for a specified city.
+
+ Args:
+ city (str): The name of the city for which to retrieve the weather report.
+
+ Returns:
+ str: Weather report status and details.
+ """
+ # Output to stderr so it does not pollute the stdout stream capture
+ sys.stderr.write(f"\n[PYTHON TOOL get_weather executed for city: {city}]\n")
+ sys.stderr.flush()
+ c = city.lower()
+ if "new york" in c or "nyc" in c:
+ return "The weather in New York is sunny with a temperature of 25 degrees Celsius (77 degrees Fahrenheit)."
+ elif "san francisco" in c or "sf" in c:
+ return "The weather in San Francisco is foggy with a temperature of 16 degrees Celsius (60.8 degrees Fahrenheit)."
+ else:
+ return f"Weather information for '{city}' is not available."
+
+# 2. Expose agent_config globally for harness_server.py config loading
+agent_config = LocalAgentConfig(
+ system_instructions="You are a helpful agent. Use the get_weather tool to answer weather questions.",
+ tools=[get_weather]
+)
+
+# Expose the L2 configuration strategy factory for custom loaders
+strategy_factory = lambda: LocalConnectionStrategy(tool_runner=ToolRunner(tools=[get_weather]))
async def main():
- # Initialize the agent configuration. It automatically picks up GEMINI_API_KEY from the environment.
- config = LocalAgentConfig()
- async with Agent(config) as agent:
- # Check if the user has sent a prompt otherwise thrown an error
-
+ # 3. Initialize the local connection strategy
+ strategy = strategy_factory()
+
+ # 4. Create the stateful conversation session
+ print("Starting stateful Antigravity conversation (L2 API)...")
+ async with Conversation.create(strategy) as conversation:
prompt = sys.argv[1] if len(sys.argv) > 1 else None
if not prompt:
raise ValueError("Please provide a prompt for your agent. Usage: python agent.py <prompt>")
- response = await agent.chat(prompt)
- print(await response.text())
+
+ # 5. Send query and receive streaming ChatResponse
+ response = await conversation.chat(prompt)
+
+ # 6. Stream semantic chunks (Thoughts, Text, and ToolCalls) in real-time
+ async for chunk in response.chunks:
+ if isinstance(chunk, Text):
+ sys.stdout.write(chunk.text)
+ sys.stdout.flush()
+ elif isinstance(chunk, Thought):
+ # Display thought process in comment style
+ sys.stdout.write(f"\n[Thinking]: {chunk.text}")
+ sys.stdout.flush()
+ elif isinstance(chunk, ToolCall):
+ sys.stdout.write(f"\n[Tool Call]: {chunk.name} with args {chunk.args}\n")
+ sys.stdout.flush()
+ print()
if __name__ == "__main__":
asyncio.run(main())
+
+
diff --git a/hack/run-antigravity-streaming.sh b/hack/run-antigravity-streaming.sh
new file mode 100755
index 0000000..7e80428
--- /dev/null
+++ b/hack/run-antigravity-streaming.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+# 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.
+
+set -e
+
+# Check if GEMINI_API_KEY is set
+if [ -z "$GEMINI_API_KEY" ]; then
+ echo "ERROR: GEMINI_API_KEY environment variable is not set."
+ echo "Please set it using: export GEMINI_API_KEY=\"your-key\""
+ exit 1
+fi
+
+PORT=50053
+ADDRESS="localhost:$PORT"
+AGENT_FILE="examples/antigravity_agent/agent.py"
+
+# 1. Start Python gRPC server in the background
+echo "Starting Python gRPC Harness Server on port $PORT..."
+PYTHONPATH=python:. .venv/bin/python -m python.antigravity.harness_server --agent_file "$AGENT_FILE" --port "$PORT" > /tmp/antigravity_harness.log 2>&1 &
+SERVER_PID=$!
+
+# Register trap to ensure server is killed on script exit
+cleanup() {
+ echo "Cleaning up: killing Python server (PID: $SERVER_PID)..."
+ kill "$SERVER_PID" || true
+ wait "$SERVER_PID" 2>/dev/null || true
+ echo "Cleanup complete!"
+}
+trap cleanup EXIT
+
+# 2. Wait for the Python server to be healthy
+echo "Waiting for Python server to become healthy..."
+MAX_ATTEMPTS=30
+ATTEMPT=1
+HEALTHY=false
+
+while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
+ # We can check if the port is open using nc (netcat)
+ if nc -z localhost "$PORT"; then
+ HEALTHY=true
+ break
+ fi
+ sleep 0.2
+ ATTEMPT=$((ATTEMPT + 1))
+done
+
+if [ "$HEALTHY" = false ]; then
+ echo "ERROR: Python server failed to start within 6 seconds."
+ echo "Server logs (/tmp/antigravity_harness.log):"
+ cat /tmp/antigravity_harness.log
+ exit 1
+fi
+echo "Python server is active!"
+
+# 3. Build and run the Go E2E V2 demonstration
+echo "Building e2e..."
+/opt/homebrew/bin/go build -o bin/e2e ./cmd/e2e
+
+echo "Executing E2E Demo with Antigravity gRPC Harness..."
+bin/e2e
+
+echo "Success!"
diff --git a/internal/harness/antigravity.go b/internal/harness/antigravity.go
index 397f1da..15158de 100644
--- a/internal/harness/antigravity.go
+++ b/internal/harness/antigravity.go
@@ -17,31 +17,37 @@ package harness
import (
"context"
"fmt"
- "os/exec"
- "strings"
+ "io"
"sync"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
+
"github.com/google/ax/proto"
"github.com/google/uuid"
)
-// AntigravityHarness implements the Harness interface by running the
-// Antigravity Python agent as a subprocess.
+// Compile-time interface assertions.
+var _ Harness = (*AntigravityHarness)(nil)
+var _ Execution = (*antigravityExecution)(nil)
+
+// AntigravityHarness implements the Harness interface by connecting to the
+// Antigravity Python agent server over gRPC.
type AntigravityHarness struct {
- scriptPath string
+ address string
}
-// NewAntigravityHarness creates a new AntigravityHarness with a configurable script path.
-func NewAntigravityHarness(scriptPath string) *AntigravityHarness {
- if scriptPath == "" {
- scriptPath = "examples/antigravity_agent/agent.py"
+// NewAntigravityHarness creates a new AntigravityHarness with a configurable address.
+// Address defaults to "localhost:50053" (gRPC TCP connection).
+func NewAntigravityHarness(address string) *AntigravityHarness {
+ if address == "" {
+ address = "localhost:50053"
}
return &AntigravityHarness{
- scriptPath: scriptPath,
+ address: address,
}
}
-
// Start implements Harness.Start.
func (h *AntigravityHarness) Start(ctx context.Context, conversationID string) (Execution, error) {
return &antigravityExecution{
@@ -72,79 +78,78 @@ func (e *antigravityExecution) Queue(ctx context.Context, msg ...*proto.Message)
e.mu.Lock()
defer e.mu.Unlock()
if e.closed {
- return fmt.Errorf("execution is closed")
+ return fmt.Errorf("execution session already closed")
}
e.queued = append(e.queued, msg...)
return nil
}
-// Run implements Execution.Run.
-// It executes the Python agent as a one-shot subprocess turn.
-//
-// NOTE: This is a stateless, subprocess-based validation harness. Because a new
-// subprocess is launched for every turn, it does not support persistent state
-// or dynamic input streaming. We retrieve all queued inputs at the start of the
-// turn, clear the queue, and pass only the last user prompt to the subprocess.
-// Full bidirectional streaming input/output will be supported once we migrate to
-// the gRPC HarnessService server as noted below.
+// Run executes the turn over gRPC bidirectional streaming and forwards events to the handler.
func (e *antigravityExecution) Run(ctx context.Context, handler Handler) error {
e.mu.Lock()
+ if e.closed {
+ e.mu.Unlock()
+ return fmt.Errorf("execution session already closed")
+ }
+ // Retrieve queued inputs
inputs := e.queued
e.queued = nil
e.mu.Unlock()
- // Extract only the latest user message since the CLI script only accepts a single prompt argument.
- var prompt string
- for i := len(inputs) - 1; i >= 0; i-- {
- msg := inputs[i]
- if msg.Role == "user" {
- if textContent := msg.GetContent().GetText().GetText(); textContent != "" {
- prompt = textContent
- break
- }
- }
+ if len(inputs) == 0 {
+ return fmt.Errorf("no input messages queued for execution turn")
}
- // TODO(anj): Upgrade this to a gRPC HarnessService server to support full bidirectional
- // input/output streaming and avoid subprocess invocation overhead.
-
- // Prepare the command
- args := []string{e.harness.scriptPath}
- if prompt != "" {
- args = append(args, prompt)
+ // 1. Connect to the gRPC server
+ conn, err := grpc.DialContext(ctx, e.harness.address, grpc.WithTransportCredentials(insecure.NewCredentials()))
+ if err != nil {
+ return fmt.Errorf("failed to connect to gRPC harness server at %s: %w", e.harness.address, err)
}
-
- cmd := exec.CommandContext(ctx, "python3", args...)
-
- // Capture stdout and stderr
- var stdout, stderr strings.Builder
- cmd.Stdout = &stdout
- cmd.Stderr = &stderr
-
- // Run the command
- if err := cmd.Run(); err != nil {
- return fmt.Errorf("failed to run antigravity agent (stderr: %s): %w", stderr.String(), err)
+ defer conn.Close()
+
+ // 2. Create AgentService client
+ client := proto.NewAgentServiceClient(conn)
+
+ // 3. Build standard AgentRequest
+ req := &proto.AgentRequest{
+ ConversationId: e.conversationID,
+ ExecId: e.id,
+ Start: &proto.AgentStart{
+ AgentId: "antigravity",
+ Messages: inputs,
+ },
}
- output := strings.TrimSpace(stdout.String())
-
- // Send the output back to the handler
- msg := &proto.Message{
- Role: "assistant",
- Content: &proto.Content{
- Type: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: output,
- },
- },
- },
+ // 4. Call Connect to start bidirectional streaming
+ stream, err := client.Connect(ctx, req)
+ if err != nil {
+ return fmt.Errorf("failed to call gRPC AgentService.Connect: %w", err)
}
- if err := handler.OnMessage(ctx, e.id, msg); err != nil {
- return fmt.Errorf("failed to send message to handler: %w", err)
+ // 5. Stream responses and trigger callbacks
+ for {
+ resp, err := stream.Recv()
+ if err == io.EOF {
+ break
+ }
+ if err != nil {
+ return fmt.Errorf("gRPC harness streaming failure: %w", err)
+ }
+
+ switch payload := resp.Type.(type) {
+ case *proto.AgentResponse_Outputs:
+ for _, outMsg := range payload.Outputs.Messages {
+ if err := handler.OnMessage(ctx, e.id, outMsg); err != nil {
+ return fmt.Errorf("failed to dispatch streamed output: %w", err)
+ }
+ }
+ case *proto.AgentResponse_End:
+ // Standard turn complete callback
+ return handler.OnComplete(ctx, e.id)
+ }
}
- return handler.OnComplete(ctx, e.id)
+ return nil
}
// Close implements Execution.Close.
diff --git a/internal/harness/antigravity_test.go b/internal/harness/antigravity_test.go
new file mode 100644
index 0000000..18d23b9
--- /dev/null
+++ b/internal/harness/antigravity_test.go
@@ -0,0 +1,222 @@
+// 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 harness
+
+import (
+ "context"
+ "net"
+ "strings"
+ "sync"
+ "testing"
+
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
+
+ "github.com/google/ax/proto"
+)
+
+type mockHandler struct {
+ mu sync.Mutex
+ messages []*proto.Message
+ complete bool
+ err error
+}
+
+func (h *mockHandler) OnMessage(ctx context.Context, execID string, msg *proto.Message) error {
+ h.mu.Lock()
+ defer h.mu.Unlock()
+ h.messages = append(h.messages, msg)
+ return h.err
+}
+
+func (h *mockHandler) OnComplete(ctx context.Context, execID string) error {
+ h.mu.Lock()
+ defer h.mu.Unlock()
+ h.complete = true
+ return nil
+}
+
+// mockAgentServer implements proto.AgentServiceServer for testing.
+type mockAgentServer struct {
+ proto.UnimplementedAgentServiceServer
+ failConnect bool
+}
+
+func (s *mockAgentServer) Connect(req *proto.AgentRequest, stream proto.AgentService_ConnectServer) error {
+ if s.failConnect {
+ return status.Error(codes.Internal, "internal mock server crash")
+ }
+
+ // 1. Verify conversation details
+ if req.ConversationId != "conv-test" {
+ return status.Error(codes.InvalidArgument, "invalid conversation_id")
+ }
+
+ // 2. Stream thought frame
+ tMsg := &proto.Message{
+ Role: "model",
+ Content: &proto.Content{
+ Type: &proto.Content_Thought{
+ Thought: &proto.ThoughtContent{
+ Summary: []*proto.ThoughtSummaryContent{
+ {
+ Type: &proto.ThoughtSummaryContent_Text{
+ Text: &proto.TextContent{Text: "Analyzing"},
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+ err := stream.Send(&proto.AgentResponse{
+ ConversationId: req.ConversationId,
+ ExecId: req.ExecId,
+ Type: &proto.AgentResponse_Outputs{
+ Outputs: &proto.AgentOutputs{Messages: []*proto.Message{tMsg}},
+ },
+ })
+ if err != nil {
+ return err
+ }
+
+ // 3. Stream text frame
+ txtMsg := &proto.Message{
+ Role: "assistant",
+ Content: &proto.Content{
+ Type: &proto.Content_Text{
+ Text: &proto.TextContent{Text: "Hello world"},
+ },
+ },
+ }
+ err = stream.Send(&proto.AgentResponse{
+ ConversationId: req.ConversationId,
+ ExecId: req.ExecId,
+ Type: &proto.AgentResponse_Outputs{
+ Outputs: &proto.AgentOutputs{Messages: []*proto.Message{txtMsg}},
+ },
+ })
+ if err != nil {
+ return err
+ }
+
+ // 4. Stream end frame
+ return stream.Send(&proto.AgentResponse{
+ ConversationId: req.ConversationId,
+ ExecId: req.ExecId,
+ Type: &proto.AgentResponse_End{
+ End: &proto.AgentEnd{},
+ },
+ })
+}
+
+func TestAntigravityHarness_Run_Success(t *testing.T) {
+ // Spin up a local TCP listener
+ lis, err := net.Listen("tcp", "localhost:0")
+ if err != nil {
+ t.Fatalf("failed to listen: %v", err)
+ }
+ defer lis.Close()
+
+ // Initialize and start local gRPC server
+ grpcServer := grpc.NewServer()
+ mockServer := &mockAgentServer{}
+ proto.RegisterAgentServiceServer(grpcServer, mockServer)
+
+ go func() {
+ if err := grpcServer.Serve(lis); err != nil && err != grpc.ErrServerStopped {
+ t.Errorf("Serve failed: %v", err)
+ }
+ }()
+ defer grpcServer.Stop()
+
+ harnessClient := NewAntigravityHarness(lis.Addr().String())
+ exec, err := harnessClient.Start(context.Background(), "conv-test")
+ if err != nil {
+ t.Fatalf("failed to start execution: %v", err)
+ }
+ defer exec.Close(context.Background())
+
+ msg := &proto.Message{
+ Role: "user",
+ Content: &proto.Content{
+ Type: &proto.Content_Text{Text: &proto.TextContent{Text: "Hi"}},
+ },
+ }
+ if err := exec.Queue(context.Background(), msg); err != nil {
+ t.Fatalf("failed to queue message: %v", err)
+ }
+
+ handler := &mockHandler{}
+ err = exec.Run(context.Background(), handler)
+ if err != nil {
+ t.Fatalf("Run failed: %v", err)
+ }
+
+ handler.mu.Lock()
+ defer handler.mu.Unlock()
+
+ if !handler.complete {
+ t.Error("expected OnComplete to be called")
+ }
+ if len(handler.messages) != 2 {
+ t.Fatalf("expected 2 messages, got %d", len(handler.messages))
+ }
+ if handler.messages[0].GetContent().GetThought().GetSummary()[0].GetText().GetText() != "Analyzing" {
+ t.Errorf("expected 'Analyzing', got %q", handler.messages[0].GetContent().GetThought().GetSummary()[0].GetText().GetText())
+ }
+ if handler.messages[1].GetContent().GetText().GetText() != "Hello world" {
+ t.Errorf("expected 'Hello world', got %q", handler.messages[1].GetContent().GetText().GetText())
+ }
+}
+
+func TestAntigravityHarness_Run_ErrorFrame(t *testing.T) {
+ lis, err := net.Listen("tcp", "localhost:0")
+ if err != nil {
+ t.Fatalf("failed to listen: %v", err)
+ }
+ defer lis.Close()
+
+ grpcServer := grpc.NewServer()
+ mockServer := &mockAgentServer{failConnect: true}
+ proto.RegisterAgentServiceServer(grpcServer, mockServer)
+
+ go func() {
+ _ = grpcServer.Serve(lis)
+ }()
+ defer grpcServer.Stop()
+
+ harnessClient := NewAntigravityHarness(lis.Addr().String())
+ exec, _ := harnessClient.Start(context.Background(), "conv-test")
+ defer exec.Close(context.Background())
+
+ msg := &proto.Message{
+ Role: "user",
+ Content: &proto.Content{
+ Type: &proto.Content_Text{Text: &proto.TextContent{Text: "Hi"}},
+ },
+ }
+ _ = exec.Queue(context.Background(), msg)
+
+ handler := &mockHandler{}
+ err = exec.Run(context.Background(), handler)
+ if err == nil {
+ t.Fatal("expected error from Run(), got nil")
+ }
+ if !strings.Contains(err.Error(), "internal mock server crash") {
+ t.Errorf("unexpected error message: %v", err)
+ }
+}
diff --git a/python/antigravity/__init__.py b/python/antigravity/__init__.py
new file mode 100644
index 0000000..58d482e
--- /dev/null
+++ b/python/antigravity/__init__.py
@@ -0,0 +1,13 @@
+# 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.
diff --git a/python/antigravity/harness_server.py b/python/antigravity/harness_server.py
new file mode 100644
index 0000000..04f65f6
--- /dev/null
+++ b/python/antigravity/harness_server.py
@@ -0,0 +1,229 @@
+# 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
+#
+# https://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.
+
+# NOTE ON ARCHITECTURE:
+# This is a generic, reusable gRPC server that does not define tools or personas.
+# Instead, it dynamically imports any agent configuration file (defaulting to examples/antigravity_agent/agent.py)
+# passed via the --agent_file CLI argument, then hosts it over the AX AgentService protocol.
+
+import argparse
+
+import asyncio
+import importlib.util
+import logging
+import sys
+import grpc
+from google.protobuf.struct_pb2 import Struct
+
+from python.proto import ax_pb2
+from python.proto import ax_pb2_grpc
+from python.proto import content_pb2
+from google.antigravity import Agent, AgentConfig
+from google.antigravity.types import Step, StepType, StepSource, StepTarget, StepStatus, Text, Thought, ToolCall
+
+# Global placeholder for loaded agent config
+loaded_config: AgentConfig | None = None
+
+def load_agent_config(agent_file: str) -> AgentConfig:
+ print(f"Loading agent config from {agent_file}...")
+ spec = importlib.util.spec_from_file_location("agent_module", agent_file)
+ if spec is None or spec.loader is None:
+ raise FileNotFoundError(f"Could not find or load agent file: {agent_file}")
+ agent_module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(agent_module)
+
+ config = getattr(agent_module, "agent_config", None)
+ if not config:
+ raise ValueError(f"No 'agent_config' found in {agent_file}")
+ print("Agent config loaded successfully.")
+ return config
+
+def hydrate_ax_history_to_steps(historical_messages) -> list[Step]:
+ steps = []
+ for i, msg in enumerate(historical_messages):
+ source = StepSource.UNKNOWN
+ target = StepTarget.UNSPECIFIED
+ step_type = StepType.TEXT_RESPONSE
+ content = ""
+ thinking = ""
+
+ # Determine source and target based on role
+ if msg.role == "user":
+ source = StepSource.USER
+ target = StepTarget.ENVIRONMENT
+ elif msg.role in ("assistant", "model"):
+ source = StepSource.MODEL
+ target = StepTarget.USER
+
+ # Extract content/thinking
+ active_type = msg.content.WhichOneof('type')
+ if active_type == 'text':
+ content = msg.content.text.text
+ elif active_type == 'thought':
+ step_type = StepType.TEXT_RESPONSE
+ if msg.content.thought.summary:
+ texts = []
+ for s in msg.content.thought.summary:
+ if s.WhichOneof('type') == 'text':
+ texts.append(s.text.text)
+ thinking = "".join(texts)
+
+ step = Step(
+ id=f"hist-{i}",
+ step_index=i,
+ type=step_type,
+ source=source,
+ target=target,
+ status=StepStatus.DONE,
+ content=content,
+ thinking=thinking,
+ is_complete_response=True
+ )
+ steps.append(step)
+ return steps
+
+class AntigravityAgentServiceServicer(ax_pb2_grpc.AgentServiceServicer):
+ """Implements the standard ax.AgentService protocol over gRPC."""
+
+ async def Connect(self, request: ax_pb2.AgentRequest, context):
+ print(f"[gRPC] Connect turn requested. conv_id={request.conversation_id}, exec_id={request.exec_id}")
+
+ # 1. Retrieve and check messages
+ ax_messages = request.start.messages
+ if not ax_messages:
+ context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
+ context.set_details("No messages found in start payload")
+ return
+
+ historical_messages = ax_messages[:-1]
+ latest_message = ax_messages[-1]
+
+ if latest_message.content.WhichOneof('type') != 'text':
+ context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
+ context.set_details("Latest message must contain text content")
+ return
+ latest_query_text = latest_message.content.text.text
+
+ # 2. Initialize the Antigravity Agent session
+ global loaded_config
+ if not loaded_config:
+ context.set_code(grpc.StatusCode.INTERNAL)
+ context.set_details("Agent config is not loaded on the server")
+ return
+
+ try:
+ async with Agent(loaded_config) as agent:
+ conversation = agent.conversation
+
+ # Hydrate history
+ print(f"[gRPC] Hydrating {len(historical_messages)} historical messages...")
+ history_steps = hydrate_ax_history_to_steps(historical_messages)
+ conversation._steps.extend(history_steps)
+
+ # Run the turn with streaming
+ print(f"[gRPC] Running chat query: {latest_query_text}")
+ response = await conversation.chat(latest_query_text)
+
+ async for chunk in response.chunks:
+ if isinstance(chunk, Text):
+ msg = ax_pb2.Message(
+ role="assistant",
+ content=content_pb2.Content(text=content_pb2.TextContent(text=chunk.text))
+ )
+ yield ax_pb2.AgentResponse(
+ conversation_id=request.conversation_id,
+ exec_id=request.exec_id,
+ outputs=ax_pb2.AgentOutputs(messages=[msg])
+ )
+ elif isinstance(chunk, Thought):
+ summary = [
+ content_pb2.ThoughtSummaryContent(text=content_pb2.TextContent(text=chunk.text))
+ ]
+ msg = ax_pb2.Message(
+ role="model",
+ content=content_pb2.Content(thought=content_pb2.ThoughtContent(summary=summary))
+ )
+ yield ax_pb2.AgentResponse(
+ conversation_id=request.conversation_id,
+ exec_id=request.exec_id,
+ outputs=ax_pb2.AgentOutputs(messages=[msg])
+ )
+ elif isinstance(chunk, ToolCall):
+ struct_args = Struct()
+ struct_args.update(chunk.args)
+
+ func_call = content_pb2.FunctionCallContent(
+ name=str(chunk.name),
+ arguments=struct_args
+ )
+ msg = ax_pb2.Message(
+ role="model",
+ content=content_pb2.Content(tool_call=content_pb2.ToolCallContent(
+ id=chunk.id or "",
+ function_call=func_call
+ ))
+ )
+ yield ax_pb2.AgentResponse(
+ conversation_id=request.conversation_id,
+ exec_id=request.exec_id,
+ outputs=ax_pb2.AgentOutputs(messages=[msg])
+ )
+
+ # Yield completion end frame
+ yield ax_pb2.AgentResponse(
+ conversation_id=request.conversation_id,
+ exec_id=request.exec_id,
+ end=ax_pb2.AgentEnd()
+ )
+ print("[gRPC] Turn completed successfully.")
+
+ except Exception as e:
+ logging.exception("Error inside Connect servicer execution")
+ context.set_code(grpc.StatusCode.INTERNAL)
+ context.set_details(f"Agent execution terminated due to error. ({str(e)})")
+ return
+
+ async def HealthCheck(self, request: ax_pb2.HealthCheckRequest, context):
+ """Simple health-probe responder."""
+ return ax_pb2.HealthCheckResponse(healthy=True, message="Antigravity gRPC harness active")
+
+async def serve(host: str, port: int):
+ server = grpc.aio.server()
+ ax_pb2_grpc.add_AgentServiceServicer_to_server(AntigravityAgentServiceServicer(), server)
+
+ listen_addr = f"{host}:{port}"
+ server.add_insecure_port(listen_addr)
+ print(f"Starting gRPC harness server on {listen_addr}...")
+ await server.start()
+ await server.wait_for_termination()
+
+def main():
+ parser = argparse.ArgumentParser(description="Antigravity gRPC Harness Server")
+ parser.add_argument("--agent_file", default="examples/antigravity_agent/agent.py", help="Path to the agent config file")
+ parser.add_argument("--port", type=int, default=50053, help="Port to bind the server to")
+ parser.add_argument("--host", default="localhost", help="Host to bind the server to")
+ args = parser.parse_args()
+
+ # Load the agent config globally
+ global loaded_config
+ try:
+ loaded_config = load_agent_config(args.agent_file)
+ except Exception as e:
+ print(f"ERROR: Failed to load agent config: {e}", file=sys.stderr)
+ sys.exit(1)
+
+ asyncio.run(serve(args.host, args.port))
+
+if __name__ == "__main__":
+ main()
diff --git a/python/antigravity/harness_server_test.py b/python/antigravity/harness_server_test.py
new file mode 100644
index 0000000..fbff32a
--- /dev/null
+++ b/python/antigravity/harness_server_test.py
@@ -0,0 +1,92 @@
+# 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
+#
+# https://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.
+
+import asyncio
+import pytest
+import grpc
+from python.proto import ax_pb2, ax_pb2_grpc, content_pb2
+from python.antigravity.harness_server import AntigravityAgentServiceServicer, loaded_config
+from google.antigravity import LocalAgentConfig
+
+def mock_config(monkeypatch):
+ cfg = LocalAgentConfig(system_instructions="Test instructions")
+ import python.antigravity.harness_server as hs
+ hs.loaded_config = cfg
+ return cfg
+
+def test_grpc_connect_success(mock_config, monkeypatch):
+ async def _run():
+ # 1. Start temporary local gRPC server on random open port
+ server = grpc.aio.server()
+ servicer = AntigravityAgentServiceServicer()
+ ax_pb2_grpc.add_AgentServiceServicer_to_server(servicer, server)
+ port = server.add_insecure_port("localhost:0")
+ await server.start()
+
+ # 2. Connect async stub channel
+ addr = f"localhost:{port}"
+ async with grpc.aio.insecure_channel(addr) as channel:
+ stub = ax_pb2_grpc.AgentServiceStub(channel)
+
+ # Mock the underlying Antigravity SDK class calls
+ class MockConversation:
+ def __init__(self):
+ self._steps = []
+ async def chat(self, text):
+ class MockResponse:
+ def __init__(self):
+ self.chunks = self._chunk_generator()
+ async def _chunk_generator(self):
+ from google.antigravity.types import Text, Thought
+ yield Thought(text="Thinking details", step_index=0)
+ yield Text(text="Hello human", step_index=0)
+ return MockResponse()
+
+ class MockAgent:
+ def __init__(self, config):
+ self.conversation = MockConversation()
+ async def __aenter__(self):
+ return self
+ async def __aexit__(self, exc_type, exc, tb):
+ pass
+
+ monkeypatch.setattr("python.antigravity.harness_server.Agent", MockAgent)
+
+ # 3. Construct and fire standard AgentRequest
+ start_payload = ax_pb2.AgentStart(
+ agent_id="test",
+ messages=[
+ ax_pb2.Message(role="user", content=content_pb2.Content(text=content_pb2.TextContent(text="Hi")))
+ ]
+ )
+ req = ax_pb2.AgentRequest(
+ conversation_id="conv-test",
+ exec_id="exec-test",
+ start=start_payload
+ )
+
+ responses = []
+ async for resp in stub.Connect(req):
+ responses.append(resp)
+
+ # 4. Assert outputs are correctly mapped and completed
+ assert len(responses) == 3 # Thought + Text + End
+ assert responses[0].outputs.messages[0].content.thought.summary[0].text.text == "Thinking details"
+ assert responses[1].outputs.messages[0].content.text.text == "Hello human"
+ assert responses[2].WhichOneof('type') == 'end'
+
+ await server.stop(0)
+
+ asyncio.run(_run())
diff --git a/python/proto/ax_pb2.py b/python/proto/ax_pb2.py
index 988e4ae..9c62f51 100644
--- a/python/proto/ax_pb2.py
+++ b/python/proto/ax_pb2.py
@@ -37,10 +37,10 @@ _sym_db = _symbol_database.Default()
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
-import content_pb2 as proto_dot_content__pb2
+from proto import content_pb2 as proto_dot_content__pb2
-DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0eproto/ax.proto\x12\x02\x61x\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x13proto/content.proto\"S\n\nAgentStart\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\x12\x14\n\x0c\x61gent_config\x18\x02 \x01(\x0c\x12\x1d\n\x08messages\x18\x03 \x03(\x0b\x32\x0b.ax.Message\"-\n\x0c\x41gentOutputs\x12\x1d\n\x08messages\x18\x01 \x03(\x0b\x32\x0b.ax.Message\"\n\n\x08\x41gentEnd\"\xa3\x01\n\x0c\x41gentMessage\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\x12\x0f\n\x07\x65xec_id\x18\x02 \x01(\t\x12\x1f\n\x05start\x18\x03 \x01(\x0b\x32\x0e.ax.AgentStartH\x00\x12#\n\x07outputs\x18\x04 \x01(\x0b\x32\x10.ax.AgentOutputsH\x00\x12\x1b\n\x03\x65nd\x18\x05 \x01(\x0b\x32\x0c.ax.AgentEndH\x00\x42\x06\n\x04type\"L\n\x07Message\x12\x0c\n\x04role\x18\x01 \x01(\t\x12\x1c\n\x07\x63ontent\x18\x02 \x01(\x0b\x32\x0b.ax.Content\x12\x15\n\rinternal_only\x18\x03 \x01(\x08\"\x83\x01\n\x11\x43onversationEvent\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\x12\x0b\n\x03seq\x18\x02 \x01(\x05\x12\x0f\n\x07\x65xec_id\x18\x03 \x01(\t\x12\x1d\n\x08messages\x18\x04 \x03(\x0b\x32\x0b.ax.Message\x12\x18\n\x05state\x18\x05 \x01(\x0e\x32\t.ax.State\"\xcd\x01\n\x0e\x45xecutionEvent\x12\x0f\n\x07\x65xec_id\x18\x01 \x01(\t\x12\x10\n\x08\x61gent_id\x18\x02 \x01(\t\x12\x14\n\x0c\x61gent_config\x18\x03 \x01(\x0c\x12\x1b\n\x06inputs\x18\x04 \x03(\x0b\x32\x0b.ax.Message\x12\x1c\n\x07outputs\x18\x05 \x03(\x0b\x32\x0b.ax.Message\x12\x18\n\x05state\x18\x06 \x01(\x0e\x32\t.ax.State\x12-\n\ttimestamp\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\x14\n\x12HealthCheckRequest\"7\n\x13HealthCheckResponse\x12\x0f\n\x07healthy\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t\"}\n\x0b\x45xecRequest\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\x12\x1b\n\x06inputs\x18\x02 \x03(\x0b\x32\x0b.ax.Message\x12\x10\n\x08last_seq\x18\x03 \x01(\x05\x12\x10\n\x08\x61gent_id\x18\x04 \x01(\t\x12\x14\n\x0c\x61gent_config\x18\x05 \x01(\x0c\"9\n\x0c\x45xecResponse\x12\x1c\n\x07outputs\x18\x01 \x03(\x0b\x32\x0b.ax.Message\x12\x0b\n\x03seq\x18\x02 \x01(\x05\"$\n\x11RemoteAgentConfig\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\t\"\xe9\x01\n\x14RegisterAgentRequest\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12\x38\n\x08metadata\x18\x04 \x03(\x0b\x32&.ax.RegisterAgentRequest.MetadataEntry\x12\'\n\x06remote\x18\x05 \x01(\x0b\x32\x15.ax.RemoteAgentConfigH\x00\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x42\x08\n\x06\x63onfig\"\x17\n\x15RegisterAgentResponse\"&\n\x0bListRequest\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\"5\n\x0cListResponse\x12%\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x15.ax.ConversationEvent\"(\n\rDeleteRequest\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\"\x10\n\x0e\x44\x65leteResponse\"Y\n\x0b\x46orkRequest\x12\x1b\n\x13src_conversation_id\x18\x01 \x01(\t\x12\x0f\n\x07src_seq\x18\x02 \x01(\x05\x12\x1c\n\x14\x64\x65st_conversation_id\x18\x03 \x01(\t\"\'\n\x0c\x46orkResponse\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t*X\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x11\n\rSTATE_PENDING\x10\x01\x12\x10\n\x0cSTATE_FAILED\x10\x02\x12\x13\n\x0fSTATE_COMPLETED\x10\x03\x32\x81\x01\n\x0c\x41gentService\x12\x31\n\x07\x43onnect\x12\x10.ax.AgentMessage\x1a\x10.ax.AgentMessage(\x01\x30\x01\x12>\n\x0bHealthCheck\x12\x16.ax.HealthCheckRequest\x1a\x17.ax.HealthCheckResponse2\x86\x01\n\x11\x43ontrollerService\x12+\n\x04\x45xec\x12\x0f.ax.ExecRequest\x1a\x10.ax.ExecResponse0\x01\x12\x44\n\rRegisterAgent\x12\x18.ax.RegisterAgentRequest\x1a\x19.ax.RegisterAgentResponse2\x98\x01\n\x0f\x45ventLogService\x12)\n\x04List\x12\x0f.ax.ListRequest\x1a\x10.ax.ListResponse\x12/\n\x06\x44\x65lete\x12\x11.ax.DeleteRequest\x1a\x12.ax.DeleteResponse\x12)\n\x04\x46ork\x12\x0f.ax.ForkRequest\x1a\x10.ax.ForkResponseB\x1cZ\x1agithub.com/google/ax/protob\x06proto3')
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0eproto/ax.proto\x12\x02\x61x\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x13proto/content.proto\"S\n\nAgentStart\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\x12\x14\n\x0c\x61gent_config\x18\x02 \x01(\x0c\x12\x1d\n\x08messages\x18\x03 \x03(\x0b\x32\x0b.ax.Message\"-\n\x0c\x41gentOutputs\x12\x1d\n\x08messages\x18\x01 \x03(\x0b\x32\x0b.ax.Message\"\n\n\x08\x41gentEnd\"W\n\x0c\x41gentRequest\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\x12\x0f\n\x07\x65xec_id\x18\x02 \x01(\t\x12\x1d\n\x05start\x18\x03 \x01(\x0b\x32\x0e.ax.AgentStart\"\x83\x01\n\rAgentResponse\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\x12\x0f\n\x07\x65xec_id\x18\x02 \x01(\t\x12#\n\x07outputs\x18\x03 \x01(\x0b\x32\x10.ax.AgentOutputsH\x00\x12\x1b\n\x03\x65nd\x18\x04 \x01(\x0b\x32\x0c.ax.AgentEndH\x00\x42\x06\n\x04type\"L\n\x07Message\x12\x0c\n\x04role\x18\x01 \x01(\t\x12\x1c\n\x07\x63ontent\x18\x02 \x01(\x0b\x32\x0b.ax.Content\x12\x15\n\rinternal_only\x18\x03 \x01(\x08\"\x83\x01\n\x11\x43onversationEvent\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\x12\x0b\n\x03seq\x18\x02 \x01(\x05\x12\x0f\n\x07\x65xec_id\x18\x03 \x01(\t\x12\x1d\n\x08messages\x18\x04 \x03(\x0b\x32\x0b.ax.Message\x12\x18\n\x05state\x18\x05 \x01(\x0e\x32\t.ax.State\"\xcd\x01\n\x0e\x45xecutionEvent\x12\x0f\n\x07\x65xec_id\x18\x01 \x01(\t\x12\x10\n\x08\x61gent_id\x18\x02 \x01(\t\x12\x14\n\x0c\x61gent_config\x18\x03 \x01(\x0c\x12\x1b\n\x06inputs\x18\x04 \x03(\x0b\x32\x0b.ax.Message\x12\x1c\n\x07outputs\x18\x05 \x03(\x0b\x32\x0b.ax.Message\x12\x18\n\x05state\x18\x06 \x01(\x0e\x32\t.ax.State\x12-\n\ttimestamp\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\x14\n\x12HealthCheckRequest\"7\n\x13HealthCheckResponse\x12\x0f\n\x07healthy\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t\"/\n\x0eHarnessMessage\x12\x1d\n\x08messages\x18\x01 \x03(\x0b\x32\x0b.ax.Message\"}\n\x0b\x45xecRequest\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\x12\x1b\n\x06inputs\x18\x02 \x03(\x0b\x32\x0b.ax.Message\x12\x10\n\x08last_seq\x18\x03 \x01(\x05\x12\x10\n\x08\x61gent_id\x18\x04 \x01(\t\x12\x14\n\x0c\x61gent_config\x18\x05 \x01(\x0c\"9\n\x0c\x45xecResponse\x12\x1c\n\x07outputs\x18\x01 \x03(\x0b\x32\x0b.ax.Message\x12\x0b\n\x03seq\x18\x02 \x01(\x05\"4\n\x19\x44\x65leteConversationRequest\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t\"\x1c\n\x1a\x44\x65leteConversationResponse\"e\n\x17\x46orkConversationRequest\x12\x1b\n\x13src_conversation_id\x18\x01 \x01(\t\x12\x0f\n\x07src_seq\x18\x02 \x01(\x05\x12\x1c\n\x14\x64\x65st_conversation_id\x18\x03 \x01(\t\"3\n\x18\x46orkConversationResponse\x12\x17\n\x0f\x63onversation_id\x18\x01 \x01(\t*X\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x11\n\rSTATE_PENDING\x10\x01\x12\x10\n\x0cSTATE_FAILED\x10\x02\x12\x13\n\x0fSTATE_COMPLETED\x10\x03\x32\x80\x01\n\x0c\x41gentService\x12\x30\n\x07\x43onnect\x12\x10.ax.AgentRequest\x1a\x11.ax.AgentResponse0\x01\x12>\n\x0bHealthCheck\x12\x16.ax.HealthCheckRequest\x1a\x17.ax.HealthCheckResponse2G\n\x0eHarnessService\x12\x35\n\x07\x43onnect\x12\x12.ax.HarnessMessage\x1a\x12.ax.HarnessMessage(\x01\x30\x01\x32@\n\x11\x43ontrollerService\x12+\n\x04\x45xec\x12\x0f.ax.ExecRequest\x1a\x10.ax.ExecResponse0\x01\x32\xb9\x01\n\x13\x43onversationService\x12S\n\x12\x44\x65leteConversation\x12\x1d.ax.DeleteConversationRequest\x1a\x1e.ax.DeleteConversationResponse\x12M\n\x10\x46orkConversation\x12\x1b.ax.ForkConversationRequest\x1a\x1c.ax.ForkConversationResponseB\x1cZ\x1agithub.com/google/ax/protob\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
@@ -48,56 +48,48 @@ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'proto.ax_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
_globals['DESCRIPTOR']._loaded_options = None
_globals['DESCRIPTOR']._serialized_options = b'Z\032github.com/google/ax/proto'
- _globals['_REGISTERAGENTREQUEST_METADATAENTRY']._loaded_options = None
- _globals['_REGISTERAGENTREQUEST_METADATAENTRY']._serialized_options = b'8\001'
- _globals['_STATE']._serialized_start=1657
- _globals['_STATE']._serialized_end=1745
+ _globals['_STATE']._serialized_start=1417
+ _globals['_STATE']._serialized_end=1505
_globals['_AGENTSTART']._serialized_start=76
_globals['_AGENTSTART']._serialized_end=159
_globals['_AGENTOUTPUTS']._serialized_start=161
_globals['_AGENTOUTPUTS']._serialized_end=206
_globals['_AGENTEND']._serialized_start=208
_globals['_AGENTEND']._serialized_end=218
- _globals['_AGENTMESSAGE']._serialized_start=221
- _globals['_AGENTMESSAGE']._serialized_end=384
- _globals['_MESSAGE']._serialized_start=386
- _globals['_MESSAGE']._serialized_end=462
- _globals['_CONVERSATIONEVENT']._serialized_start=465
- _globals['_CONVERSATIONEVENT']._serialized_end=596
- _globals['_EXECUTIONEVENT']._serialized_start=599
- _globals['_EXECUTIONEVENT']._serialized_end=804
- _globals['_HEALTHCHECKREQUEST']._serialized_start=806
- _globals['_HEALTHCHECKREQUEST']._serialized_end=826
- _globals['_HEALTHCHECKRESPONSE']._serialized_start=828
- _globals['_HEALTHCHECKRESPONSE']._serialized_end=883
- _globals['_EXECREQUEST']._serialized_start=885
- _globals['_EXECREQUEST']._serialized_end=1010
- _globals['_EXECRESPONSE']._serialized_start=1012
- _globals['_EXECRESPONSE']._serialized_end=1069
- _globals['_REMOTEAGENTCONFIG']._serialized_start=1071
- _globals['_REMOTEAGENTCONFIG']._serialized_end=1107
- _globals['_REGISTERAGENTREQUEST']._serialized_start=1110
- _globals['_REGISTERAGENTREQUEST']._serialized_end=1343
- _globals['_REGISTERAGENTREQUEST_METADATAENTRY']._serialized_start=1286
- _globals['_REGISTERAGENTREQUEST_METADATAENTRY']._serialized_end=1333
- _globals['_REGISTERAGENTRESPONSE']._serialized_start=1345
- _globals['_REGISTERAGENTRESPONSE']._serialized_end=1368
- _globals['_LISTREQUEST']._serialized_start=1370
- _globals['_LISTREQUEST']._serialized_end=1408
- _globals['_LISTRESPONSE']._serialized_start=1410
- _globals['_LISTRESPONSE']._serialized_end=1463
- _globals['_DELETEREQUEST']._serialized_start=1465
- _globals['_DELETEREQUEST']._serialized_end=1505
- _globals['_DELETERESPONSE']._serialized_start=1507
- _globals['_DELETERESPONSE']._serialized_end=1523
- _globals['_FORKREQUEST']._serialized_start=1525
- _globals['_FORKREQUEST']._serialized_end=1614
- _globals['_FORKRESPONSE']._serialized_start=1616
- _globals['_FORKRESPONSE']._serialized_end=1655
- _globals['_AGENTSERVICE']._serialized_start=1748
- _globals['_AGENTSERVICE']._serialized_end=1877
- _globals['_CONTROLLERSERVICE']._serialized_start=1880
- _globals['_CONTROLLERSERVICE']._serialized_end=2014
- _globals['_EVENTLOGSERVICE']._serialized_start=2017
- _globals['_EVENTLOGSERVICE']._serialized_end=2169
+ _globals['_AGENTREQUEST']._serialized_start=220
+ _globals['_AGENTREQUEST']._serialized_end=307
+ _globals['_AGENTRESPONSE']._serialized_start=310
+ _globals['_AGENTRESPONSE']._serialized_end=441
+ _globals['_MESSAGE']._serialized_start=443
+ _globals['_MESSAGE']._serialized_end=519
+ _globals['_CONVERSATIONEVENT']._serialized_start=522
+ _globals['_CONVERSATIONEVENT']._serialized_end=653
+ _globals['_EXECUTIONEVENT']._serialized_start=656
+ _globals['_EXECUTIONEVENT']._serialized_end=861
+ _globals['_HEALTHCHECKREQUEST']._serialized_start=863
+ _globals['_HEALTHCHECKREQUEST']._serialized_end=883
+ _globals['_HEALTHCHECKRESPONSE']._serialized_start=885
+ _globals['_HEALTHCHECKRESPONSE']._serialized_end=940
+ _globals['_HARNESSMESSAGE']._serialized_start=942
+ _globals['_HARNESSMESSAGE']._serialized_end=989
+ _globals['_EXECREQUEST']._serialized_start=991
+ _globals['_EXECREQUEST']._serialized_end=1116
+ _globals['_EXECRESPONSE']._serialized_start=1118
+ _globals['_EXECRESPONSE']._serialized_end=1175
+ _globals['_DELETECONVERSATIONREQUEST']._serialized_start=1177
+ _globals['_DELETECONVERSATIONREQUEST']._serialized_end=1229
+ _globals['_DELETECONVERSATIONRESPONSE']._serialized_start=1231
+ _globals['_DELETECONVERSATIONRESPONSE']._serialized_end=1259
+ _globals['_FORKCONVERSATIONREQUEST']._serialized_start=1261
+ _globals['_FORKCONVERSATIONREQUEST']._serialized_end=1362
+ _globals['_FORKCONVERSATIONRESPONSE']._serialized_start=1364
+ _globals['_FORKCONVERSATIONRESPONSE']._serialized_end=1415
+ _globals['_AGENTSERVICE']._serialized_start=1508
+ _globals['_AGENTSERVICE']._serialized_end=1636
+ _globals['_HARNESSSERVICE']._serialized_start=1638
+ _globals['_HARNESSSERVICE']._serialized_end=1709
+ _globals['_CONTROLLERSERVICE']._serialized_start=1711
+ _globals['_CONTROLLERSERVICE']._serialized_end=1775
+ _globals['_CONVERSATIONSERVICE']._serialized_start=1778
+ _globals['_CONVERSATIONSERVICE']._serialized_end=1963
# @@protoc_insertion_point(module_scope)
diff --git a/python/proto/ax_pb2_grpc.py b/python/proto/ax_pb2_grpc.py
index 5463f20..48b9ebd 100644
--- a/python/proto/ax_pb2_grpc.py
+++ b/python/proto/ax_pb2_grpc.py
@@ -17,7 +17,7 @@
import grpc
import warnings
-import ax_pb2 as proto_dot_ax__pb2
+from proto import ax_pb2 as proto_dot_ax__pb2
GRPC_GENERATED_VERSION = '1.80.0'
GRPC_VERSION = grpc.__version__
@@ -55,10 +55,10 @@ class AgentServiceStub(object):
Args:
channel: A grpc.Channel.
"""
- self.Connect = channel.stream_stream(
+ self.Connect = channel.unary_stream(
'/ax.AgentService/Connect',
- request_serializer=proto_dot_ax__pb2.AgentMessage.SerializeToString,
- response_deserializer=proto_dot_ax__pb2.AgentMessage.FromString,
+ request_serializer=proto_dot_ax__pb2.AgentRequest.SerializeToString,
+ response_deserializer=proto_dot_ax__pb2.AgentResponse.FromString,
_registered_method=True)
self.HealthCheck = channel.unary_unary(
'/ax.AgentService/HealthCheck',
@@ -77,7 +77,7 @@ class AgentServiceServicer(object):
we are solidifying resumption on the wire.
"""
- def Connect(self, request_iterator, context):
+ def Connect(self, request, context):
"""Connect is used by agents to connect to the controller.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -94,10 +94,10 @@ class AgentServiceServicer(object):
def add_AgentServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
- 'Connect': grpc.stream_stream_rpc_method_handler(
+ 'Connect': grpc.unary_stream_rpc_method_handler(
servicer.Connect,
- request_deserializer=proto_dot_ax__pb2.AgentMessage.FromString,
- response_serializer=proto_dot_ax__pb2.AgentMessage.SerializeToString,
+ request_deserializer=proto_dot_ax__pb2.AgentRequest.FromString,
+ response_serializer=proto_dot_ax__pb2.AgentResponse.SerializeToString,
),
'HealthCheck': grpc.unary_unary_rpc_method_handler(
servicer.HealthCheck,
@@ -123,7 +123,7 @@ class AgentService(object):
"""
@staticmethod
- def Connect(request_iterator,
+ def Connect(request,
target,
options=(),
channel_credentials=None,
@@ -133,12 +133,12 @@ class AgentService(object):
wait_for_ready=None,
timeout=None,
metadata=None):
- return grpc.experimental.stream_stream(
- request_iterator,
+ return grpc.experimental.unary_stream(
+ request,
target,
'/ax.AgentService/Connect',
- proto_dot_ax__pb2.AgentMessage.SerializeToString,
- proto_dot_ax__pb2.AgentMessage.FromString,
+ proto_dot_ax__pb2.AgentRequest.SerializeToString,
+ proto_dot_ax__pb2.AgentResponse.FromString,
options,
channel_credentials,
insecure,
@@ -177,6 +177,78 @@ class AgentService(object):
_registered_method=True)
+class HarnessServiceStub(object):
+ """Missing associated documentation comment in .proto file."""
+
+ def __init__(self, channel):
+ """Constructor.
+
+ Args:
+ channel: A grpc.Channel.
+ """
+ self.Connect = channel.stream_stream(
+ '/ax.HarnessService/Connect',
+ request_serializer=proto_dot_ax__pb2.HarnessMessage.SerializeToString,
+ response_deserializer=proto_dot_ax__pb2.HarnessMessage.FromString,
+ _registered_method=True)
+
+
+class HarnessServiceServicer(object):
+ """Missing associated documentation comment in .proto file."""
+
+ def Connect(self, request_iterator, context):
+ """Missing associated documentation comment in .proto file."""
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details('Method not implemented!')
+ raise NotImplementedError('Method not implemented!')
+
+
+def add_HarnessServiceServicer_to_server(servicer, server):
+ rpc_method_handlers = {
+ 'Connect': grpc.stream_stream_rpc_method_handler(
+ servicer.Connect,
+ request_deserializer=proto_dot_ax__pb2.HarnessMessage.FromString,
+ response_serializer=proto_dot_ax__pb2.HarnessMessage.SerializeToString,
+ ),
+ }
+ generic_handler = grpc.method_handlers_generic_handler(
+ 'ax.HarnessService', rpc_method_handlers)
+ server.add_generic_rpc_handlers((generic_handler,))
+ server.add_registered_method_handlers('ax.HarnessService', rpc_method_handlers)
+
+
+ # This class is part of an EXPERIMENTAL API.
+class HarnessService(object):
+ """Missing associated documentation comment in .proto file."""
+
+ @staticmethod
+ def Connect(request_iterator,
+ target,
+ options=(),
+ channel_credentials=None,
+ call_credentials=None,
+ insecure=False,
+ compression=None,
+ wait_for_ready=None,
+ timeout=None,
+ metadata=None):
+ return grpc.experimental.stream_stream(
+ request_iterator,
+ target,
+ '/ax.HarnessService/Connect',
+ proto_dot_ax__pb2.HarnessMessage.SerializeToString,
+ proto_dot_ax__pb2.HarnessMessage.FromString,
+ options,
+ channel_credentials,
+ insecure,
+ call_credentials,
+ compression,
+ wait_for_ready,
+ timeout,
+ metadata,
+ _registered_method=True)
+
+
class ControllerServiceStub(object):
"""Missing associated documentation comment in .proto file."""
@@ -191,11 +263,6 @@ class ControllerServiceStub(object):
request_serializer=proto_dot_ax__pb2.ExecRequest.SerializeToString,
response_deserializer=proto_dot_ax__pb2.ExecResponse.FromString,
_registered_method=True)
- self.RegisterAgent = channel.unary_unary(
- '/ax.ControllerService/RegisterAgent',
- request_serializer=proto_dot_ax__pb2.RegisterAgentRequest.SerializeToString,
- response_deserializer=proto_dot_ax__pb2.RegisterAgentResponse.FromString,
- _registered_method=True)
class ControllerServiceServicer(object):
@@ -209,13 +276,6 @@ class ControllerServiceServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
- def RegisterAgent(self, request, context):
- """RegisterAgent registers a new agent with the controller
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details('Method not implemented!')
- raise NotImplementedError('Method not implemented!')
-
def add_ControllerServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
@@ -224,11 +284,6 @@ def add_ControllerServiceServicer_to_server(servicer, server):
request_deserializer=proto_dot_ax__pb2.ExecRequest.FromString,
response_serializer=proto_dot_ax__pb2.ExecResponse.SerializeToString,
),
- 'RegisterAgent': grpc.unary_unary_rpc_method_handler(
- servicer.RegisterAgent,
- request_deserializer=proto_dot_ax__pb2.RegisterAgentRequest.FromString,
- response_serializer=proto_dot_ax__pb2.RegisterAgentResponse.SerializeToString,
- ),
}
generic_handler = grpc.method_handlers_generic_handler(
'ax.ControllerService', rpc_method_handlers)
@@ -267,35 +322,8 @@ class ControllerService(object):
metadata,
_registered_method=True)
- @staticmethod
- def RegisterAgent(request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- insecure=False,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None):
- return grpc.experimental.unary_unary(
- request,
- target,
- '/ax.ControllerService/RegisterAgent',
- proto_dot_ax__pb2.RegisterAgentRequest.SerializeToString,
- proto_dot_ax__pb2.RegisterAgentResponse.FromString,
- options,
- channel_credentials,
- insecure,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- _registered_method=True)
-
-class EventLogServiceStub(object):
+class ConversationServiceStub(object):
"""Missing associated documentation comment in .proto file."""
def __init__(self, channel):
@@ -304,34 +332,22 @@ class EventLogServiceStub(object):
Args:
channel: A grpc.Channel.
"""
- self.List = channel.unary_unary(
- '/ax.EventLogService/List',
- request_serializer=proto_dot_ax__pb2.ListRequest.SerializeToString,
- response_deserializer=proto_dot_ax__pb2.ListResponse.FromString,
- _registered_method=True)
- self.Delete = channel.unary_unary(
- '/ax.EventLogService/Delete',
- request_serializer=proto_dot_ax__pb2.DeleteRequest.SerializeToString,
- response_deserializer=proto_dot_ax__pb2.DeleteResponse.FromString,
+ self.DeleteConversation = channel.unary_unary(
+ '/ax.ConversationService/DeleteConversation',
+ request_serializer=proto_dot_ax__pb2.DeleteConversationRequest.SerializeToString,
+ response_deserializer=proto_dot_ax__pb2.DeleteConversationResponse.FromString,
_registered_method=True)
- self.Fork = channel.unary_unary(
- '/ax.EventLogService/Fork',
- request_serializer=proto_dot_ax__pb2.ForkRequest.SerializeToString,
- response_deserializer=proto_dot_ax__pb2.ForkResponse.FromString,
+ self.ForkConversation = channel.unary_unary(
+ '/ax.ConversationService/ForkConversation',
+ request_serializer=proto_dot_ax__pb2.ForkConversationRequest.SerializeToString,
+ response_deserializer=proto_dot_ax__pb2.ForkConversationResponse.FromString,
_registered_method=True)
-class EventLogServiceServicer(object):
+class ConversationServiceServicer(object):
"""Missing associated documentation comment in .proto file."""
- def List(self, request, context):
- """List conversational events.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details('Method not implemented!')
- raise NotImplementedError('Method not implemented!')
-
- def Delete(self, request, context):
+ def DeleteConversation(self, request, context):
"""Deletes conversational events and all event log resources
for its children executions.
"""
@@ -339,7 +355,7 @@ class EventLogServiceServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
- def Fork(self, request, context):
+ def ForkConversation(self, request, context):
"""Fork forks an event log from a specific conversation.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -347,63 +363,31 @@ class EventLogServiceServicer(object):
raise NotImplementedError('Method not implemented!')
-def add_EventLogServiceServicer_to_server(servicer, server):
+def add_ConversationServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
- 'List': grpc.unary_unary_rpc_method_handler(
- servicer.List,
- request_deserializer=proto_dot_ax__pb2.ListRequest.FromString,
- response_serializer=proto_dot_ax__pb2.ListResponse.SerializeToString,
- ),
- 'Delete': grpc.unary_unary_rpc_method_handler(
- servicer.Delete,
- request_deserializer=proto_dot_ax__pb2.DeleteRequest.FromString,
- response_serializer=proto_dot_ax__pb2.DeleteResponse.SerializeToString,
+ 'DeleteConversation': grpc.unary_unary_rpc_method_handler(
+ servicer.DeleteConversation,
+ request_deserializer=proto_dot_ax__pb2.DeleteConversationRequest.FromString,
+ response_serializer=proto_dot_ax__pb2.DeleteConversationResponse.SerializeToString,
),
- 'Fork': grpc.unary_unary_rpc_method_handler(
- servicer.Fork,
- request_deserializer=proto_dot_ax__pb2.ForkRequest.FromString,
- response_serializer=proto_dot_ax__pb2.ForkResponse.SerializeToString,
+ 'ForkConversation': grpc.unary_unary_rpc_method_handler(
+ servicer.ForkConversation,
+ request_deserializer=proto_dot_ax__pb2.ForkConversationRequest.FromString,
+ response_serializer=proto_dot_ax__pb2.ForkConversationResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
- 'ax.EventLogService', rpc_method_handlers)
+ 'ax.ConversationService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
- server.add_registered_method_handlers('ax.EventLogService', rpc_method_handlers)
+ server.add_registered_method_handlers('ax.ConversationService', rpc_method_handlers)
# This class is part of an EXPERIMENTAL API.
-class EventLogService(object):
+class ConversationService(object):
"""Missing associated documentation comment in .proto file."""
@staticmethod
- def List(request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- insecure=False,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None):
- return grpc.experimental.unary_unary(
- request,
- target,
- '/ax.EventLogService/List',
- proto_dot_ax__pb2.ListRequest.SerializeToString,
- proto_dot_ax__pb2.ListResponse.FromString,
- options,
- channel_credentials,
- insecure,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- _registered_method=True)
-
- @staticmethod
- def Delete(request,
+ def DeleteConversation(request,
target,
options=(),
channel_credentials=None,
@@ -416,9 +400,9 @@ class EventLogService(object):
return grpc.experimental.unary_unary(
request,
target,
- '/ax.EventLogService/Delete',
- proto_dot_ax__pb2.DeleteRequest.SerializeToString,
- proto_dot_ax__pb2.DeleteResponse.FromString,
+ '/ax.ConversationService/DeleteConversation',
+ proto_dot_ax__pb2.DeleteConversationRequest.SerializeToString,
+ proto_dot_ax__pb2.DeleteConversationResponse.FromString,
options,
channel_credentials,
insecure,
@@ -430,7 +414,7 @@ class EventLogService(object):
_registered_method=True)
@staticmethod
- def Fork(request,
+ def ForkConversation(request,
target,
options=(),
channel_credentials=None,
@@ -443,9 +427,9 @@ class EventLogService(object):
return grpc.experimental.unary_unary(
request,
target,
- '/ax.EventLogService/Fork',
- proto_dot_ax__pb2.ForkRequest.SerializeToString,
- proto_dot_ax__pb2.ForkResponse.FromString,
+ '/ax.ConversationService/ForkConversation',
+ proto_dot_ax__pb2.ForkConversationRequest.SerializeToString,
+ proto_dot_ax__pb2.ForkConversationResponse.FromString,
options,
channel_credentials,
insecure,