Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to pause the AI agent for human input.
Agentic AI
agent.pause_for_human([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using timeout=30 causes the agent to pause for a fixed time, not wait for human input.
Setting wait=False means the agent won't pause at all.
✗ Incorrect
Setting interrupt=True tells the agent to pause and wait for human input before continuing.
2fill in blank
mediumComplete the code to resume the AI agent after human approval.
Agentic AI
if human_approval == True: agent.[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using stop() ends the agent instead of resuming it.
Calling pause() again will not resume the agent.
✗ Incorrect
The resume() method continues the agent's process after it was paused for human input.
3fill in blank
hardFix the error in the code to correctly handle human interrupts.
Agentic AI
try: agent.run() except [1]: agent.pause_for_human(interrupt=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ValueError or RuntimeError does not catch human interrupts.
TimeoutError is for timeouts, not manual interrupts.
✗ Incorrect
KeyboardInterrupt is the exception raised when a human interrupts the program (e.g., Ctrl+C).
4fill in blank
hardFill both blanks to create a loop that waits for human input before continuing.
Agentic AI
while not agent.[1](): agent.[2](interrupt=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using stop or resume in the wrong place breaks the loop logic.
Not checking human approval causes the loop to run endlessly.
✗ Incorrect
The loop checks if the agent is approved by human (is_approved), and if not, it pauses for human input (pause_for_human).
5fill in blank
hardFill all three blanks to implement a human-in-the-loop interrupt handler.
Agentic AI
def handle_interrupt(agent): try: agent.[1]() except [2]: agent.[3](interrupt=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using stop instead of pause_for_human causes the agent to end instead of waiting.
Catching the wrong exception misses the human interrupt.
✗ Incorrect
The function runs the agent, catches KeyboardInterrupt, and pauses for human input.