Agent Executor (AX) is Google's open agentic orchestration runtime
Go
feat: return error when requested last_seq is missing from event log (#262)
Jaana Doganb2cca64368f8
diff --git a/internal/controller/controller.go b/internal/controller/controller.goindex 1ffcf69..06d95ee 100644--- a/internal/controller/controller.go+++ b/internal/controller/controller.go@@ -99,7 +99,11 @@ func (d *Controller) tryResuming(ctx context.Context, req *proto.ExecRequest, el}if req.LastSeq != 0 {+ found := falsefor _, ev := range events {+ if ev.Seq == req.LastSeq {+ found = true+ }if ev.Seq > req.LastSeq {if err := handler(&proto.ExecResponse{Outputs: ev.Messages,@@ -109,6 +113,9 @@ func (d *Controller) tryResuming(ctx context.Context, req *proto.ExecRequest, el}}}+ if !found {+ return nil, false, fmt.Errorf("last_seq %d not found", req.LastSeq)+ }}if pendingExecID == "" {diff --git a/internal/controller/controller_test.go b/internal/controller/controller_test.goindex 818630b..fa0b54d 100644--- a/internal/controller/controller_test.go+++ b/internal/controller/controller_test.go@@ -236,6 +236,52 @@ func TestController_Exec_LastSeq(t *testing.T) {}}+func TestController_Exec_LastSeq_NotFound(t *testing.T) {+ ctx := context.Background()+ cid := "test-conv-seq-not-found"++ log := &executortest.MemoryEventLog{}+ // Pre-populate history+ log.AllEvents = []*proto.ConversationEvent{+ {+ ConversationId: cid,+ Seq: 1,+ Messages: []*proto.Message{+ {Role: "user", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}},+ },+ State: proto.State_STATE_COMPLETED,+ },+ }++ c, err := New(ctx, Config{+ EventLogBuilder: func() (executor.EventLog, error) {+ return log, nil+ },+ PlannerBuilder: func(ctx context.Context, r *Registry) (agent.Agent, error) {+ return &dummyAgent{}, nil+ },+ })+ if err != nil {+ t.Fatal(err)+ }+ defer c.Close()++ handler := ExecHandler(func(resp *proto.ExecResponse) error {+ return nil+ })++ err = c.Exec(ctx, &proto.ExecRequest{+ ConversationId: cid,+ LastSeq: 99,+ }, handler)+ if err == nil {+ t.Fatal("expected error when LastSeq is not found, got nil")+ }+ if err.Error() != "last_seq 99 not found" {+ t.Fatalf("expected 'last_seq 99 not found', got %v", err)+ }+}+func TestController_Exec_WaitsForConfirmation(t *testing.T) {ctx := context.Background()cid := "test-conv-conf"