Skip to content

armgit / ax

Public Imported from GitHub
0

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

Go

Antigravity and AX integration - skills (#218)

JoyceLiu6f8f97b907e7
diff --git a/ax.yaml b/ax.yaml
index a8e8d0d..ec9823c 100644
--- a/ax.yaml
+++ b/ax.yaml
@@ -20,11 +20,26 @@ eventlog:
filename: "eventlog/log.sqlite"
planner:
+ # Type of planner to use: "gemini" or "antigravity" (default: "gemini")
+ # Note: Only the configuration block matching this type will be active.
+ type: "antigravity"
+
+ # The Gemini planner uses Google's Gemini models for planning.
gemini:
model: "gemini-3-flash-preview"
timeout: "60s"
skills_dir: "./examples/skills"
+ # The Antigravity planner uses an external Python sidecar. See README for instructions.
+ antigravity:
+ endpoint: "http://localhost:8085/plan"
+
+
+ model: "MODEL_PLACEHOLDER_M18"
+ skills_dir: "./examples/skills"
+
+# Remote agents configuration (optional)
+# List of remote or sandbox agents to register on startup.
registry:
# remote_agents:
# - id: "medical-deep-researcher"
diff --git a/cmd/ax/exec.go b/cmd/ax/exec.go
index 5e8c707..befb927 100644
--- a/cmd/ax/exec.go
+++ b/cmd/ax/exec.go
@@ -314,6 +314,12 @@ func displayContents(d *internal.Display, contents []*proto.Message) {
}
}
}
+ case *proto.Content_Thought:
+ for _, summary := range o.Thought.GetSummary() {
+ if textContent := summary.GetText(); textContent != nil {
+ d.DisplayOutput(fmt.Sprintf("Thinking: %s", textContent.Text))
+ }
+ }
default:
d.DisplayOutput(fmt.Sprintf("unknown output type: %v", o))
}
diff --git a/cmd/ax/serve.go b/cmd/ax/serve.go
index 9ff39ef..5931a52 100644
--- a/cmd/ax/serve.go
+++ b/cmd/ax/serve.go
@@ -80,7 +80,6 @@ func runServe(cmd *cobra.Command, args []string) error {
log.Println("\nReceived interrupt, shutting down...")
srv.GracefulStop()
}()
-
log.Printf("Starting AX server at %s...\n", cfg.Server.Address)
if err := srv.Serve(cfg.Server.Address); err != nil {
return fmt.Errorf("error serving: %w", err)
@@ -98,23 +97,28 @@ func newControllerFromConfig(ctx context.Context, cfg *config.Config) (*controll
// Create planner builder
plannerBuilder := func(ctx context.Context, r *controller.Registry) (agent.Agent, error) {
- // The builder defines which planner to use.
- // Currently, it uses the Gemini planner.
- // Gemini config can be customized via environment variables (GEMINI_API_KEY, AX_GEMINI_MODEL)
- // TODO(lhuan): allow other planners based on cfg.PlannerType
- timeout, err := time.ParseDuration(cfg.Planner.Gemini.Timeout)
- if err != nil {
- return nil, fmt.Errorf("failed to parse duration: %v", err)
+ switch cfg.Planner.Type {
+ case "antigravity":
+ return controller.NewAntigravityPlannerAgent(ctx, r, controller.AntigravityPlannerConfig{
+ Endpoint: cfg.Planner.Antigravity.Endpoint,
+ })
+ case "gemini":
+ timeout, err := time.ParseDuration(cfg.Planner.Gemini.Timeout)
+ if err != nil {
+ return nil, fmt.Errorf("failed to parse duration: %v", err)
+ }
+ return controller.NewGeminiPlannerAgent(ctx, r, controller.GeminiPlannerConfig{
+ GeminiConfig: &proto.GeminiConfig{
+ Model: cfg.Planner.Gemini.Model,
+ MaxTokens: cfg.Planner.Gemini.MaxTokens,
+ Timeout: durationpb.New(timeout),
+ SystemPrompt: cfg.Planner.Gemini.SystemPrompt,
+ },
+ SkillsDir: cfg.Planner.Gemini.SkillsDir,
+ })
+ default:
+ return nil, fmt.Errorf("unknown planner type: %s", cfg.Planner.Type)
}
- return controller.NewGeminiPlannerAgent(ctx, r, controller.GeminiPlannerConfig{
- GeminiConfig: &proto.GeminiConfig{
- Model: cfg.Planner.Gemini.Model,
- MaxTokens: cfg.Planner.Gemini.MaxTokens,
- Timeout: durationpb.New(timeout),
- SystemPrompt: cfg.Planner.Gemini.SystemPrompt,
- },
- SkillsDir: cfg.Planner.Gemini.SkillsDir,
- })
}
// Build controller config
diff --git a/internal/config/config.go b/internal/config/config.go
index e8a8729..cdd2b65 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -61,7 +61,22 @@ type EventLogConfig struct {
// PlannerConfig configures the planner.
type PlannerConfig struct {
- Gemini GeminiPlannerConfig `yaml:"gemini"`
+ Type string `yaml:"type"` // "gemini" or "antigravity"
+ Gemini GeminiPlannerConfig `yaml:"gemini,omitempty"`
+ Antigravity AntigravityPlannerConfig `yaml:"antigravity,omitempty"`
+}
+
+// AntigravityPlannerConfig configures the Antigravity-based planner.
+// TODO: Support additional Antigravity SDK features (e.g., custom tools, hooks, MCP servers, agentic mode).
+type AntigravityPlannerConfig struct {
+ Endpoint string `yaml:"endpoint,omitempty"` // URL of the Python sidecar
+}
+
+// setDefaults sets default values for AntigravityPlannerConfig.
+func (c *AntigravityPlannerConfig) setDefaults() {
+ if c.Endpoint == "" {
+ c.Endpoint = "http://localhost:8085/plan"
+ }
}
// GeminiPlannerConfig configures the Gemini-based planner.
@@ -165,11 +180,18 @@ func (c *Config) setDefaults() {
c.Server.Address = ":8494"
}
- // EventLog defaults
if c.EventLog.SQLiteConfig.Filename == "" {
c.EventLog.SQLiteConfig.Filename = "eventlog/log.sqlite"
}
+ // Planner defaults
+ if c.Planner.Type == "" {
+ c.Planner.Type = "gemini"
+ }
+ if c.Planner.Type == "antigravity" {
+ c.Planner.Antigravity.setDefaults()
+ }
+
}
// Validate validates the configuration.
diff --git a/internal/controller/antigravity_planner.go b/internal/controller/antigravity_planner.go
new file mode 100644
index 0000000..5e004bd
--- /dev/null
+++ b/internal/controller/antigravity_planner.go
@@ -0,0 +1,224 @@
+// 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 controller
+
+import (
+ "bufio"
+ "bytes"
+ "context"
+ "encoding/json"
+ "fmt"
+ "log"
+ "net/http"
+ "time"
+
+ "github.com/google/ax/internal/agent"
+ "github.com/google/ax/proto"
+)
+
+const (
+ streamResponseInitialBufferSize = 64 * 1024 // 64 KB
+ streamResponseMaxBufferSize = 1024 * 1024 // 1 MB
+)
+
+// AntigravityPlannerConfig configures the Antigravity-based planner.
+type AntigravityPlannerConfig struct {
+ Endpoint string
+ Timeout string
+}
+
+// AntigravityPlannerAgent implements the agent.Agent interface by calling an external Python server.
+type AntigravityPlannerAgent struct {
+ registry *Registry
+ config AntigravityPlannerConfig
+ httpClient *http.Client
+}
+
+// NewAntigravityPlannerAgent creates a new Antigravity-based planner agent.
+func NewAntigravityPlannerAgent(ctx context.Context, registry *Registry, cfg AntigravityPlannerConfig) (agent.Agent, error) {
+ timeoutStr := cfg.Timeout
+ if timeoutStr == "" {
+ // TODO(lhuan): optimize and reduce latency
+ timeoutStr = "5m" // Default timeout
+ }
+ timeout, err := time.ParseDuration(timeoutStr)
+ if err != nil {
+ return nil, fmt.Errorf("failed to parse duration %q: %w", timeoutStr, err)
+ }
+ return &AntigravityPlannerAgent{
+ registry: registry,
+ config: cfg,
+ httpClient: &http.Client{
+ Timeout: timeout,
+ },
+ }, nil
+}
+
+// Connect starts the agent loop.
+func (p *AntigravityPlannerAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {
+ return p.loop(ctx, execID, start, e, handler)
+}
+
+// loop is the main execution loop for the Antigravity planner.
+func (p *AntigravityPlannerAgent) loop(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {
+ payload, err := p.preparePayload(execID, start)
+ if err != nil {
+ return err
+ }
+
+ resp, err := p.sendRequest(ctx, payload)
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
+
+ return p.handleStreamingResponse(ctx, resp, handler)
+}
+
+func (p *AntigravityPlannerAgent) preparePayload(execID string, start *proto.AgentStart) ([]byte, error) {
+ type Message struct {
+ Role string `json:"role"`
+ Text string `json:"text"`
+ }
+ var messages []Message
+ for _, msg := range start.Messages {
+ role := msg.Role
+ text := ""
+ if msg.Content != nil {
+ switch content := msg.Content.Type.(type) {
+ case *proto.Content_Text:
+ text = content.Text.Text
+ }
+ // TODO: Add support for other content types.
+ }
+ messages = append(messages, Message{
+ Role: role,
+ Text: text,
+ })
+ }
+
+ reqData := map[string]interface{}{
+ "conversation_id": execID,
+ "messages": messages,
+ }
+
+ return json.Marshal(reqData)
+}
+
+func (p *AntigravityPlannerAgent) sendRequest(ctx context.Context, payload []byte) (*http.Response, error) {
+ log.Printf("Sending request to Antigravity Server at %s", p.config.Endpoint)
+ req, err := http.NewRequestWithContext(ctx, "POST", p.config.Endpoint, bytes.NewBuffer(payload))
+ if err != nil {
+ return nil, fmt.Errorf("failed to create request: %w", err)
+ }
+ req.Header.Set("Content-Type", "application/json")
+
+ resp, err := p.httpClient.Do(req)
+ if err != nil {
+ return nil, fmt.Errorf("failed to call Antigravity Server: %w", err)
+ }
+
+ if resp.StatusCode != http.StatusOK {
+ resp.Body.Close()
+ return nil, fmt.Errorf("Antigravity Server returned error status: %s", resp.Status)
+ }
+
+ return resp, nil
+}
+
+func (p *AntigravityPlannerAgent) handleStreamingResponse(ctx context.Context, resp *http.Response, handler agent.OutputHandler) error {
+ scanner := bufio.NewScanner(resp.Body)
+ buf := make([]byte, 0, streamResponseInitialBufferSize)
+ scanner.Buffer(buf, streamResponseMaxBufferSize)
+
+ for scanner.Scan() {
+ line := scanner.Bytes()
+ if len(line) == 0 {
+ continue
+ }
+
+ // TODO(lhuan): to update / add more types per antigravity proto
+ var result struct {
+ Type string `json:"type"`
+ Text string `json:"text,omitempty"`
+ ToolCall *struct {
+ Name string `json:"name"`
+ Args map[string]interface{} `json:"args"`
+ } `json:"tool_call,omitempty"`
+ }
+ if err := json.Unmarshal(line, &result); err != nil {
+ log.Printf("Failed to unmarshal streaming chunk: %v", err)
+ continue
+ }
+
+ switch result.Type {
+ case "thinking":
+ handler(&proto.AgentOutputs{
+ Messages: []*proto.Message{
+ {
+ Role: "assistant",
+ Content: &proto.Content{
+ Type: &proto.Content_Thought{
+ Thought: &proto.ThoughtContent{
+ Summary: []*proto.ThoughtSummaryContent{
+ {
+ Type: &proto.ThoughtSummaryContent_Text{
+ Text: &proto.TextContent{Text: result.Text},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ })
+
+ case "text":
+ handler(&proto.AgentOutputs{
+ Messages: []*proto.Message{
+ {
+ Role: "assistant",
+ Content: &proto.Content{
+ Type: &proto.Content_Text{
+ Text: &proto.TextContent{Text: result.Text},
+ },
+ },
+ },
+ },
+ })
+
+ // TODO(lhuan): Support tool_call and tool_result types when needed.
+ default:
+ log.Printf("Warning: unhandled response type: %s", result.Type)
+ }
+ }
+
+ if err := scanner.Err(); err != nil {
+ return fmt.Errorf("error reading streaming response: %w", err)
+ }
+
+ return nil
+}
+
+// HealthCheck implements the agent.Agent interface.
+func (p *AntigravityPlannerAgent) HealthCheck(ctx context.Context) error {
+ return nil
+}
+
+// Close implements the agent.Agent interface.
+func (p *AntigravityPlannerAgent) Close() error {
+ return nil
+}