← Lesson
Contain, Then See
Joeven
Run
Reset
Python loads on first run
def classify(trace): tools = [e.get("tool") for e in trace if e.get("kind") == "tool"] flags = [e.get("flag") for e in trace if e.get("kind") == "flag"] if "wire" in tools: return "policy_or_injection" if any(e.get("code") == "PERMISSION_DENIED" for e in trace) is False and "get_invoice" in tools: tenants = [e.get("tenant") for e in trace if e.get("tool") == "get_invoice"] if len(set(t for t in tenants if t)) > 1: return "tool_authz" if any(e.get("code") == "VENDOR_503" for e in trace): return "vendor" if "refund" in tools and "hitl_approved" not in flags: return "hitl_bypass" return "needs_human" storm = [ {"kind": "tool", "tool": "refund"}, {"kind": "final", "text": "done"}, ] print("storm", classify(storm)) print("vendor", classify([{"kind": "tool", "tool": "search_kb", "code": "VENDOR_503"}])) print("inject", classify([{"kind": "tool", "tool": "wire"}]))
Run to execute this in your browser. Nothing is sent to a server.