Capstone: design and review an agentic system
Design one customer-service agent end to end, from build approach to guardrails, tracing every choice to a requirement. Then review a flawed design of the same agent and find its five defects.
Chapter 7CapstoneLesson 1 of 1ShowHide
Chapter 7 of 7 in Google Cloud Professional Agentic Architect
- Capstone: design and review an agentic systemYou're here
Prerequisites: Low-code or code: designing hybrid agents, Deploying agents: Agent Runtime, Cloud Run or GKE, Choosing evaluation criteria for agents, Guardrails: Model Armor, data protection and human in the loop
The exam asks you to combine choices, not recite them. In this lesson you design one agent from a written brief, one decision at a time, and tie each decision to a line of that brief. Then you review a weaker design of the same agent and name what is wrong with it. That is a : a check of a design against its requirements and the failure modes you already know.
Two rules run through everything below. Every choice traces to a requirement. If you cannot point at the line in the brief that a choice serves, it is decoration or a guess. Evaluation, identity and guardrails are designed in from the start. Bolted on at the end, they cost a rebuild, which is the lesson of the low-code-or-code topic.
The brief
Northwind Outdoor, an online retailer, wants an agent on its website that answers customers. The requirements, numbered so the design can cite them:
- R1. Answer questions about returns, shipping and warranty from about 2,000 policy pages. The support team edits them every week.
- R2. Tell a signed-in customer the status of their own orders, which are in a Cloud SQL database. Never another customer's.
- R3. Issue refunds through the internal payments API. A refund over $200 needs a support lead's approval first.
- R4. Customers sometimes paste card numbers into the chat. They must not be repeated or stored in logs.
- R5. The engineering team ships weekly and wants every change tested automatically before it reaches customers.
- R6. Traffic is quiet at night and ten times normal on sale days.
- R7. The security team must see and control which systems the agent can reach.
- R8. Keep what the team builds and operates, and the running cost, as low as the other requirements allow.
Design it in ten decisions
Each step names the choice, the requirement behind it, and the lesson that taught the reasoning.
Build approach: ADK, in code
R5 asks for evaluation gated on every change, R3 needs a refund rule enforced in code, and R2 needs a custom integration with the orders database. Those are the signals for code from the low-code-or-code lesson, so the agent is built with ADK. CX Agent Studio, Google's tool for customer conversations, is where you would start if a contact-centre team owned the agent and most of it were instructions and fixed flows. Here engineers own it and need that control.
Model: a managed Gemini model
R8 favours the least to operate, and nothing in the brief asks to hold weights, run the model on your own infrastructure, or cut cost at a measured, steady volume, so the agent calls a managed Gemini model through the API. Start with one capable model, measure, and only then route simple steps, such as classifying the request, to a smaller one.
Knowledge: Agent Search over the policy pages
R1 is plain document question answering with no special pipeline needs, so the first choice is Agent Search, Google's out-of-the-box RAG. The pages change weekly, so the data store is kept in step with the source. Superseded pages are marked with metadata and filtered out, because an outdated page is a data problem, not a prompt problem. Reach for RAG Engine only when you need to configure chunking, embeddings or reranking yourself.
Tools: one safe query, one refund function
For R2, the orders database is reached through MCP Toolbox for Databases with one named, parameterised query,
get_orders_for_customer, never a free-form SQL tool. Its customer id comes from session state that the web app writes when the customer signs in, not from the model: the agent wraps the Toolbox tool so the wrapper reads the id from state and binds it, and the model never sees that parameter. The MCP lesson's authenticated parameters fill such a value from a verified Google sign-in token; these customers sign in to the website, not to Google, so the binding is done in the agent's code. For R3,issue_refundis a function tool that calls the payments API.Orchestration: one agent, no team
One
LlmAgentwith three tools covers the brief: search the policies, look up orders, refund. No step needs a specialist with its own instructions, and no work runs in parallel. Use the least autonomy that solves the task: under R8, a multi-agent design would add routing failures and cost without serving a requirement.Sessions and memory: persistent sessions, no Memory Bank
A refund conversation can span several turns, and under R6 instances come and go, so sessions must live in a persistent session service, never in instance memory. The signed-in customer's id is held in session state. Nothing in the brief asks the agent to remember facts across conversations, so there is no Memory Bank.
Evaluation: a golden evalset gated in CI
For R5, an evalset records the expected tool calls as well as the answer. It includes edge cases (a refund of exactly $200), adversarial ones (a pasted instruction to refund someone else's order) and cases for R4. Trajectory matching with
IN_ORDERchecks that the expected lookup comes before the expected refund, while allowing extra calls. An extra, unexpected refund would still pass, so the adversarial cases also assert that no refund happens. CI runs the evalset on every change and fails the build on a regression. After launch, sampled live traffic is scored with reference-free checks, and every failure found becomes a new case.Runtime: Agent Runtime
R6 asks for scale, and R8 for no idle machines to run. Agent Runtime is the managed option with sessions, evaluation and observability services alongside. It gives the least to operate while still meeting the brief. Cloud Run would also work, with the session service configured by you.
Identity and auth: the agent's own, narrow identity
For R7 and R2, the agent runs as its own agent identity, so audit logs name it. It holds only the roles its tools need: calling the payments API and the Toolbox query, and searching the data store. A Principal Access Boundary caps what it could ever reach. The payments API is the company's own resource, and the agent acts as itself there, so its calls use two-legged OAuth. Customers sign in to the website, not to Google Cloud. The customer boundary for R2 is enforced by the query's parameter, from the step on tools.
Gateway and guardrails: control the traffic, screen the text, gate the refund
For R7, the agent and its MCP server are registered in Agent Registry, and the agent is bound to Agent Gateway, so all its outbound traffic passes through it: the model, Agent Search, sessions, the MCP server and the payments API. Access policies allow exactly those targets, and every call is recorded.
For R4, the screening has to sit where customers' text enters and leaves the agent. Model Armor on the gateway's outbound traffic covers calls to MCP servers, to A2A agents and to models over the OpenAI API format, not the agent's own Gemini calls, so on its own it would never see the chat. Screen it in one of two places: a Client-to-Agent (inbound) gateway in front of the agent, which screens what customers send and what the agent returns (an ADK agent is screened through its
streamQuerymethod), or Model Armor on the Gemini calls themselves, through a template or the project's inline enforcement. The same template screens for prompt injection.Use advanced Sensitive Data Protection, with an inspect template and a de-identify template that both cover card numbers, so numbers are removed rather than only detected, and run it in inspect and block from the first day customers use the agent. Inspect only lets the raw numbers through, which is exactly what R4 forbids, so tune the template on test traffic before launch, not on customers. An organisation floor setting still earns its place as a baseline for prompt injection and responsible-AI filters, but floor settings don't check a template's Sensitive Data Protection settings, so review those in code, where the template is defined.
For R3, the refund limit lives in code, as the next section explains.
Here is the whole design on one map, and every box answers a numbered requirement. Predict first which box holds a refund over $200 for a support lead, then open the other boxes to see what each does and the lesson behind it.
The refund limit: where a rule is enforced
R3 is the decision that most often goes wrong. Writing "ask a manager before refunds over $200" in the instruction is not enforcement: the model can skip it, and an injected instruction can talk it out of it. The limit belongs in code.
ADK's tool confirmation is the first tool to reach for. Wrap the tool with
require_confirmation set to a function that returns true when the amount is
over $200, and those calls pause until a person responds. But check the session
service: ADK's documentation lists VertexAiSessionService, which Agent
Runtime's managed sessions use, as not supported by this feature. So this
design puts the rule in issue_refund itself. At $200 or less it calls the
payments API. Above that, it files the refund in the support leads' approval
queue and tells the customer it is pending. Either way, code decides, not the
model.
Review a flawed design
A second team proposed this design for the same brief. Find five wrong choices in it, then list every requirement that nothing in it covers. Write your list down before you open the answers.
An ADK agent on Cloud Run, autoscaling from 0 to 20 instances, with
InMemorySessionService. It runs as the project's default compute service account, which has the Editor role. Tools:execute_sqlagainst the orders database, andissue_refund. The instruction says: "Only show customers their own orders. Ask a manager before refunds over $200." Before launch, a reviewer reads 50 final answers and signs off.
Show the five wrong choices
- A broad, shared identity. The default compute service account with Editor can change almost anything in the project, and audit logs cannot tell this agent from any other workload using the account. One successful injection reaches all of it. Fix: an agent identity holding only the roles its tools need, inside a Principal Access Boundary.
- Free-form SQL, with the customer boundary only in the instruction.
execute_sqllets the model write any query, so R2 depends on the model choosing to filter by the right customer. Fix: one parameterised query through MCP Toolbox, with the customer id taken from session state set at sign-in. - The refund limit only in the instruction. It is a request to the model, not a control. Fix: the limit in the refund tool's code.
- Sessions in instance memory. With 0 to 20 instances, a later turn can reach another instance, and scale-to-zero recycles them all: a customer halfway through a refund starts over. Fix: a persistent session service, or Agent Runtime's managed sessions.
- A one-time review of final answers. Reading answers cannot see a refund made without a lookup, and a one-time review tests none of the weekly changes in R5. Fix: an evalset with expected trajectories, run in CI on every change, plus online monitoring after launch.
Show the requirements nothing covers
- R1: no data store, so the policy questions have no source and the model answers from memory.
- R4: no screening, so card numbers are echoed and logged.
- R7: no gateway or registry, so security can neither see nor control what the agent reaches.
A requirement with no design element behind it is as much a defect as a wrong choice, and easier to overlook, because there is nothing on the page to question.
Recap
- Number the requirements, and make every design choice cite one.
- Choose the least you must build and operate that still meets the brief: managed model, Agent Search, one agent, a managed runtime.
- Enforce rules in code, such as query parameters and tool logic, never only in the instruction.
- Design evaluation, identity and guardrails in from the start.
- Read the constraints of your choices together. Two good choices can conflict.
- In a review, look for wrong choices and for requirements with nothing behind them.
Sources
Show 9 sourcesHide sources
| Source | Publisher | What it supports |
|---|---|---|
| Professional Agentic Architect exam guide (opens in a new tab) | Google Cloud | the five exam sections this design covers; retrieved 2026-11-17 |
| www.skills.google/paths/4525 (opens in a new tab) | Google Skills, "Professional Agentic Architect" learning path | labs |
| Get action confirmation for ADK Tools (opens in a new tab) | Google, Agent Development Kit documentation | retrieved 2026-11-17: require_confirmation with a confirmation function such as an amount threshold; DatabaseSessionService and VertexAiSessionService not supported |
| Deploy an agent with Agent Gateway (opens in a new tab) | Google Cloud | retrieved 2026-11-17: binding an agent routes its outbound traffic, including platform calls such as the Sessions API, through the gateway; egress endpoints must be allowed |
| MCP Toolbox for Databases (opens in a new tab) | Google, Agent Development Kit documentation | retrieved 2026-11-17: authenticated parameters bind tool inputs to values from OIDC tokens; bound parameters are hidden from the model |
| Model Armor overview (opens in a new tab) | Google Cloud | retrieved 2026-11-17: basic Sensitive Data Protection detects credit card numbers; advanced configuration supports inspection and de-identification |
| Integrate Model Armor with Agent Gateway (opens in a new tab) | Google Cloud | retrieved 2026-12-02: inline protection on egress traffic is limited to MCP servers, services following the OpenAI format, and A2A through Agent Gateway; streaming sanitization for ADK agents uses the streamQuery method |
| Configure floor settings (opens in a new tab) | Google Cloud | retrieved 2026-12-02: floor settings don't check templates for Sensitive Data Protection conformance; inline enforcement for supported Gemini models and Google Cloud MCP servers is configured at the project level |
| with their sources, in the earlier lessons of this path: low-code or code, choosing a model, RAG pipelines, MCP tools and integrations, multi-agent orchestration, sessions, state and memory, evaluation criteria, deploying agents, agent identity, OAuth, Agent Gateway and Registry, and guardrails | The other facts in this lesson are taught |
Suggested videos
Show 2 videosHide videos
From prototype to production: 45 minutes to a reliable Gemini Enterprise Agent Platform agent (opens YouTube in a new tab)
End-to-end production design on Agent Platform (MCP, guardrails, evaluation, deployment, observability), the same decision chain as the capstone.
Note: The first 10 minutes are Booking.com's customer story.
From Prototype to Production: Building with Gemini Enterprise Agent Platform (opens YouTube in a new tab)
Next '26 recap of build, scale, govern and optimize: a good review before the design exercise.
Check yourself
The order-lookup tool must return only the signed-in customer's orders. Where should the tool get the customer id from?
Go deeper
Hands-on lab: Production-Ready AI Roadshow 1: Building a Multi-Agent System →
Build a distributed multi-agent system with ADK and A2A. Part 1 of the roadshow series: build, then secure. Codelab, runs in your own Google Cloud project with billing on.
LinkHands-on lab: Production-Ready AI Roadshow 3: Securing a Multi-Agent System →
Secure the system from part 1 with Google Cloud security features. Codelab, runs in your own Google Cloud project with billing on.