An agent that can run shell commands, send emails and delete files is only as safe as the rules that stand between a model's output and the real world. A permission policy is the simplest effective guardrail: a list of patterns saying which tool calls are allowed outright, which are forbidden and which need a human to approve first. Two design rules make it robust. Deny beats allow: an explicit prohibition cannot be overridden by a broad allowance. And the default is deny: anything the policy does not mention is blocked, so forgetting a rule fails safe instead of open.
Implement check_permission.
call is a string such as 'bash:rm -rf /tmp/x' or 'email:send'. policy is a dict with keys deny, ask and allow, each a list of glob patterns (use fnmatch.fnmatchcase).'deny' if any deny pattern matches. Else return 'ask' if any ask pattern matches. Else return 'allow' if any allow pattern matches. Otherwise return 'deny'.policy mean an empty list.Test the three lists in priority order and return at the first hit.
fnmatchcase('bash:rm -rf /', 'bash:rm *') is True, since * matches any characters including spaces and slashes.
No results yet
Run your code to check it against the examples, or submit to run every test.