0
0
Agentic AIml~10 mins

Supervisor agent pattern in Agentic AI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a supervisor agent that manages tasks.

Agentic AI
class SupervisorAgent:
    def __init__(self):
        self.tasks = []

    def add_task(self, task):
        self.tasks.[1](task)
Drag options to blanks, or click blank then click option'
Apop
Bremove
Cappend
Dclear
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove instead of append will cause an error because the task is not yet in the list.
Using pop removes an item, which is not what we want here.
2fill in blank
medium

Complete the code to have the supervisor agent execute all tasks.

Agentic AI
class SupervisorAgent:
    def __init__(self):
        self.tasks = []

    def execute_all(self):
        for task in self.tasks:
            task.[1]()
Drag options to blanks, or click blank then click option'
Aexecute
Brun
Cperform
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using run or start may not match the task's method name.
Using perform is uncommon and may cause an AttributeError.
3fill in blank
hard

Fix the error in the supervisor agent's task removal method.

Agentic AI
class SupervisorAgent:
    def __init__(self):
        self.tasks = []

    def remove_task(self, task):
        if task in self.tasks:
            self.tasks.[1](task)
        else:
            print("Task not found")
Drag options to blanks, or click blank then click option'
Adelete
Bremove
Cpop
Ddiscard
Attempts:
3 left
💡 Hint
Common Mistakes
Using delete causes a syntax error.
Using pop requires an index, not a value.
4fill in blank
hard

Fill both blanks to create a dictionary of task statuses.

Agentic AI
task_status = {task.[1]: task.[2] for task in supervisor.tasks}
Drag options to blanks, or click blank then click option'
Aname
Bstatus
Cresult
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using result instead of status may not reflect the current task state.
Using id as key is possible but name is more readable.
5fill in blank
hard

Fill all three blanks to filter and collect completed tasks.

Agentic AI
completed_tasks = [task for task in supervisor.tasks if task.[1] == [2]]
completed_names = [task.[3] for task in completed_tasks]
Drag options to blanks, or click blank then click option'
Astatus
B'completed'
Cname
Dresult
Attempts:
3 left
💡 Hint
Common Mistakes
Using result instead of name for collecting task identifiers.
Comparing status to a wrong string value.