How to Enforce Tool-Call Policy on Vertex AI Gemini Function Calls
Place policy enforcement in the execution path, at two points: after Gemini proposes a function call and before your code runs it, and again after the function returns and before the result goes back to the model. Treat the proposed call as untrusted input. Evaluate it against a defined policy for allowed functions, argument constraints, redaction, rate limits and human approval, and record each decision as evidence.
Where policy decisions belong in the Gemini function calling flow
- 1
Model proposes a call
Gemini returns a function name and arguments based on the declarations it was given.
- 2
Enforcement point evaluates
Policy checks the function, arguments, caller context and call rate.
- 3
Tool executes or is stopped
An allowed call runs with the application's own credentials. A blocked call never reaches the tool.
- 4
Result is evaluated
Returned data is inspected and redacted where policy requires.
- 5
Response returns to the model
Only the policy-approved result becomes part of model context.
Why model output is not an authorization decision
OWASP defines Excessive Agency as the vulnerability that enables damaging actions in response to unexpected or ambiguous model output, whatever the cause: hallucination, direct or indirect prompt injection, a malicious plugin, or a poorly performing model. Because the cause does not matter, a system prompt that says which functions to use cannot serve as the control.
OWASP's own example is an email assistant that has a send function in addition to the read function it needs. An indirect prompt injection in an incoming email causes the model to call send. The model did what its context told it to do. Only enforcement outside the model could have stopped it.
Other documented paths include manipulated tool arguments, where user-crafted input steers what a function is asked to do, and poisoned tool descriptions, which the NIST initial public draft SP 2400-102e2026 describes as attacker-controlled text in the agent's context. Over-broad service identities widen the impact. OWASP's Q1 2026 round-up reports a deployed agent on Vertex AI Agent Engine that inherited excessive default permissions through a Google-managed service account. That case concerns service-account scoping, not a flaw in Gemini function calling, but it shows why the identity behind a tool matters as much as the call itself.
NIST's draft describes action-level policy enforcement, where each proposed action is evaluated against an explicit policy before execution. That is the pattern this guide implements.
Define the tool-call policy
Write the policy before building the enforcement point. It should be explicit, versioned and specific to each application or agent. Five elements cover the decisions an enforcement point must make.
Start with the allowlist. OWASP recommends limiting the tools an agent may call to the minimum necessary, and limiting the functionality inside those tools as well. Declaring a function to Gemini should be a deliberate decision, and the allowlist should be checked at execution time rather than assumed from the declarations.
Argument constraints come next, defined per function. Treat declared schemas as a starting point, then add value ranges, permitted resource identifiers and rules on which records a caller may touch. Redaction rules apply to returned data, since tool results can carry sensitive content and can also carry injected instructions. Rate limits bound how often a function may run per caller or session. Escalation rules name the functions whose impact is high enough to need human approval.
- Allowed functions: A per-application allowlist, with the minimum functionality inside each function.
- Argument constraints: Per-function validation of types, ranges, targets and record scope.
- Data redaction: Rules for removing or masking sensitive fields in results before they reach the model.
- Rate limits: Ceilings on call frequency per function, caller or session.
- Human escalation: Named sensitive functions that pause for an approver and a recorded decision.
Enforce at runtime, before execution and before results return
On the pre-execution side, the enforcement point receives the proposed call, resolves the caller and application context, and evaluates the policy. The outcome is one of allow, redact, block, rate limit or escalate. If the call is allowed, the function runs. If it is blocked, return a controlled response to the model so the conversation can continue without the action having occurred. If it is escalated, hold the call until an approver decides.
Keep credentials and execution in application or intermediary code, never in anything the model can influence. OWASP recommends giving the application its own API tokens and scoping them to least privilege. Use short-lived credentials where possible, and inventory the service identities tied to agent execution. If agents can reach multiple projects, buckets or registries, test whether a call can pivot across them.
On the result side, evaluate the function's output before it becomes part of the next model turn. This step handles sensitive data in returned records and instructions hidden in retrieved content. Apply redaction here, and treat any block as a recorded decision.
Apply the same check in every service that executes tools. Application-side checks scattered across services leave gaps that are hard to demonstrate to an auditor. A single enforcement point in the path gives one place to test, one policy version to point to and one stream of evidence.
What each enforcement decision should record
An auditor asks two things: what was the AI allowed to do, and what did it do. Each tool-call decision should answer both without reconstruction from application logs.
At minimum, record the function name, the arguments or their redacted form, the policy and policy version applied, the decision (allow, redact, block, rate limit or escalate), the approver where a human was involved, and a timestamp. Add the outcome of execution and whether the result was modified before returning to the model. These fields are a design recommendation rather than a mandated schema, and you should confirm with your compliance team how they map to the frameworks you answer to.
Two properties matter more than the exact field list. Records should be produced by the enforcement itself, so that evidence cannot drift from what actually happened. They should also be durable, with retention and data residency set deliberately, since redacted arguments and results may still be sensitive.
How Trussed enforces policy on tool calls
Trussed enforces policy in the execution path across models, agents, tools and MCP servers, at the level of individual interactions and tool calls. For a Gemini function calling flow, that means the proposed call is evaluated at runtime before the function executes, and the result can be evaluated before it returns to the model. Outcomes include allow, redact and block, with rate limiting and escalation for human approval also available. Enforcement is at runtime, not reviewed after the fact.
Each enforcement decision generates audit-ready evidence, mapped to HIPAA, NAIC, NYDFS, the EU AI Act and NIST. Trussed can be self-managed in the customer's cloud, with configurable retention and data residency. It has run in continuous production in a regulated enterprise for more than 18 months, with 99.95% uptime on live production traffic.
The scope is tool-call-level enforcement. Trussed does not provide end-to-end tracing of agentic workflows or transaction-level governance, so those needs should be assessed separately.
Enforcement points in the function calling lifecycle
1. Model proposes
Gemini returns a function name and arguments. Nothing has run yet.
2. Pre-execution check
Policy evaluates the proposed call: allow, redact, block, rate limit or escalate.
3. Tool executes or stops
Only an approved call reaches the downstream function.
4. Result check
Returned data is evaluated and redacted before it re-enters model context.
5. Evidence recorded
Each decision produces a durable record.
See enforcement and evidence on a tool call
Walk through how a proposed Gemini function call is evaluated in the execution path and what evidence each decision produces.
See How Evidence Is ProducedHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.