Command Palette

Search for a command to run...

Hectal
Phase 10: Safety and Security (Defensive)
LLM Engineering · Exercise 3 of 5 PreviousNext
Advanced

Write a tool gate

Write gate(tool, allowed, approved). allowed is a dict that maps each permitted tool name to True when a human must approve its calls and False when no approval is needed. approved is the set of tool names a human has approved.

Return "denied" when the tool is not in allowed, "waiting" when it needs approval that has not been given, and "allowed" otherwise.

What Check tests

  1. A tool that needs no approval is allowed
  2. An unknown tool is denied
  3. A tool that needs approval waits
  4. An approved tool is allowed
  5. Approving a tool does not allow an unlisted one

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.