Skip to content

armgit / ax

Public Imported from GitHub
0

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

Go

Remove docker agent example (#159)

JoyceLiu2ac395bae293
diff --git a/examples/docker_agent/ax.yaml b/examples/docker_agent/ax.yaml
deleted file mode 100644
index e165a04..0000000
--- a/examples/docker_agent/ax.yaml
+++ /dev/null
@@ -1,33 +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.
-
-server:
- address: ":8494"
-
-eventlog:
- sqlite:
- filename: "examples/docker_agent/eventlog/log.sqlite"
-
-planner:
- type: "gemini"
- gemini:
- model: "gemini-3.5-flash"
- timeout: "60s"
-
-registry:
- remote_agents:
- - id: "DockerAgent"
- name: "Docker Agent"
- description: "Agent specialized in generating Dockerfiles. Call this agent whenever the user request involves creating, writing, or generating a Dockerfile."
- address: "localhost:50052"
diff --git a/examples/docker_agent/main.go b/examples/docker_agent/main.go
deleted file mode 100644
index a0976e7..0000000
--- a/examples/docker_agent/main.go
+++ /dev/null
@@ -1,266 +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 (
- "context"
- "errors"
- "fmt"
- "log"
- "net"
- "os"
-
- "google.golang.org/genai"
- "google.golang.org/grpc"
-
- "github.com/google/ax/internal/skills"
- "github.com/google/ax/proto"
- "github.com/google/uuid"
-)
-
-const port = ":50052"
-
-type server struct {
- proto.UnimplementedAgentServiceServer
- genaiClient *genai.Client
- skillsExecutor *skills.Executor
-}
-
-func (s *server) Connect(req *proto.AgentRequest, stream grpc.ServerStreamingServer[proto.AgentResponse]) error {
- start := req.GetStart()
- if start == nil {
- return errors.New("missing start message")
- }
-
- contents := protoToContents(start.Messages)
-
- for {
- model := os.Getenv("AX_GEMINI_MODEL")
- if model == "" {
- model = "gemini-3.5-flash"
- }
- resp, err := s.genaiClient.Models.GenerateContent(stream.Context(), model, contents, &genai.GenerateContentConfig{
- SystemInstruction: genai.Text("You are DockerAgent, an agent specialized in writing Dockerfiles. Use the docker-writer skill to fulfill requests. Keep responses concise.")[0],
- Tools: []*genai.Tool{skills.BuildTool(s.skillsExecutor.SkillNames())},
- })
- if err != nil {
- return fmt.Errorf("failed to generate content: %w", err)
- }
-
- if len(resp.Candidates) == 0 {
- return errors.New("no candidates from Gemini")
- }
- candidate := resp.Candidates[0]
-
- var keepLooping bool
- var functionCall *genai.FunctionCall
- var thoughtSignature []byte
-
- for _, part := range candidate.Content.Parts {
- if part.FunctionCall != nil {
- functionCall = part.FunctionCall
- thoughtSignature = part.ThoughtSignature
- break
- }
- }
-
- if functionCall != nil {
- if functionCall.ID == "" {
- functionCall.ID = uuid.NewString()
- }
-
- // Handle skill call
- result, err := s.skillsExecutor.HandleCall(stream.Context(), functionCall)
- if err != nil {
- return fmt.Errorf("failed to handle skill call: %w", err)
- }
-
- // Append function call and response to history
- contents = append(contents, &genai.Content{
- Role: "model",
- Parts: []*genai.Part{{
- FunctionCall: functionCall,
- ThoughtSignature: thoughtSignature,
- }},
- })
- contents = append(contents, &genai.Content{
- Role: "user",
- Parts: []*genai.Part{{
- FunctionResponse: &genai.FunctionResponse{
- ID: functionCall.ID,
- Name: functionCall.Name,
- Response: map[string]any{"result": result.Stdout},
- },
- }},
- })
-
- if functionCall.Name == "activate_skill" {
- keepLooping = true
- }
- }
-
- // Send text output if any (regardless of keepLooping)
- for _, part := range candidate.Content.Parts {
- if part.Text != "" {
- responseMsg := &proto.Message{
- Role: "assistant",
- Content: &proto.Content{
- Type: &proto.Content_Text{
- Text: &proto.TextContent{Text: "[DockerAgent] " + part.Text},
- },
- },
- }
- if err := stream.Send(&proto.AgentResponse{
- ConversationId: req.ConversationId,
- ExecId: req.ExecId,
- Type: &proto.AgentResponse_Outputs{
- Outputs: &proto.AgentOutputs{
- Messages: []*proto.Message{responseMsg},
- },
- },
- }); err != nil {
- return err
- }
- }
- }
-
- if !keepLooping {
- break
- }
- }
-
- fmt.Println("DockerAgent finished execution turn.")
-
- // Send AgentEnd
- return stream.Send(&proto.AgentResponse{
- ConversationId: req.ConversationId,
- ExecId: req.ExecId,
- Type: &proto.AgentResponse_End{
- End: &proto.AgentEnd{},
- },
- })
-}
-
-// protoToContents converts history to Gemini conversation format.
-func protoToContents(inputs []*proto.Message) []*genai.Content {
- var contents []*genai.Content
- for _, msg := range inputs {
- if msg.GetInternalOnly() {
- continue
- }
- role := msg.Role
- if role != "user" {
- role = "model"
- }
-
- content := msg.GetContent()
- if content == nil {
- continue
- }
-
- switch m := content.Type.(type) {
- case *proto.Content_Text:
- contents = append(contents, &genai.Content{
- Role: role,
- Parts: []*genai.Part{
- {
- Text: m.Text.Text,
- },
- },
- })
- case *proto.Content_Confirmation:
- // shouldn't be sent to Gemini
- switch m.Confirmation.Decision.(type) {
- case *proto.ConfirmationContent_Decline:
- // shouldn't be sent to Gemini
- case *proto.ConfirmationContent_Approval:
- // shouldn't be sent to Gemini
- }
- case *proto.Content_ToolCall:
- tc := m.ToolCall
- if fc := tc.GetFunctionCall(); fc != nil {
- contents = append(contents, &genai.Content{
- Role: "model",
- Parts: []*genai.Part{
- {
- ThoughtSignature: tc.Signature,
- FunctionCall: &genai.FunctionCall{
- ID: tc.Id,
- Name: fc.Name,
- Args: fc.Arguments.AsMap(),
- },
- },
- },
- })
- }
- case *proto.Content_ToolResult:
- tr := m.ToolResult
- if fr := tr.GetFunctionResult(); fr != nil {
- var respMap map[string]any
- if fr.GetResponse() != nil {
- respMap = fr.GetResponse().AsMap()
- }
- contents = append(contents, &genai.Content{
- Role: "user",
- Parts: []*genai.Part{
- {
- FunctionResponse: &genai.FunctionResponse{
- ID: tr.CallId,
- Name: fr.Name,
- Response: respMap,
- },
- },
- },
- })
- }
- }
- }
- return contents
-}
-
-func (s *server) HealthCheck(ctx context.Context, req *proto.HealthCheckRequest) (*proto.HealthCheckResponse, error) {
- return &proto.HealthCheckResponse{
- Healthy: true,
- Message: "DockerAgent is healthy",
- }, nil
-}
-
-func main() {
- ctx := context.Background()
- client, err := genai.NewClient(ctx, &genai.ClientConfig{})
- if err != nil {
- log.Fatalf("Failed to create GenAI client: %v", err)
- }
-
- // Create skills executor pointing to the local skills directory
- skillsExecutor, err := skills.NewExecutor("./examples/docker_agent/skills")
- if err != nil {
- log.Fatalf("Failed to create skills executor: %v", err)
- }
-
- 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{genaiClient: client, skillsExecutor: skillsExecutor})
-
- fmt.Println("\nDockerAgent server is running...")
- if err := grpcServer.Serve(lis); err != nil {
- log.Fatalf("Failed to serve: %v", err)
- }
-}
diff --git a/examples/docker_agent/run_docker_agent.sh b/examples/docker_agent/run_docker_agent.sh
deleted file mode 100755
index 2deed4a..0000000
--- a/examples/docker_agent/run_docker_agent.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/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.
-
-# Exit immediately if a command exits with a non-zero status
-set -e
-
-# Function to cleanup background processes
-cleanup() {
- echo "Cleaning up background processes..."
- jobs -p | xargs -I {} kill {} 2>/dev/null || true
-}
-trap cleanup EXIT
-
-echo "Cleaning up port 50052 if in use..."
-kill -9 $(lsof -t -i:50052) 2>/dev/null || true
-
-echo "Starting DockerAgent in background..."
-go run examples/docker_agent/main.go &
-
-echo "Waiting for agent to be ready..."
-sleep 3
-
-echo "Running test client..."
-go run examples/docker_agent/test/test_docker_agent.go
diff --git a/examples/docker_agent/run_e2e.sh b/examples/docker_agent/run_e2e.sh
deleted file mode 100755
index 3c4f134..0000000
--- a/examples/docker_agent/run_e2e.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/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.
-
-# Exit immediately if a command exits with a non-zero status
-set -e
-
-# Function to cleanup background processes
-cleanup() {
- echo "Cleaning up background processes..."
- jobs -p | xargs -I {} kill {} 2>/dev/null || true
-}
-trap cleanup EXIT
-
-echo "Cleaning up port 50052 if in use..."
-kill -9 $(lsof -t -i:50052) 2>/dev/null || true
-
-echo "Starting DockerAgent in background..."
-go run examples/docker_agent/main.go &
-AGENT_PID=$!
-
-echo "Starting AX Server in background..."
-/opt/homebrew/bin/go build -o bin/ax ./cmd/ax
-./bin/ax serve --config examples/docker_agent/ax.yaml &
-SERVER_PID=$!
-
-# Give servers a few seconds to start up
-echo "Waiting for servers to be ready..."
-for i in {1..30}; do
- if (echo > /dev/tcp/localhost/50052) >/dev/null 2>&1 && (echo > /dev/tcp/localhost/8494) >/dev/null 2>&1; then
- echo "Servers are ready!"
- break
- fi
- echo "Waiting..."
- sleep 1
-done
-
-echo "Executing task..."
-./bin/ax exec --server localhost:8494 --input "Write a Dockerfile for a Python flask app that says hello world."
-
-# Wait for the exec command to finish
-# The trap will kill the background servers when the script exits
diff --git a/examples/docker_agent/skills/docker-writer/SKILL.md b/examples/docker_agent/skills/docker-writer/SKILL.md
deleted file mode 100644
index 1d8df18..0000000
--- a/examples/docker_agent/skills/docker-writer/SKILL.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-name: docker-writer
-description: Skill for writing Dockerfiles based on user requirements.
----
-
-# Instructions
-You are the Docker Writer skill. Your job is to generate a Dockerfile directly in the response.
-
-**IMPORTANT**: There are no scripts in this skill's directory. Do NOT attempt to call `run_skill_script`. Just generate the Dockerfile content directly as text in your response.
-
-1. Analyze the user's request for language, dependencies, and environment.
-2. Generate a well-commented Dockerfile.
-3. Output the Dockerfile content directly.
diff --git a/examples/docker_agent/test/test_docker_agent.go b/examples/docker_agent/test/test_docker_agent.go
deleted file mode 100644
index 74d9a55..0000000
--- a/examples/docker_agent/test/test_docker_agent.go
+++ /dev/null
@@ -1,80 +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 (
- "context"
- "fmt"
- "log"
-
- "google.golang.org/grpc"
- "google.golang.org/grpc/credentials/insecure"
-
- "github.com/google/ax/proto"
-)
-
-func main() {
- fmt.Println("Connecting to DockerAgent at localhost:50052...")
- conn, err := grpc.NewClient("localhost:50052", grpc.WithTransportCredentials(insecure.NewCredentials()))
- if err != nil {
- log.Fatalf("Failed to connect: %v", err)
- }
- defer conn.Close()
-
- client := proto.NewAgentServiceClient(conn)
- fmt.Println("Sending request to write a Dockerfile...")
- req := &proto.AgentRequest{
- ConversationId: "test-conversation-id",
- ExecId: "test-exec-id",
- Start: &proto.AgentStart{
- AgentId: "DockerAgent",
- Messages: []*proto.Message{
- {
- Role: "user",
- Content: &proto.Content{
- Type: &proto.Content_Text{
- Text: &proto.TextContent{Text: "Write a Dockerfile for a simple Node.js app."},
- },
- },
- },
- },
- },
- }
-
- stream, err := client.Connect(context.Background(), req)
- if err != nil {
- log.Fatalf("Failed to open stream: %v", err)
- }
-
- fmt.Println("Waiting for response...")
- // Read responses
- for {
- resp, err := stream.Recv()
- if err != nil {
- log.Fatalf("Error receiving: %v", err)
- }
- if resp.GetEnd() != nil {
- fmt.Println("\n\n[Agent finished]")
- break
- }
- if outputs := resp.GetOutputs(); outputs != nil {
- for _, m := range outputs.Messages {
- if txt := m.GetContent().GetText(); txt != nil {
- fmt.Print(txt.Text)
- }
- }
- }
- }
-}