Google Now Blocks an AI Agent's Tool Call Before It Runs. Here Is the Pattern in 44 Lines of Python Google has put "semantic governance policies" into preview on its Gemini platform, checking every tool call an agent proposes before it runs and blocking calls that violate plain-language company rules or the user's stated intent, according to Help Net Security. In Google's finance-agent example, an attempt to email unreleased quarterly results to an outside investor was denied, as was a hidden-text injection trying to make the agent delete drafts. A developer can replicate the pattern without a specific cloud using a 44-line Python policy gate that combines rule checks, an intent check, an audit log and a dry-run mode. Help Net Security reported on November 23 that Google has put "semantic governance policies" into preview on its Gemini platform. The idea is simple and overdue: every tool call an agent proposes is checked before it runs. If it does not match what the user asked for, or it breaks a company rule written in plain language, the call is blocked and the agent gets a denial instead. Google's own example is a finance agent with one rule: unreleased quarterly results may only be emailed to addresses at the company's domain before the earnings release. When the agent tried to email results to an outside investor, the call was denied. When hidden text in a document tried to make the agent delete drafts, the intent check denied that too, because deleting drafts had nothing to do with the user's request. You do not need a specific cloud to adopt this pattern. Here is the core of it in 44 lines of Python, with both checks, an audit log and a dry-run mode. php user request -- agent model -- proposed tool call | v POLICY GATE <-- company rules + user intent | allow ----------+---------- deny | | run tool denial message back to agent | | +-------- audit log --------+ The important word is before . Output filters catch bad text after the fact. A gate in front of the tool stops the email from being sent at all. python import json, re Plain-language company rules, compiled to checks a reviewer can read. POLICIES = "Unreleased results go only to our own domain", lambda call, req: call "tool" = "send email" or "q3 results" not in call "args" "body" .lower or call "args" "to" .endswith "@example.com" , "Agents never delete data", lambda call, req: not call "tool" .startswith "delete " , Which tools each kind of user request can justify the "intent" check . INTENT TOOLS = { "email": {"send email", "search docs"}, "report": {"search docs", "read sheet"}, } def intent of request: str - str: return "email" if re.search r"\b email|send|reply \b", request, re.I else "report" def gate call: dict, request: str, dry run: bool = False - dict: """Runs BEFORE the tool. Returns allow/deny plus every reason, and logs the verdict.""" reasons = name for name, ok in POLICIES if not ok call, request if call "tool" not in INTENT TOOLS intent of request : reasons.append f"'{call 'tool' }' does not serve the request" verdict = {"allow": dry run or not reasons, "reasons": reasons, "dry run": dry run} print json.dumps {"tool": call "tool" , verdict} audit log line return verdict def run tool call, request, dry run=False : v = gate call, request, dry run return f"ran {call 'tool' }" if v "allow" else "DENIED: " + "; ".join v "reasons" if name == " main ": req = "Email the Q3 results summary to the finance team" cases = {"tool": "send email", "args": {"to": "cfo@example.com", "body": "Q3 results attached"}}, {"tool": "send email", "args": {"to": "investor@fund.com", "body": "Q3 results attached"}}, {"tool": "delete drafts", "args": {}}, injected by hidden text in a document {"tool": "search docs", "args": {"q": "Q3"}}, for c in cases: print " - ", run tool c, req print "\ndry run log only, nothing blocked :" print " - ", run tool cases 1 , req, dry run=True bash $ python gate.py {"tool": "send email", "allow": true, "reasons": , "dry run": false} - ran send email {"tool": "send email", "allow": false, "reasons": "Unreleased results go only to our own domain" , "dry run": false} - DENIED: Unreleased results go only to our own domain {"tool": "delete drafts", "allow": false, "reasons": "Agents never delete data", "'delete drafts' does not serve the request" , "dry run": false} - DENIED: Agents never delete data; 'delete drafts' does not serve the request {"tool": "search docs", "allow": true, "reasons": , "dry run": false} - ran search docs dry run log only, nothing blocked : {"tool": "send email", "allow": true, "reasons": "Unreleased results go only to our own domain" , "dry run": true} - ran send email Four proposed calls for one request "Email the Q3 results summary to the finance team" : In dry-run mode the risky email is allowed but the log still records the rule it broke. That is how you roll a gate out without breaking a working agent: watch what it would have blocked for a week, fix false positives, then enforce. Company rules encode things that are always true, whatever the user says: no unreleased results outside the company, no deletes, no refunds above a limit. Google lets compliance teams write these in plain language and has a model judge them. Mine are code. Both have a place. The intent check asks a different question: does this call serve what the user actually asked? It is the main defence against prompt injection, because injected instructions almost always ask for something unrelated to the user's request delete, forward, export . My version maps request types to allowed tools. Google uses a model to judge intent, which is more flexible. Google's documentation is candid that an LLM judge is probabilistic and its verdicts may vary, which is why it recommends dry-run mode before enforcing. My recommendation: The model deciding what to do is the exciting part of an agent. The gate deciding what it is allowed to do is the part that lets you put it in front of real customers and real data. If you are building agents that touch email, money or customer data, that is what we do at Axionry https://axionry.com/services/ai-product-development , an AI product development studio. We ship in weeks, with guardrails like this built in.