
An instruction in a prompt, a tool docstring, or a rule file is guidance. A model will usually follow it, but nothing guarantees that it will do so on every request. When an architecture requires that a rule always be enforced, or that a specific action never happen, the control has to live outside the model. That distinction between guidance and enforcement appears repeatedly on the Professional Agentic Architect exam, where options that tell the agent how to behave are typically distractors whenever hard enforcement is required.
Enforced controls fall into three categories: code inside the agent framework, configuration around the runtime or tools, and managed Google Cloud services. There is also a second architectural boundary. When a requirement calls for enforcement outside the agent's own code, even in-code controls are ruled out in favor of a platform layer that the agent code cannot change.
System instructions, tool docstrings, Antigravity rules, and skills all steer model behavior, yet each one depends on the model choosing to comply. Generation settings do not cross into enforcement either. Lowering temperature or supplying stronger examples can make outputs more consistent, but a consistent wrong value is still wrong, and neither stops a model from calling an unintended tool or repeating restricted text. We treat prompts and rules as guidance for normal behavior, while placing non-negotiable constraints in deterministic controls.
When enforcement belongs in code, ADK and the Antigravity SDK offer deterministic safeguards that run before a tool executes or control how execution flows:
McpToolset (for instance, paired with StreamableHTTPConnectionParams for a remote server), setting tool_filter exposes only the named MCP tools to the model, whereas listing allowed tools in an instruction still hands the model every tool on the server.before_tool_callback with the tool, its arguments, and the tool context before execution. Returning a dict skips the tool and passes that dictionary to the model as the tool result, blocking actions such as protected deletions without modifying the tool function while giving the model an explanation to relay. Returning None lets the tool run normally, while after_tool_callback runs too late to prevent an action.@validate_call and constrained types checks arguments before the function body runs. Catching ValidationError and returning its details blocks invalid inputs, such as a bad refund amount, before downstream API calls and lets the model retry. By contrast, output_schema shapes only the agent's final response.FunctionTool with require_confirmation pauses for approval through the ADK web interface or the ADK server's REST API in reply to adk_request_confirmation, accepting True or a conditional function on the arguments. This feature is experimental and does not yet support DatabaseSessionService or VertexAiSessionService, so it runs with ADK's in-memory session service.Workflow in ADK 2.0 defines conditional branching in code using agent, tool, or plain Python nodes and edges mapped from a router node's Event route value, rather than relying on a long prompt.deny, allow, and ask_user policies in LocalAgentConfig enforces tool access in the SDK runtime, such as denying * first and selectively opening tools or sending calls to a custom approval handler.Other safeguards operate through configuration around the runtime rather than code inside the agent.
In Antigravity, workspace-level hooks in .agents/hooks.json at the project root apply to everyone who opens the repository and run outside the model. A PreToolUse hook matched to run_command inspects commands before execution. It can return deny to block commands such as terraform apply and log blocked attempts, or return allow with an overwrite object that rewrites arguments before the command runs, with Antigravity prepending a notice naming the changed keys to the tool result. A PostToolUse hook runs only after execution finishes.
In the Antigravity app, the Default permission preset runs routine project commands without prompts inside an OS-level terminal sandbox that can write to project folders and temporary directories, blocks sensitive paths such as ~/.ssh and .env, hides unmounted files, and blocks outbound network access except for domains granted under read_url. Both Turbo and Request Review leave the sandbox off.
For databases, MCP Toolbox for Databases defines custom tools such as postgres-sql in tools.yaml with typed parameters and fixed SQL statements, grouped into reusable toolsets with connection pooling and IAM-based authentication. This avoids both the unrestricted reach of execute_sql and building SQL from model output.
The Professional Agentic Architect exam also separates in-code controls from controls enforced outside the agent's code. Safeguards such as tool_filter or calling a screening API from a callback enforce rules against the model, but a code change inside the agent can still alter or remove them. When central controls must hold regardless of agent code, enforcement moves to managed services:
iap.googleapis.com/mcp.tool.isReadOnly to limit one identity to read-only tools while others keep full access. Neither project IAM roles nor VPC Service Controls can inspect individual MCP tool names.Two architectural questions usually settle which control belongs in a design. First, is the rule a preference that prompt guidance can shape, or a hard requirement that must be enforced outside the model? Second, if enforcement is needed, can it live in the agent's code or local configuration, or must a managed service enforce it independently of the agent's codebase? Keeping those boundaries clear helps separate prompt instructions, ADK and Antigravity controls, and managed Google Cloud services.
Our Professional Agentic Architect practice exams test guidance versus enforcement alongside ADK tool controls and Agent Gateway policies, with detailed explanations that drill these distinctions.