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
- A tool that needs no approval is allowed
- An unknown tool is denied
- A tool that needs approval waits
- An approved tool is allowed
- 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.