Agent Executor (AX) is Google's open agentic orchestration runtime
Go
Introduce "type" into agent config (#83)
Jaana Dogan9e9923db96f1
diff --git a/README.md b/README.mdindex 85b20a7..c740cf9 100644--- a/README.md+++ b/README.md@@ -226,19 +226,18 @@ health_check:# Agents to register on startupagents:- - remote:- id: "text-processing-agent"- name: "Text Processing Agent"- description: "An agent for text processing"- address: "localhost:50051"- metadata:- version: "1.0"- - sandbox:- id: "uppercase-sandbox-agent"- name: "Sandbox Uppercase Agent"- description: "A secure, ephemeral cloud container for executing uppercase transformations"- sandbox_template_ref: "uppercase-agent-template"-+ - type: "remote"+ id: "text-processing-agent"+ name: "Text Processing Agent"+ description: "An agent for text processing"+ address: "localhost:50051"+ metadata:+ version: "1.0"+ - type: "k8s_sandbox"+ id: "uppercase-sandbox-agent"+ name: "Uppercase Agent"+ description: "A secure, ephemeral cloud container for executing uppercase transformations"+ sandbox_template_ref: "uppercase-agent-template"```Example:@@ -341,12 +340,12 @@ To use a Sandbox Agent, specify it in your `gar.yaml` configuration using the `s```yamlagents:- - sandbox:- id: "my-sandbox-agent"- name: "Sandbox Worker"- description: "An ephemeral sandbox processor"- sandbox_template_ref: "your-gke-sandbox-template-name"- container_port: 8494+ - type: "k8s_sandbox"+ id: "my-sandbox-agent"+ name: "Sandbox Worker"+ description: "An ephemeral sandbox processor"+ sandbox_template_ref: "your-gke-sandbox-template-name"+ container_port: 8494```#### End-to-End Example (Uppercase Agent)@@ -375,10 +374,10 @@ kubectl apply -f examples/sandbox_agent/sandbox-template.yamlEnsure your `gar.yaml` references this sandbox agent:```yamlagents:- - id: "uppercase-agent"- sandbox:- sandbox_template_ref: "uppercase-agent-template"- container_port: 8494+ - type: "k8s_sandbox"+ id: "uppercase-agent"+ sandbox_template_ref: "uppercase-agent-template"+ container_port: 8494```**4. Run the GAR Server**diff --git a/agent/sandbox.go b/agent/sandbox.goindex 9fd6ab9..4e37fc3 100644--- a/agent/sandbox.go+++ b/agent/sandbox.go@@ -29,9 +29,9 @@ import ("google.golang.org/grpc/metadata")-type SandboxAgent struct {+type KubernetesSandboxAgent struct {client *sandboxclient.Client- config SandboxAgentConfig+ config KubernetesSandboxAgentConfiginCluster boolpoolName string@@ -39,8 +39,8 @@ type SandboxAgent struct {activeClaims map[string]struct{}}-// SandboxAgentConfig configures a sandbox agent client.-type SandboxAgentConfig struct {+// KubernetesSandboxAgentConfig configures a sandbox agent client.+type KubernetesSandboxAgentConfig struct {ID stringSandboxTemplateRef string@@ -51,7 +51,7 @@ type SandboxAgentConfig struct {}// NewSandboxAgent creates a new sandbox agent logic coordinator.-func NewSandboxAgent(ctx context.Context, config SandboxAgentConfig) (*SandboxAgent, error) {+func NewSandboxAgent(ctx context.Context, config KubernetesSandboxAgentConfig) (*KubernetesSandboxAgent, error) {namespace := "default"//TODO(lhuan): allow setup in yamlif ns := os.Getenv("POD_NAMESPACE"); ns != "" {@@ -67,8 +67,8 @@ func NewSandboxAgent(ctx context.Context, config SandboxAgentConfig) (*SandboxAg}// newSandboxAgentWithClient allows customizing the client instantiation.-func newSandboxAgentWithClient(ctx context.Context, client *sandboxclient.Client, config SandboxAgentConfig) (*SandboxAgent, error) {- agent := &SandboxAgent{+func newSandboxAgentWithClient(ctx context.Context, client *sandboxclient.Client, config KubernetesSandboxAgentConfig) (*KubernetesSandboxAgent, error) {+ agent := &KubernetesSandboxAgent{client: client,config: config,inCluster: os.Getenv("KUBERNETES_SERVICE_HOST") != "",@@ -94,12 +94,12 @@ func newSandboxAgentWithClient(ctx context.Context, client *sandboxclient.Client}// HealthCheck always returns nil for ephemeral agents since health is checked during Process.-func (a *SandboxAgent) HealthCheck(ctx context.Context) error {+func (a *KubernetesSandboxAgent) HealthCheck(ctx context.Context) error {// TODO: implement proper health check logic for sandbox agents.return nil}-func (a *SandboxAgent) Process(ctx context.Context, sessionID string, req *proto.ProcessRequest, handler OutputHandler) error {+func (a *KubernetesSandboxAgent) Process(ctx context.Context, sessionID string, req *proto.ProcessRequest, handler OutputHandler) error {// Use the sessionID deterministically so interactive sessions reuse the same sandbox pod,// rather than spawning a new pod for every exchanged message.safeSessionID := strings.ReplaceAll(sessionID, "-", "")@@ -231,7 +231,7 @@ func findAvailablePort() (int, error) {// Close gracefully deletes the SandboxWarmPool if one was created,// and shreds all active SandboxClaims generated by this agent during interactive sessions.-func (a *SandboxAgent) Close() error {+func (a *KubernetesSandboxAgent) Close() error {ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)defer cancel()diff --git a/cmd/gar/serve.go b/cmd/gar/serve.goindex 10183e5..c853f50 100644--- a/cmd/gar/serve.go+++ b/cmd/gar/serve.go@@ -126,16 +126,18 @@ func newControllerFromConfig(ctx context.Context, cfg *config.Config) (*controll}for _, agentCfg := range cfg.Agents {- if agentCfg.SandboxAgentConfig != nil {- if err := c.Registry().RegisterSandbox(ctx, *agentCfg.SandboxAgentConfig); err != nil {- return nil, fmt.Errorf("failed to register sandbox agent %s: %w", agentCfg.SandboxAgentConfig.ID, err)+ typ := controller.AgentType(agentCfg.Type)+ switch typ {+ case controller.AgentTypeKubernetesSandbox:+ if err := c.Registry().RegisterSandbox(ctx, *agentCfg.KubernetesSandboxAgentConfig); err != nil {+ return nil, fmt.Errorf("failed to register k8s_sandbox agent %s: %w", agentCfg.KubernetesSandboxAgentConfig.ID, err)}- } else if agentCfg.RemoteAgentConfig != nil {+ case controller.AgentTypeRemote:if err := c.Registry().RegisterRemote(*agentCfg.RemoteAgentConfig); err != nil {return nil, fmt.Errorf("failed to register remote agent %s: %w", agentCfg.RemoteAgentConfig.ID, err)}- } else {- return nil, fmt.Errorf("invalid agent configuration: must specify 'sandbox' or 'remote'")+ default:+ return nil, fmt.Errorf("invalid agent configuration: unsupported agent type %q", typ)}}diff --git a/gar.yaml b/gar.yamlindex 9a53b3e..f5c50c4 100644--- a/gar.yaml+++ b/gar.yaml@@ -61,19 +61,19 @@ planner:# List of remote or sandbox agents to register on startup.agents:- - remote:- id: "remote-text-processor"- name: "Remote Text Processor"- description: "Converts text to lowercase."- address: "localhost:50051"- metadata:- version: "1.0"- - sandbox:- id: "uppercase"- name: "Upper Case Agent"- description: "Converts text to uppercase."- sandbox_template_ref: "uppercase-agent-template"- container_port: 8494- use_router: true- metadata:- version: "1.0"+ - type: "remote"+ id: "remote-text-processor"+ name: "Remote Text Processor"+ description: "Converts text to lowercase."+ address: "localhost:50051"+ metadata:+ version: "1.0"+ - type: "k8s_sandbox"+ id: "uppercase"+ name: "Upper Case Agent"+ description: "Converts text to uppercase."+ sandbox_template_ref: "uppercase-agent-template"+ container_port: 8494+ use_router: true+ metadata:+ version: "1.0"diff --git a/internal/config/config.go b/internal/config/config.goindex 0360df3..a64e34e 100644--- a/internal/config/config.go+++ b/internal/config/config.go@@ -35,8 +35,9 @@ type Config struct {}type Agent struct {- RemoteAgentConfig *RemoteAgentConfig `yaml:"remote,omitempty"`- SandboxAgentConfig *SandboxAgentConfig `yaml:"sandbox,omitempty"`+ Type string `yaml:"type"`+ RemoteAgentConfig *RemoteAgentConfig `yaml:",inline"`+ KubernetesSandboxAgentConfig *SandboxAgentConfig `yaml:",inline"`}// HealthCheckConfig defines the configuration for agent health checks.diff --git a/internal/controller/registry.go b/internal/controller/registry.goindex c2539bd..13a428d 100644--- a/internal/controller/registry.go+++ b/internal/controller/registry.go@@ -30,7 +30,7 @@ type AgentType stringconst (AgentTypeLocal AgentType = "local"AgentTypeRemote AgentType = "remote"- AgentTypeSandbox AgentType = "sandbox"+ AgentTypeKubernetesSandbox AgentType = "k8s_sandbox")// AgentInfo contains metadata about a registered agent.@@ -149,7 +149,7 @@ func (r *Registry) RegisterSandbox(ctx context.Context, cfg config.SandboxAgentCreturn fmt.Errorf("agent %s already registered", cfg.ID)}- sandboxAgent, err := agent.NewSandboxAgent(ctx, agent.SandboxAgentConfig{+ sandboxAgent, err := agent.NewSandboxAgent(ctx, agent.KubernetesSandboxAgentConfig{ID: cfg.ID,SandboxTemplateRef: cfg.SandboxTemplateRef,WarmPoolSize: cfg.WarmPoolSize,@@ -165,7 +165,7 @@ func (r *Registry) RegisterSandbox(ctx context.Context, cfg config.SandboxAgentCID: cfg.ID,Name: cfg.Name,Description: cfg.Description,- Type: AgentTypeSandbox,+ Type: AgentTypeKubernetesSandbox,Healthy: true,LastHealthCheck: time.Time{},Metadata: cfg.Metadata,