Agent Executor (AX) is Google's open agentic orchestration runtime
Go
Don't allow triggers at any time when a session is running or failed
Jaana Doganeb94d35589b8
diff --git a/internal/controller/controller.go b/internal/controller/controller.goindex 427410c..496db1e 100644--- a/internal/controller/controller.go+++ b/internal/controller/controller.go@@ -90,12 +90,8 @@ func (d *Controller) TriggerSession(ctx context.Context, sessionID string, inputreturn fmt.Errorf("session_id is required")}- // TODO(jbd): Don't allow a running session to accept- // new triggers. Also mark, a session as COMPLETED- // if it's no longer running.-// Check if session already exists- sess, err := d.sessionManager.GetSession(sessionID)+ sess, err := d.sessionManager.LoadSession(ctx, sessionID)if err == nil && sess == nil {// Session doesn't exist - create new session// Checkpoint ID is ignored for new sessions@@ -105,6 +101,13 @@ func (d *Controller) TriggerSession(ctx context.Context, sessionID string, input}}+ if sess.State() == proto.State_STATE_RUNNING {+ return fmt.Errorf("session is already running")+ }+ if sess.State() == proto.State_STATE_FAILED {+ return fmt.Errorf("session has failed and cannot continue")+ }+for _, content := range inputs {if _, err := sess.WriteContentIn(ctx, content); err != nil {return fmt.Errorf("failed to write input content: %w", err)diff --git a/internal/controller/loop.go b/internal/controller/loop.goindex 1750817..39712b8 100644--- a/internal/controller/loop.go+++ b/internal/controller/loop.go@@ -97,10 +97,6 @@ func NewLoopExecutor(ctx context.Context, config LoopConfig) (*LoopExecutor, err}, nil}-func (e *LoopExecutor) stateRunnable(sesion *Session) bool {- return sesion.State() == proto.State_STATE_RUNNING || sesion.State() == proto.State_STATE_UNSPECIFIED-}-// Execute starts a new agentic loop execution for the given session.func (e *LoopExecutor) Execute(ctx context.Context, sessionID string, inputs []*proto.Content) error {// Get or create session@@ -109,10 +105,6 @@ func (e *LoopExecutor) Execute(ctx context.Context, sessionID string, inputs []*return fmt.Errorf("failed to get session: %w", err)}- if !e.stateRunnable(session) {- return fmt.Errorf("session is not in a runnable state")- }-if err := session.SetState(ctx, proto.State_STATE_RUNNING); err != nil {return fmt.Errorf("failed to set session state: %w", err)}