Skip to content

armgit / ax

Public Imported from GitHub
0

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

Go

Ensure that max_steps are per trigger

JBDc37188784bff
diff --git a/README.md b/README.md
index 09e5bef..23a5ca1 100644
--- a/README.md
+++ b/README.md
@@ -199,6 +199,8 @@ eventlog:
dir: "eventlog"
controller:
+ # Maximum steps per trigger
+ max_steps: 50
health_check_interval: 30s
```
diff --git a/gar.yaml b/gar.yaml
index d3b3c88..9425298 100644
--- a/gar.yaml
+++ b/gar.yaml
@@ -13,8 +13,8 @@ eventlog:
# Controller configuration
controller:
- # Maximum number of steps per session
- max_steps: 1000
+ # Maximum number of steps per trigger
+ max_steps: 50
# Health check interval for agents (e.g., "30s", "1m")
health_check_interval: 30s
diff --git a/internal/config/config.go b/internal/config/config.go
index 56ee010..01e48f0 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -29,7 +29,7 @@ type EventLogConfig struct {
// ControllerConfig configures the controller behavior.
type ControllerConfig struct {
- MaxSteps int `yaml:"max_steps"` // Maximum steps per session
+ MaxSteps int `yaml:"max_steps"` // Maximum steps per trigger
HealthCheckInterval time.Duration `yaml:"health_check_interval"` // Health check interval for agents
}
@@ -37,7 +37,7 @@ type ControllerConfig struct {
// Note: API key is not configurable here for security reasons.
// Set GEMINI_API_KEY environment variable instead.
type GeminiPlannerConfig struct {
- Model string `yaml:"model,omitempty"` // Model name
+ Model string `yaml:"model,omitempty"` // Model name
Temperature float32 `yaml:"temperature,omitempty"`
MaxTokens int32 `yaml:"max_tokens,omitempty"`
Timeout time.Duration `yaml:"timeout,omitempty"`
diff --git a/internal/controller/loop.go b/internal/controller/loop.go
index a9e1be7..ab93560 100644
--- a/internal/controller/loop.go
+++ b/internal/controller/loop.go
@@ -52,7 +52,7 @@ func NewLoopExecutor(config LoopConfig) (*LoopExecutor, error) {
return nil, fmt.Errorf("session manager cannot be nil")
}
if config.MaxSteps == 0 {
- config.MaxSteps = 100 // Default max steps
+ config.MaxSteps = 100 // Default max steps per trigger
}
// Provide default plan function if not specified
@@ -120,8 +120,11 @@ func (e *LoopExecutor) Resume(ctx context.Context, sessionID string) error {
}
// runLoop executes the main agentic loop.
+// It runs up to maxSteps iterations per trigger/resume invocation.
func (e *LoopExecutor) runLoop(ctx context.Context, session *Session) error {
- for session.CurrentStep < e.maxSteps {
+ steps := 0
+
+ for steps < e.maxSteps {
// Check context cancellation
select {
case <-ctx.Done():
@@ -164,8 +167,9 @@ func (e *LoopExecutor) runLoop(ctx context.Context, session *Session) error {
return fmt.Errorf("evaluation failed: %w", err)
}
- // Phase 4: Advance step
+ // Phase 4: Advance step counters
session.AdvanceStep()
+ steps++
// If goal achieved, complete the session
if goalAchieved {
@@ -174,9 +178,8 @@ func (e *LoopExecutor) runLoop(ctx context.Context, session *Session) error {
}
}
- // Max steps reached
- session.SetState(proto.State_STATE_FAILED)
- return fmt.Errorf("max steps (%d) reached", e.maxSteps)
+ // Can be resumed later with another trigger
+ return fmt.Errorf("max steps per trigger (%d) reached", e.maxSteps)
}
// executeTask sends input to an agent and collects output.
@@ -235,7 +238,6 @@ func (e *LoopExecutor) HandleLifecycleEvent(session *Session, event *proto.Lifec
}
}
-
// defaultEvaluateFunc is a simple default evaluation function.
// It considers the goal achieved after processing one step.
func defaultEvaluateFunc(session *Session, task *AgentTask, output []*proto.Content) (bool, error) {