AI Security & Governance

Google Gates Agent Tool Calls Before They Run. n8n Doesn't.

Rushil ShahRushil Shah
15 min read
Share

Google's pre-execution intent gate cut AgentDojo attack success from 48.7% to 0.9% for 2.6 points of utility. Here is what the second inference actually costs, where it breaks streaming, and how to replicate it outside Gemini Enterprise.

TL;DR

Google's Semantic governance policies put an LLM judge between the model's proposed tool call and the tool itself, cutting AgentDojo attack success from 48.7% to 0.9% at a cost of 2.6 utility points. The part the reprints skip: every gated call is a second model inference over a growing conversation, so a six-step task costs roughly $14 per 1,000 runs at Gemini 2.5 Flash list prices, streaming has to be switched off, and denials land disproportionately on the money-moving steps. If you are on n8n or LangGraph you can build the same gate yourself — put deterministic checks first and the judge second.

What Google actually shipped

On 20 November Google put Semantic governance policies into Preview on the Gemini platform, enforced through Agent Gateway. When the model responds with a tool call, Agent Gateway sends the proposed call to the policy engine before the response reaches your agent; if it fails, the engine replaces the response content, tool calls included, with a denial message. Two checks run: your natural-language policies, and a built-in user intent check that is on by default.

Three days later Google published the benchmark. Running AgentDojo v1.2.2 with a gemini-2.5-flash agent — 97 user tasks, 949 attacked runs, six full repetitions per configuration — attack success fell from 48.7% to 0.9%, and none of the 929 attacks that required a tool call succeeded in any of the six runs. The remaining successes were text-only: an injection asking the agent to recommend a hotel in its reply. No tool call, nothing for an action gate to evaluate.

That distinction matters more than the headline. This control judges actions, not text. It is not a prompt-injection classifier, and it does not care how the injection is phrased. It asks whether the proposed call follows from what the user asked for.

48.7% → 0.9% AgentDojo attack success rate, without and with the intent gate (6-run average) Source: Google Cloud docs, 2026
72.7% → 70.1% Utility on benign tasks — the 2.6-point cost everyone quotes Source: Google Cloud docs, 2026
11% → 81% Hijacking success when NIST CAISI red-teamed attacks against the specific model under test Source: NIST, 2025
57% → 80% Average attack success when the same five injections are retried 25 times Source: NIST, 2025

Google is unusually straight about the limit. The judge still has to read untrusted content to evaluate an action, and that separation is enforced by how the judge is instructed, not by a hard technical boundary. AgentDojo's attacks are fixed and were not adapted to the defence. The NIST numbers above are what adaptive pressure looks like.

Every gated call is a second inference, and the context grows

Nobody is publishing a price for this, so here is the arithmetic. The policy engine's judge sees the user prompt, the system instruction, the tool manifest, your policies, and the conversation history including tool results. That input set grows with every step of the task. Google's own docs promise exact per-turn LLM token consumption logged in Cloud Logging for budget predictability — which tells you they expect the bill to be worth watching.

Model a realistic enterprise agent: a 1,200-token static prefix (system instructions, tool descriptions, policies) plus about 1,500 tokens of conversation added per step, and a six-step task where every step proposes a tool call. Judge inputs across the six calls total roughly 38,700 tokens, with maybe 150 output tokens per verdict. At Gemini 2.5 Flash list pricing of $0.30 per million input tokens and $2.50 per million output, that is about $0.014 per task, or roughly $14 per 1,000 gated tasks on top of the agent's own inference. Per gated call, about $0.0023.

These are my modelled numbers from public list prices, not Google's. Your mileage moves with context length, which is the point: the gate is priced on how much history your agent drags along, not on how many tools it has. Two consequences people get wrong:

  • Cost is superlinear in steps. The sixth tool call in a run costs the judge nearly four times what the first one did, because the judge re-reads everything. Long-running agents that loop twenty times are where this bites.
  • Switching to a cheaper judge barely helps. At $0.25 in / $1.50 out for Gemini 3.1 Flash-Lite, the same workload lands near $11 per 1,000 tasks. Input tokens dominate; the model choice does not. Shrinking the context you hand the judge does.
!

Gating every tool call, including the reads

The default is to judge every proposed call. In most workflows 70–80% of calls are lookups: search the drive, read the ticket, list recent transactions. Those calls cost you a full judge inference each, over the longest context in the run, and they almost never get denied. You pay the most for the decisions that matter least.

Fix: classify tools into read, write and irreversible tiers at registration time. Let reads through on a deterministic allowlist, gate writes semantically, and require a human on irreversible actions. You keep the protection where actions have consequences and cut gate spend by roughly the read ratio.

Where the gate adds latency in a multi-step handoff

Google does not publish a per-call latency figure for the policy engine, and I am not going to invent one. What the documentation does tell you is structural, and it is worse than a millisecond count. The policy engine does not support streamed model responses, and a tool call in a streamed response might not be blocked, so you have to configure your agent to call its model without streaming.

For a user-facing agent that is the real cost. You trade progressive token output for a full response, then add a judge inference before the tool fires. Time-to-first-token goes from a few hundred milliseconds to the full generation plus the gate. For a back-office agent reconciling invoices at 3am, irrelevant. For a support copilot a customer is watching, it changes the product.

The second structural cost is serialisation. The gate sits on the critical path between model and tool, so a six-step task goes from six sequential LLM round trips to twelve. Parallel tool calls in a single response do not save you either — in production, a denial replaces the whole response including all tool calls, so one bad call in a batch kills the good ones with it.

A gated step, end to end

1
Model proposes

Non-streamed response returns one or more tool calls. Full generation latency, no partial output.

↓
2
Deterministic pre-checks

Amount ceilings, recipient allowlists, tool tier. Microseconds, no tokens. Most denials should die here.

↓
3
Semantic judge

Second inference over prompt, history, tool manifest and policies. Verdict plus rationale, logged with token count.

↓
4
Allow, deny, or escalate

Allowed calls pass unchanged. Denied calls are replaced with a denial message and the turn ends. Escalations wait on a human.

↓
5
Compensating action

The step most teams skip. A denial mid-transaction leaves partial state that something has to unwind.

Over-blocking lands on the write steps, not the reads

The 2.6-point utility cost reads as cheap until you look at where it falls. Google's breakdown is specific: of 97 benign tasks, two fail consistently and both legitimately look like injections; unintended over-blocking affects 1 of 97 benign tasks, about 1%. That is a genuinely good result on this benchmark.

But a gate that judges actions can only deny actions. Lookups rarely trip it. Every denial, by construction, concentrates on the mutating calls — send money, send email, delete file, export records. So a 1% over-block rate measured across all tasks is not a 1% failure rate on your payment run. If writes are a fifth of your calls, the same absolute error rate is five times denser on the steps that carry money.

The behavioural detail is worse than the rate. When a denial lands, the agent usually stops rather than continuing with the user's task, because the denial replaces the model's whole response and the turn ends there. In a benchmark that is a lost point. In an ERP workflow that is a purchase order created, a goods receipt not posted, and a reconciliation job that will fail silently tomorrow. Budget for the unwind, not just the block.

There is also strong evidence that an LLM judge is the wrong tool for the checks you can express deterministically. A preregistered study of multi-agent handoffs published this month found that on identical trajectories, a deterministic verifier caught 78.7% of violating decisions versus 59.0% for an LLM checker, with 7% versus 50% false alarms. Fifty percent false alarms is what an over-eager semantic gate feels like in production. Put the predicates you can compute — amount ceilings, payee allowlists, domain rules — in code, and reserve the judge for the things code cannot express.

The portable version for n8n, LangGraph and custom stacks

Most teams running real actions are not on Gemini Enterprise. The good news is that the mechanism is architectural, not proprietary: you need an enforcement point that sees the proposed call before it executes.

n8n does not give you one out of the box. The Guardrails node is explicitly a text control — it checks text going into or coming out of an AI model against safety, security and content policies, and can replace PII and secret keys with placeholders, with jailbreak, NSFW, topical alignment and custom LLM-based checks. Useful, and worth having on inputs. But it inspects strings, not the arguments of a proposed tool call, and when an AI Agent node is wired directly to a Gmail or HTTP Request tool, that call executes the moment the model asks for it. Nothing sits in between.

The pattern that works in n8n is to stop giving the agent the real write tools at all. Expose a single propose_action sub-workflow tool that returns a structured proposal and nothing else. The proposal lands in a normal workflow branch where you run deterministic checks in a Code or Switch node, then an LLM policy node that receives only the original user request, the proposed tool name, the arguments and your policy text — not the whole poisoned conversation. Only on an allow verdict does the branch call the real connector. Sensitive tiers route to a Slack or email send-and-wait step first.

json
{
  "user_request": "Pay invoice INV-4471 to Acme Ltd",
  "proposed_tool": "bank.send_payment",
  "arguments": { "payee_iban": "US13...", "amount": 8200, "currency": "AED" },
  "tier": "irreversible",
  "deterministic": { "amount_within_ceiling": true, "payee_on_allowlist": false },
  "verdict": "deny",
  "reason": "payee not previously used by this requester; not named in the user request",
  "judge_tokens": { "input": 5840, "output": 142 }
}

In LangGraph the same thing is a conditional edge. The model node emits an AIMessage containing tool calls; that message is in state before the tool node runs. Insert a policy node between them, route allow to the tool node, deny back to the model with a denial message, and escalate to an interrupt that waits on a human. Log the full decision record above on every verdict — you will need it for the shadow-mode phase below, and it is the only way to tune a policy without guessing. We build these interception layers as part of agent implementation work, and the structure is the same whichever orchestrator you are on.

One rule the Google docs state and everyone ignores: give every tool a clear description, because the judge relies on descriptions to understand a call and is instructed to deny calls to tools that have none. Half the over-blocking I would expect in a homegrown gate comes from tool schemas written for the agent's benefit, not the judge's.

LangSmith Tool Gateway answers a different question

LangChain opened LangSmith Tool Gateway in Public Beta on 19 November, and the timing invited a lot of comparisons that do not hold. Tool Gateway is an identity and access layer: register MCP servers once, scope each agent to a curated tool kit at a single URL, resolve whether a call runs as the user or as the agent, and trace every call. It also ships approval policies that ask the user to confirm a sensitive tool call in their MCP client before it runs, and deny policies scoped to a user, service key or combination.

That is genuinely valuable and solves the problem most teams hit first — the retailer described in the launch post has over 50 MCP servers exposing more than a thousand tools, and nothing stops an agent reaching for the wrong credential. But deny lists and human approvals are about who the agent is and which tool it may touch. They do not evaluate whether this particular call, with these arguments, follows from what the user asked. An injected send_email from an agent that is legitimately allowed to send email passes an identity gate cleanly.

ControlWhat it decidesStops an injected write?Marginal cost per call
IAM / tool scopingWhich tools the agent can reach at allNo — the tool is already allowedNegligible
LangSmith Tool GatewayIdentity, credential, deny lists, human approval on sensitive toolsOnly if a human reviews that callNegligible, plus human review time
n8n Guardrails nodeText in and out: jailbreak, PII, topic, custom LLM checksNo — it never sees the tool callOne classifier call on the text
Google Semantic governance policiesDoes this call match user intent and your written rulesYes, for calls that require a toolOne judge inference over full history
Deterministic policy nodeComputable predicates: amounts, allowlists, tiersYes, within what you can express in codeEffectively zero

These stack. Identity gating, a deterministic pre-check, a semantic judge and asynchronous anomaly detection each catch something the others miss. If you are choosing one because budget only covers one, the deterministic layer has the best cost-to-coverage ratio and the semantic judge has the best coverage of things you could not have anticipated.

Why this became a procurement question this week

On 20 November Bell Canada confirmed that an intrusion on 17 November saw an “agentic threat actor” access multiple systems, including one used for ordering and provisioning circuits, and exfiltrate enterprise customer data from a pre-production Maximo environment. Bell said it does not yet know the attribution.

Be precise about what that does and does not prove. This is an attacker using agentic tooling, not a defender's agent being hijacked through its inbox. A pre-execution intent gate on your own agents would not have prevented it. What it changes is the board conversation: “agentic” is now a word in breach notifications, which means the question of what your agents are permitted to do without a human in the loop arrives on a procurement timeline rather than a research one.

A rollout sequence that will not break production

Google's own recommendation is the right starting shape: turn on dry run mode, where the engine logs what it would deny without blocking anything, review the verdicts in Cloud Logging, then switch to enforcement. Here is how I would sequence it on any stack.

Week 0

Inventory and tier every tool. Read, write, irreversible. Rewrite tool descriptions so a judge with no product knowledge can tell what a call does. This step surfaces more risk than the gate will.

Weeks 1–2

Shadow mode. Gate runs, logs a verdict and rationale on every proposed call, blocks nothing. Capture judge token counts per verdict so you have a real cost curve instead of my model.

Week 3

Review every denial by hand. Sort into true positives, policy wording failures, and tool-description failures. If the false-alarm rate on write steps is above a few percent, fix the descriptions and policies before you enforce anything.

Week 4

Enforce on money-moving and data-export tools only. Everything else stays in shadow. Ship the compensating-action path at the same time — a denial mid-workflow must leave a clean state.

Week 6+

Expand tier by tier, and re-run your own adversarial set against the gate. Fixed public benchmarks do not measure adaptive attacks against the judge itself.

When not to gate

If your agent only reads, or only drafts output a human sends, a semantic gate adds cost and latency for protection you already have. The honest answer for a lot of workflows is that the human review step you already run is cheaper and more reliable than a judge model. Gate the moment an agent can move money, send external email, write to a system of record, or export data — and not before.

The broader shift is that agent security is moving from input filtering to action authorisation, and that is the right direction: you cannot enumerate every phrasing of an injection, but you can enumerate the actions that hurt. If you want to see how we tier tools and wire interception into existing automation, our case studies and model coverage pages cover the ground, and you can start a conversation here.

Frequently Asked Questions

What are semantic governance policies for AI agents?

They are natural-language rules evaluated by an LLM judge against each tool call an agent proposes, before that call executes. Google's implementation runs two checks: whether the call complies with your written constraints, and whether it matches the original user intent. A call must pass both. The check sits outside the agent, at Agent Gateway, so a compromised conversation cannot talk it out of the rules.

How much does a pre-execution gate cost per 1,000 actions?

Modelling a six-step task with a 1,200-token policy prefix and 1,500 tokens of history added per step, the judge consumes roughly 38,700 input and 900 output tokens per task. At Gemini 2.5 Flash list prices that is about $14 per 1,000 tasks, or $0.0023 per gated call. Input tokens dominate, so trimming the context you give the judge saves far more than switching to a cheaper judge model.

Does the gate stop all prompt injection?

No. It stops injections that require a tool call — on AgentDojo, none of the 929 such attacks succeeded. It does nothing about text-only manipulation, where the attacker makes the agent say something rather than do something. And the benchmark used fixed attacks. NIST CAISI found that attacks red-teamed against a specific model raised success from 11% to 81%, so assume an adaptive attacker will do better than the published figure.

Can I do this in n8n without Gemini Enterprise?

Yes, but not with the Guardrails node, which checks text going into or out of a model rather than proposed tool calls. The working pattern is to remove write tools from the agent entirely and expose one propose-action sub-workflow. Its structured output runs through deterministic checks, then an LLM policy node, and only an allow verdict triggers the real connector. Sensitive tiers route through a send-and-wait approval first.

How is this different from LangSmith Tool Gateway?

Tool Gateway, in public beta since 19 November 2026, governs identity and access: which tools an agent can reach, whose credentials it uses, deny policies, human approval on sensitive tools, and a trace of every call. It answers who the agent is. A semantic gate answers whether this specific call matches what the user asked for. An injected call to a tool the agent is legitimately allowed to use passes an identity check and fails an intent check.

Should I use an LLM judge or deterministic rules?

Both, in that order. A preregistered study of multi-agent handoffs found a deterministic verifier caught 78.7% of violating decisions with 7% false alarms, against 59.0% and 50% for an LLM checker on identical trajectories. Encode everything computable — amount ceilings, payee allowlists, tool tiers — in code that runs first and costs nothing, then send only what survives to the judge.

What breaks when I turn enforcement on?

Two things, reliably. Streaming has to be disabled, because the policy engine does not evaluate streamed responses — which changes the feel of any user-facing agent. And a denial replaces the model's entire response, so the agent's turn ends mid-task rather than skipping the bad call. If step three of a five-step financial workflow is denied, something has to unwind the first two. Build that compensating path before you enforce.

AI agentsagent securityprompt injectionn8nLangGraphGemini Enterpriseworkflow automationAI governance

Published

AI-assisted writing · Reviewed by the Twarx research team

Share:
Share

Research digest

AI Research Briefing

Honest insights on AI agents, Small Language Models, and local RAG. No hype. Only when we have something worth sending.

  • No hype, just measurable outcomes
  • Read by 2,400+ engineers
  • Unsubscribe anytime

Continue reading

More from Articles