Skip to content

Add CheckPrerequisite to WorkflowStep to validate state machine edges#374

Open
Zoe Zhao (zoez7) wants to merge 2 commits into
agent-substrate:mainfrom
zoez7:check-prerequisite
Open

Add CheckPrerequisite to WorkflowStep to validate state machine edges#374
Zoe Zhao (zoez7) wants to merge 2 commits into
agent-substrate:mainfrom
zoez7:check-prerequisite

Conversation

@zoez7

@zoez7 Zoe Zhao (zoez7) commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Fixes #369

Add a CheckPrerequisite method to the WorkflowStep interface, called by RunWorkflow after IsComplete returns false and before Execute, so that each workflow validates its actor state-machine edge up front while retried (reentrant) workflows still fast-forward past completed steps.

@zoez7 Zoe Zhao (zoez7) force-pushed the check-prerequisite branch 4 times, most recently from 9e8acdf to 3921ac8 Compare July 8, 2026 23:55
}
func (s *AssignWorkerStep) CheckPrerequisite(ctx context.Context, input *ResumeInput, state *ResumeState) error {
// The resume edge exists from SUSPENDED and PAUSED.
// RESUMING is allowed for retrying this step.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because of line 168 below.

func (s *FinalizeSuspendedStep) Name() string { return "FinalizeSuspended" }
func (s *FinalizeSuspendedStep) IsComplete(ctx context.Context, input *SuspendInput, state *SuspendState) (bool, error) {
// The workflow is completely done ONLY if the status is SUSPENDED *and* we've successfully freed the worker.
return state.Actor.GetStatus() == ateapipb.Actor_STATUS_SUSPENDED && state.Actor.GetAteomPodNamespace() == "", nil

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this check, because we actually update the Actor's status and worker assignment in the same UpdateActor request in Execute() below, so we only need to check if status==suspended.

@zoez7 Zoe Zhao (zoez7) marked this pull request as ready for review July 8, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Actor state machine] Add CheckPrerequisite steps to WorkflowStep definition

1 participant