learning-it by example

Back to the video

Approval Gates for Risky Agent Actions

My prompt told the agent to ask before deleting. It deleted the file anyway. Here is a gate in code that stopped it.

Video #24 ยท AI agents and MCP

Steps in the video

  1. 0:00 The rule it ignored
  2. 0:23 The idea
  3. 0:54 Setup
  4. 1:09 The gate
  5. 1:41 Six cases for the gate
  6. 2:06 The agent
  7. 2:31 One request, three ways
  8. 3:14 What this does not show
  9. 3:50 Mistakes to avoid
  10. 4:12 My take and next steps
  11. 4:35 Recap

Files

  • agent.py (39 lines)
  • demo.py (27 lines)
  • gate.py (26 lines)
  • gate_checks.py (19 lines)

Download the code (zip)

Tested with

Python 3.12.15 | ollama==0.6.3

What this does not show

One small local model, one request and one tool, fixed settings, one run. The person is a scripted stand-in that always says yes or always says no; real approval needs a screen, a timeout and someone who reads it. The gate decides whether a tool runs and does not check its arguments. The files are examples in a temporary folder.

Sources

Learning IT by Example.