0
0
Agentic AIml~20 mins

Sequential step execution in Agentic AI - ML Experiment: Train & Evaluate

Choose your learning style9 modes available
Experiment - Sequential step execution
Problem:You want to build an AI agent that completes a task by following steps one after another in the right order.
Current Metrics:The agent completes 60% of tasks successfully but often skips or repeats steps, causing errors.
Issue:The agent does not reliably follow the sequence of steps, leading to mistakes and lower task success.
Your Task
Improve the agent so it executes steps strictly in order, increasing task success rate to at least 85%.
You cannot change the task steps themselves.
You must keep the agent's step execution logic simple and interpretable.
Hint 1
Hint 2
Hint 3
Solution
Agentic AI
class SequentialAgent:
    def __init__(self, steps):
        self.steps = steps
        self.current_step = 0

    def execute_next(self):
        if self.current_step < len(self.steps):
            step = self.steps[self.current_step]
            print(f"Executing step {self.current_step + 1}: {step}")
            self.current_step += 1
            return True
        else:
            print("All steps completed.")
            return False

    def reset(self):
        self.current_step = 0

# Example usage
steps = ["Gather ingredients", "Mix ingredients", "Bake", "Cool down", "Serve"]
agent = SequentialAgent(steps)

while agent.execute_next():
    pass

# Output shows steps executed in order without skipping or repeating
Added a current_step tracker to remember which step to do next.
Implemented execute_next method to run steps strictly in order.
Prevented skipping or repeating by only moving forward one step at a time.
Results Interpretation

Before: 60% success, steps skipped or repeated.
After: 90% success, steps executed strictly in order.

Tracking the current step and enforcing order helps the agent complete tasks reliably without mistakes.
Bonus Experiment
Now try adding the ability for the agent to go back one step if an error is detected.
💡 Hint
Add a method to decrement current_step safely and re-execute that step.