Agent Executor (AX) is Google's open agentic orchestration runtime
Go
takes planner config from yaml + default model to 3.0-flash-preview (#8)
JoyceLiue7d5c10ed75b
diff --git a/cmd/gar/serve.go b/cmd/gar/serve.goindex 5e65412..878c4c5 100644--- a/cmd/gar/serve.go+++ b/cmd/gar/serve.go@@ -95,11 +95,25 @@ func newControllerFromConfig(ctx context.Context, cfg *config.Config) (*controll})}+ // Create planner factory+ plannerFactory := func(ctx context.Context, r *controller.Registry) (controller.PlanFunc, error) {++ // The factory defines which planner to use.+ // Currently, it uses the Gemini planner.+ // Gemini config can be customized via environment variables (GEMINI_API_KEY, GAR_GEMINI_MODEL)+ // TODO(lhuan): allow other planners based on cfg.PlannerType+ return controller.NewGeminiPlanFunc(ctx, r, controller.GeminiPlannerConfig{+ Model: cfg.Planner.Gemini.Model,+ MaxTokens: cfg.Planner.Gemini.MaxTokens,+ Timeout: cfg.Planner.Gemini.Timeout,+ SystemPrompt: cfg.Planner.Gemini.SystemPrompt,+ })+ }+// Build controller config- // The controller will create a default Gemini planner if PlanFunc is nil- // Gemini config can be customized via environment variables (GEMINI_API_KEY, GAR_GEMINI_MODEL)controllerConfig := controller.Config{EventLogFactory: eventLogFactory,+ PlannerFactory: plannerFactory,MaxSteps: cfg.MaxSteps,HealthCheckInterval: cfg.HealthCheckInterval,}diff --git a/gar.yaml b/gar.yamlindex d26a05f..7ddc77a 100644--- a/gar.yaml+++ b/gar.yaml@@ -28,31 +28,28 @@ max_steps: 50# Health check interval for agents (e.g., "30s", "1m")health_check_interval: 30s-# Gemini planner configuration (optional)-# The Gemini planner uses Google's Gemini models for intelligent agent selection.-# API key must be set via GEMINI_API_KEY environment variable (required).-# Model name can be set via GAR_GEMINI_MODEL environment variable (optional).-#-# gemini_planner:-# Set GEMINI_API_KEY for authentication.-#-# # Model name (e.g., "gemini-2.5-flash")-# model: "gemini-flash-latest"-#-# # Temperature for generation (0.0 to 1.0)-# temperature: 0.7-#-# # Maximum output tokens-# max_tokens: 8192-#-# # Request timeout (e.g., "30s", "1m")-# timeout: 60s-#-# # Number of recent messages to include in context-# context_window: 30-#-# # Custom system prompt for the planner (optional)-# system_prompt: ""+# Planner configuration (optional)+# planner:+# # Gemini planner configuration+# # The Gemini planner uses Google's Gemini models for intelligent agent selection.+# gemini:+# # Model name (e.g., "gemini-3-flash")+# model: "gemini-3-flash-preview"+#+# # Temperature for generation (0.0 to 1.0)+# temperature: 0.7+#+# # Maximum output tokens+# max_tokens: 8192+#+# # Request timeout (e.g., "30s", "1m")+# timeout: 60s+#+# # Number of recent messages to include in context+# context_window: 30+#+# # Custom system prompt for the planner (optional)+# system_prompt: ""# Remote agents configuration (optional)# List of remote agents to register on startup.diff --git a/internal/config/config.go b/internal/config/config.goindex 737e43d..7dd2f46 100644--- a/internal/config/config.go+++ b/internal/config/config.go@@ -30,10 +30,15 @@ type Config struct {EventLog EventLogConfig `yaml:"eventlog"`MaxSteps int `yaml:"max_steps"` // Maximum steps per triggerHealthCheckInterval time.Duration `yaml:"health_check_interval"` // Health check interval for agents- GeminiPlanner GeminiPlannerConfig `yaml:"gemini_planner,omitempty"`+ Planner PlannerConfig `yaml:"planner,omitempty"`RemoteAgents []RemoteAgentConfig `yaml:"remote_agents,omitempty"` // List of remote agents to register}+// PlannerConfig configures the planner.+type PlannerConfig struct {+ Gemini GeminiPlannerConfig `yaml:"gemini"`+}+// ServerConfig configures the gRPC server.type ServerConfig struct {Address string `yaml:"address"` // Server address to listen on (e.g., ":8494")diff --git a/internal/controller/controller.go b/internal/controller/controller.goindex fe24c02..fed4cf7 100644--- a/internal/controller/controller.go+++ b/internal/controller/controller.go@@ -38,13 +38,14 @@ type Controller struct {loopExecutor *LoopExecutor}+// PlannerFactory is a function that creates a PlanFunc given a Registry.+type PlannerFactory func(ctx context.Context, r *Registry) (PlanFunc, error)+// Config configures the controller.type Config struct {EventLogFactory eventlog.EventLogFactory- PlanFunc PlanFunc-+ PlannerFactory PlannerFactory// TODO(jbd): Add CompactionFunc.-HealthCheckInterval time.DurationMaxSteps int}@@ -72,12 +73,24 @@ func New(ctx context.Context, config Config) (*Controller, error) {// Initialize agent registryregistry := NewRegistry(config.HealthCheckInterval)+ // Determine plan function+ // If no planner factory is provided, use the default Gemini planner.+ if config.PlannerFactory == nil {+ config.PlannerFactory = func(ctx context.Context, r *Registry) (PlanFunc, error) {+ return NewGeminiPlanFunc(ctx, r, GeminiPlannerConfig{})+ }+ }+ planFunc, err := config.PlannerFactory(ctx, registry)+ if err != nil {+ return nil, fmt.Errorf("failed to create planner from factory: %w", err)+ }+// Initialize loop executorloopExecutor, err := NewLoopExecutor(ctx, LoopConfig{Registry: registry,SessionManager: sessionManager,MaxSteps: config.MaxSteps,- PlanFunc: config.PlanFunc,+ PlanFunc: planFunc,})if err != nil {return nil, fmt.Errorf("failed to create loop executor: %w", err)diff --git a/internal/controller/gemini.go b/internal/controller/gemini.goindex 9c2f930..f7555ef 100644--- a/internal/controller/gemini.go+++ b/internal/controller/gemini.go@@ -27,7 +27,7 @@ import (// GeminiPlannerConfig configures the Gemini-based planner.type GeminiPlannerConfig struct {APIKey string // Google AI API key (for programmatic use only; if empty, uses GEMINI_API_KEY env var - recommended)- Model string // Model name (default: gemini-2.5-flash)+ Model string // Model name (default: gemini-3-flash-preview)MaxTokens int32 // Max output tokens (default: 8192)Timeout time.Duration // Request timeout (default: 60s)SystemPrompt string // Custom system prompt (optional)@@ -44,7 +44,7 @@ func NewGeminiPlanFunc(ctx context.Context, registry *Registry, config GeminiPlaif config.Model == "" {config.Model = os.Getenv("GAR_GEMINI_MODEL")if config.Model == "" {- config.Model = "gemini-2.5-flash"+ config.Model = "gemini-3-flash-preview"}}if config.APIKey == "" {diff --git a/internal/controller/loop.go b/internal/controller/loop.goindex 22c6692..956ff62 100644--- a/internal/controller/loop.go+++ b/internal/controller/loop.go@@ -61,15 +61,9 @@ func NewLoopExecutor(ctx context.Context, config LoopConfig) (*LoopExecutor, errif config.MaxSteps == 0 {config.MaxSteps = 10 // Default max steps per trigger}-- // Provide default plan function if not specified+ // Plan function is requiredif config.PlanFunc == nil {- // Use Gemini planner by default- geminiPlanFunc, err := NewGeminiPlanFunc(ctx, config.Registry, GeminiPlannerConfig{})- if err != nil {- return nil, fmt.Errorf("failed to initialize default Gemini planner: %w (set GEMINI_API_KEY env var or provide custom PlanFunc)", err)- }- config.PlanFunc = geminiPlanFunc+ return nil, fmt.Errorf("plan function is required")}return &LoopExecutor{