Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a guardrail that stops the agent if it tries to delete important files.
Agentic AI
if action == [1]: print("Guardrail activated: Action blocked.")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing an action that is safe instead of dangerous.
✗ Incorrect
The guardrail checks if the action is 'delete_important_files' to block dangerous behavior.
2fill in blank
mediumComplete the code to check if the agent's output contains forbidden words.
Agentic AI
for word in forbidden_words: if word in agent_output: raise [1]("Forbidden content detected")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Warning which does not stop execution.
✗ Incorrect
Raising a RuntimeError stops the agent when forbidden content is detected.
3fill in blank
hardFix the error in the guardrail function that prevents the agent from sending sensitive data.
Agentic AI
def guardrail_check(data): if 'password' [1] data: return False return True
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which checks equality, not membership.
✗ Incorrect
The 'in' keyword checks if 'password' is inside the data string to block it.
4fill in blank
hardFill both blanks to create a guardrail that logs and blocks unsafe commands.
Agentic AI
def check_command(cmd): if cmd [1] unsafe_commands: log_event([2]) return False return True
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'not in' which allows unsafe commands.
✗ Incorrect
The guardrail checks if cmd is in unsafe_commands and logs a blocking message.
5fill in blank
hardFill all three blanks to build a guardrail that filters outputs and raises an error if needed.
Agentic AI
def filter_output(output): filtered = [word for word in output.split() if word != [1]] if [2] in filtered: raise [3]("Disallowed word found") return ' '.join(filtered)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong words or error types that don't stop execution.
✗ Incorrect
The guardrail removes 'secret', checks for 'error', and raises RuntimeError if found.
