Agent Executor (AX) is Google's open agentic orchestration runtime
Go
Introduce LocalAgentConfig
Jaana Dogan25aaf013a48a
diff --git a/examples/local_agent/main.go b/examples/local_agent/main.goindex cc3a1de..f343aab 100644--- a/examples/local_agent/main.go+++ b/examples/local_agent/main.go@@ -22,6 +22,7 @@ import ("time""github.com/google/gar/agent"+ "github.com/google/gar/internal/config""github.com/google/gar/internal/controller""github.com/google/gar/internal/eventlog""github.com/google/gar/proto"@@ -52,14 +53,15 @@ func main() {}defer c.Close()- if err := c.Registry().RegisterLocal(- echoAgent,- "local-echo-agent",- "Echo Agent",- "Simple echo agent that uppercases input",- map[string]string{+ if err := c.Registry().RegisterLocal(config.LocalAgentConfig{+ ID: "local-echo-agent",+ Name: "Echo Agent",+ Description: "Simple echo agent that uppercases input",+ Metadata: map[string]string{"version": "1.0",- }); err != nil {+ },+ Agent: echoAgent,+ }); err != nil {log.Fatalf("Error registering agent: %v\n", err)}diff --git a/internal/config/config.go b/internal/config/config.goindex 2af5927..737e43d 100644--- a/internal/config/config.go+++ b/internal/config/config.go@@ -20,6 +20,7 @@ import ("os""time"+ "github.com/google/gar/agent""gopkg.in/yaml.v3")@@ -70,6 +71,14 @@ type RemoteAgentConfig struct {Metadata map[string]string `yaml:"metadata,omitempty"` // Optional metadata}+type LocalAgentConfig struct {+ ID string // Unique agent identifier+ Name string // Human-readable name+ Description string // Description of agent capabilities+ Metadata map[string]string // Optional metadata+ Agent agent.Agent // In-process agent instance (not in YAML)+}+// LoadFromFile loads configuration from a YAML file.func LoadFromFile(path string) (*Config, error) {data, err := os.ReadFile(path)diff --git a/internal/controller/registry.go b/internal/controller/registry.goindex 81610f7..8122e14 100644--- a/internal/controller/registry.go+++ b/internal/controller/registry.go@@ -75,23 +75,23 @@ func NewRegistry(healthCheckInterval time.Duration) *Registry {}// RegisterLocal registers a local (in-process) agent.-func (r *Registry) RegisterLocal(a agent.Agent, id, name, description string, metadata map[string]string) error {+func (r *Registry) RegisterLocal(cfg config.LocalAgentConfig) error {r.mu.Lock()defer r.mu.Unlock()- if _, ok := r.agents[id]; ok {- return fmt.Errorf("agent %s already registered", id)+ if _, ok := r.agents[cfg.ID]; ok {+ return fmt.Errorf("agent %s already registered", cfg.ID)}- r.agents[id] = a- r.agentInfo[id] = &AgentInfo{- ID: id,- Name: name,- Description: description,+ r.agents[cfg.ID] = cfg.Agent+ r.agentInfo[cfg.ID] = &AgentInfo{+ ID: cfg.ID,+ Name: cfg.Name,+ Description: cfg.Description,Type: AgentTypeLocal,Healthy: true,LastHealthCheck: time.Now(),- Metadata: metadata,+ Metadata: cfg.Metadata,}return nil