Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 10.9 — Playbook: Security Checklist and Guards
LLM Engineering · Example 2 of 2

Recipe: a tool gate with argument checks, approval and an audit log

Nothing is sent. The gate decides and records every call.

Copy-ready recipes: a guarded model call (redact, input guard, output guard), a tool gate with argument checks, approval and an audit log, a guard-model call, and the security checklist to run before you ship.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write output_guard(reply, canary, prefix) that returns "system prompt marker" if the canary is in the reply, "unexpected reply shape" if the reply does not start with the prefix, else None. Test with three replies.

02

Write audit_line(call_id, tool, result) returning "<id> <tool> <result>", and count_denied(lines) returning how many lines contain "denied".

Explain it without notes

01

Walk through the guarded call and say why each step is in its place.

02

How does the tool gate limit what a steered model can do?

03

When should you use a guard model, and how do you combine it with rule guards?

04

What belongs on a pre-ship security checklist for an LLM feature?

Recipe: a tool gate with argument checks, approval and an audit log
Sign in to run this example in your browser.

Expected output

c1 read_note ok
c2 send_email waiting for approval
c3 send_email denied: recipient not allowed
c4 delete_note denied: not on the allow-list
c5 send_email ok
5 calls, 2 ran