0
0
Agentic_aiml~10 mins

Why guardrails prevent agent disasters in Agentic Ai - Test Your Understanding

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

Complete 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'
A"delete_important_files"
B"move_files"
C"read_files"
D"create_files"
Attempts:
3 left
2fill in blank
medium

Complete 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'
AValueError
BException
CWarning
DRuntimeError
Attempts:
3 left
3fill in blank
hard

Fix 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'
Anot in
Bin
C==
D!=
Attempts:
3 left
4fill in blank
hard

Fill 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'
Ain
Bnot in
C"Blocked unsafe command"
D"Allowed command"
Attempts:
3 left
5fill in blank
hard

Fill 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'
A"secret"
B"error"
CRuntimeError
D"allowed"
Attempts:
3 left