Agent Platform POC

Build one ADK agent and run it on Google Cloud. Then go and look at everything that appears around it: its identity, its registry entry, the MCP servers and skill it uses, the A2A link to a second agent, and the CI/CD pipeline that deploys it. It uses the GA4 sample table and the Knowledge Catalog / OKF context from the kc-okf POC.

Architecture

Your code and laptop Agent Platform (managed) Tools and data Identity and governance
Architecture of the POC Code on the laptop goes through GitHub and Cloud Build to Agent Runtime. The agent runs with its own Agent Identity, is listed in Agent Registry, calls Gemini, and reaches Knowledge Catalog MCP, our OKF MCP server and BigQuery through Agent Gateway. A front-desk agent calls it via A2A. Laptop + GitHub Gemini Enterprise Agent Platform Tools and data ADK agent code agents/ga4_guide/agent.py tools · callbacks skills/ga4-context/SKILL.md mcp_servers/okf/ (FastMCP) adk web · adk run local chat, sessions, events adk eval + simulated users GitHub repo push → trigger Cloud Build agent · MCP server · skill eval gate → deploy Your gcloud login (ADC) local runs act as you deployed runs act as the agent Web GUI + A2UI chat page on Cloud Run, login or Gemini Enterprise app Data policy agent deployed separately, own identity called via A2A (agent card) Agent Runtime (formerly Agent Engine) ga4_guide orchestrator sub-agents: schema · SQL · review skill loaded on demand plugins + callbacks = guardrails Agent Identity · principal://… Sessions Memory Bank Agent Registry agents (auto) MCP servers skills (Preview) metadata, versions, agent card (A2A) Agent Gateway egress policy per agent principal rule on mcp.toolName + Model Armor Gemini model e.g. gemini-3.5-flash location global Skill Registry ga4-context skill, versioned (Preview) IAM roles granted to the agent principal Staging bucket packaged agent Trace · Topology online eval, logs Cloud Run hosts our MCP server Knowledge Catalog MCP Google-hosted remote MCP dataplex.googleapis.com/mcp needs roles/mcp.toolUser OKF MCP server (ours) FastMCP · Streamable HTTP tools + resources + prompts serves kc-okf OKF pages BigQuery ga4_sample.events read-only query tool Context set (KC) pages from kc-okf step 3–4 → OKF files → skill deploy A2A listed Langfuse (self-hosted) same OpenTelemetry traces, compared with Cloud Trace 16 7 14 15 2 6 19 8 9 10 11 12 3 5 4 13 10 16

Blue circles show the lesson that covers each part. Dashed lines are optional or happen automatically (the Registry entry is created when the agent is deployed, docs).

One request, end to end

By lesson 12 you should be able to follow this path in Cloud Trace.

  1. You ask a question in the web GUI, which calls the orchestrator on Agent Runtime.
  2. The Runner loads the session (and Memory Bank). Plugins run first, then the orchestrator hands work to its sub-agents: schema_expert → sql_writer ⇄ reviewer.
  3. sql_writer loads the skill ga4-context from Skill Registry, with rules such as "no city-level output" and "always filter on the partition".
  4. schema_expert calls Knowledge Catalog MCP as the agent's own identity. Agent Gateway checks the egress policy, Model Armor checks the content, and IAM allows the call. It also reads a playbook from our OKF MCP server, found in Agent Registry.
  5. The SQL goes over A2A to the separately deployed data policy agent. The Gateway checks that this agent may call that one.
  6. The approved SQL runs with the BigQuery tool, and the answer comes back as an A2UI table that the GUI draws.
  7. Every step is an event and a span (in Cloud Trace and Langfuse). Online evaluation scores the answer afterwards.

Key ideas at a glance

The big idea: an agent, an MCP server and a skill are three separate things. Each one is built, deployed, versioned and registered on its own. Identity says who is calling, IAM and Agent Gateway decide what that caller may use, and the Registry is where everyone finds them.

AgentMCP serverSkill
WhatReasoning loop + instruction + toolsService offering tools, resources, promptsFolder of know-how (SKILL.md)
Oursagents/ga4_guidemcp_servers/okfskills/ga4-context
Runs onAgent RuntimeCloud RunNothing: an agent loads it
Found inAgent Registry (auto)Agent Registry (we register it)Agent Registry, Skills tab (we upload it)
.NETA web appA Web APIA NuGet content package

ADK

The framework you write the agent in: agent, tools, runner, sessions, callbacks, eval.

≈ ASP.NET for agents

Agent Runtime

Managed hosting for agents, with managed sessions and Memory Bank. Formerly Agent Engine.

≈ App Service

Agent Identity

Each deployed agent gets its own principal:// ID that you grant IAM roles to. No shared service-account keys. Without an organization the ID uses agents.global.proj-NUMBER; its token works on Google's mTLS hosts (lessons 8–9, verified).

≈ Managed Identity

Agent Registry

A catalog of agents, MCP servers and skills, so other agents and people can find them. Agent Runtime agents and Google's MCP servers appear by themselves; ours are registered as services (lesson 10, verified).

≈ service registry / NuGet feed

Agent Gateway + Model Armor

All of the agent's outbound calls pass through it, even Gemini and sessions. An IAP guard checks each call against an access policy: which agent principal may reach which host, or which MCP tool when the server is registered in the gateway's region (CEL on destination.agent_registry.mcp_server.tool.name). Model Armor filters content. Verified: it denied a catalog call that IAM allowed (lesson 11).

≈ API Management + WAF, per identity

Skill Registry

Skills stored in Agent Registry, with revisions and states (only Active ones download). Agents find one with search_skills and load it by name instead of shipping it with their own code (lesson 10, verified).

≈ private NuGet feed

MCP

The standard way to plug tools and data into any agent. We use Google's hosted server and build one of our own.

≈ ODBC for agent tools

Skill

A SKILL.md folder of know-how that the agent loads only when it needs it (progressive disclosure).

≈ a runbook opened on demand

Orchestrator + sub-agents

One agent splits the job and delegates to specialists, either by LLM routing (transfer, agent as a tool) or by a fixed Workflow graph, which replaces the deprecated Sequential, Parallel and Loop agents (lesson 7, verified).

≈ controller + services, or Durable Functions

A2A

Agent-to-agent protocol for agents deployed separately, each with its own identity. An agent card says what an agent can do and where to reach it.

≈ microservices + OpenAPI

A2UI

The agent sends declarative UI (tables, pickers, cards) as JSON, and the app draws it from approved components. No agent code runs in the browser.

≈ Adaptive Cards

ADK plugin

Code registered once that runs before and after every model and tool call: logging, blocking, asking a human to confirm.

≈ global middleware

Evaluate → optimize

Offline tests, simulated users and online AI judges find failures; the prompt optimizer suggests fixes; then you re-score.

≈ tests + APM + tuning advisor

Traces + Topology

Every model and tool call is a span (OpenTelemetry). Compared with LangSmith and Langfuse, Google keeps the traces in your own project. Topology needs a project inside an organization; ours has none (verified).

≈ Application Insights + App Map

Three ways to build

Low-code in Agent Studio, config with the Managed Agents API (Preview), or code with ADK. All run on the same platform.

≈ Logic Apps vs YAML vs C#

CI/CD

One pipeline per deployable (agent, MCP server, skill). The eval gate must pass before deploy.

≈ Azure Pipelines with a test stage

Guardrails live in two places

ADK plugin (in code, lesson 9)Agent Gateway (on the network, lesson 11)
RunsInside the agent processOutside, on every outbound call
Owned byWhoever deploys the agentPlatform or security team
Bypassable?Yes, by changing the codeNo: it denied a catalog call that IAM allowed (verified, lesson 11)
Good forLogging, human approval, fixing argumentsHard allow/deny per identity and host; per MCP tool when the server is registered in the gateway's region; Model Armor

Lessons

Each lesson has a README in lessons/ with an explanation, code to paste and commands to run. ☁ means it creates cloud resources or costs money, so we check first.

#LessonYou learnStatus
0MapThe whole stack and how the pieces connect (this page)done
1Setup ☁uv, gcloud profile, ADC, APIs, quotasdone
2First ADK agentAgent, Runner, Session, State, Events; the adk web dev UI; first traces in Langfusedone
3Tools + Google's MCPFunction tools, toolsets, MCP client, Knowledge Catalog remote MCP, BigQuery tooldone
4A skill (local)SKILL.md, SkillToolset, progressive disclosure; OKF's okf-consumedone
5Your own MCP server ☁ Part BMCPServer: tools, resources, prompts; stdio vs Streamable HTTP; Cloud Run with invoker IAM (Part B, only after we agree)done
6Evaluate: offline + simulatedadk eval on 5 of kc-okf's questions (trajectory, reference and rubric metrics, Gemini as judge); a simulated NOVICE userdone
7Multi-agent in one appga4_team (transfer + AgentTool reviewer) and ga4_flow (a Workflow graph with a review loop; Sequential/Loop agents are deprecated); scored with lesson 6's eval setdone
8Deploy to Agent Runtime ☁adk deploy agent_engine of a clean build copy (skill inside, no Langfuse key), Agent Identity, scale to zero; the deliberate first 403done
9Identity, IAM, guardrails in code ☁Least-privilege roles for the agent principal (one 403 at a time); a GuardrailsPlugin that logs tool calls, blocks write and city-level SQL, asks before a full-table scan, and stops retry loopsdone
10Registry: agents, MCP servers, skills ☁Enable Agent Registry (free); find the auto-registered agent and Google's MCP servers; register our MCP server (tool spec) and skill; ga4_registry finds its skill and catalog tools in the registrydone
11Agent Gateway + governance ☁Preflight first (early preview access? organization?); egress gateway, default deny, a Unified Access Policy that blocks one MCP tool for our agent's principal; DRY_RUN then ENFORCED; Model Armordone
12A2A between agents ☁Lesson 7's reviewer as its own agent behind A2A (agent card, to_a2a, RemoteA2aAgent), first locally; later deployed with its own identity, found in the Registrydone
13Memory ☁Session vs user: state vs Memory Bank: agents/ga4_memory (preload_memory + save after each answer), using the deployed agent's Memory Bank from adk webdone
14Web GUI ☁A small chat page (web/) that streams from the deployed agent: sessions, streaming, user id; Cloud Run with IAP login and Gemini Enterprise written down, not runready
15A2UI ☁Results as an A2UI table, a picker for ambiguous questions; AG-UI and MCP Apps comparedplanned
16Observability: Google vs Langfuse ☁One run sent to Cloud Trace and Langfuse at once (--otel_to_cloud + the .env exporter), compared span by span; the deployed agent's traces; Topology needs an organizationready
17Optimize ☁Online evaluation with AutoRaters; Google's optimizer vs adk optimize (GEPA); re-scoreplanned
18Three ways to build ☁Agent Studio vs Managed Agents API vs ADK (optional)planned
19CI/CD for the deployables ☁A pipeline each for agents, MCP server and skill; eval gate; WIF; update vs re-create; rollbackplanned
20Tour: what ended up whereConsole and gcloud views of every piece; gateway decisions, threat scanningplanned
21Score, cost, clean up ☁Setups D (single) and E (multi-agent) against kc-okf's A–C; cost; delete resourcesplanned
22Same agent in LangGraphThe lesson 3 agent rebuilt in LangGraph; mapping to ADK concepts; same Gemini, project and Langfuse; same 5 questions scored (optional, after lesson 5)planned
23Caching and costThree places to cache: data in our MCP server, tool results in session state, and the model's input (Gemini implicit caching vs ADK's ContextCacheConfig); measured with scripts/measure_tokens.py: trimming the duplicate MCP payload cut input by 29%done

Left out on purpose: RAG Engine and Vector Search (our data is a structured table), Code Execution (we run SQL, not Python), CodeMender and AI Content Detection (not about data agents). Details are in docs/lesson-plan.md.

Learning journal

What we did in each lesson, what we found, and the questions asked along the way, with the answers in plain words. It's written to be re-read later without the chat. Click a lesson to open it, or use the buttons to open or fold all of them. Evidence for every verified claim is in results/.

Next session (prepared on 2026-11-27, after lesson 13)

Lesson 0The map2026-11-24done

The basics

What this project is. A hands-on tour of Google's agent stack. We build one small agent that answers questions about a Google Analytics sample dataset, then look at everything that appears around it on Google Cloud: its identity, the registry, MCP servers, skills, evaluation and tracing.

The four parts of Google's Agent Platform (the 2026 name for Vertex AI):

  • Build: what you make agents with (ADK, skills, models).
  • Scale: where agents run (Agent Runtime, managed sessions, memory).
  • Govern: who an agent is and what it may do (Agent Identity, Agent Registry, Agent Gateway).
  • Optimize: how you know it works (evaluation, traces, prompt tuning).

Words you'll meet first

TermPlain meaningFirst used
AgentA model in a loop: it reads the context, picks a tool, sees the result, and repeats until it can answerLesson 2
SessionOne conversation, with its events and saved stateLesson 2
TraceA record of every model and tool call, so you can see what happenedLesson 2
ToolA function the agent can call to do something or fetch dataLesson 3
MCPA standard way for a server to offer tools to any agentLesson 3
SkillA folder of written know-how the agent reads when it needs itLesson 4

How we work. Each lesson has a README in lessons/ with the explanation, the code and the commands. You run them and send me the output; I read your files and the traces, check the results, and update this page. Every claim is labelled verified (we ran it), docs (Google's documentation says so) or guess (not checked); see "How claims are labelled" at the bottom.

What we did

Questions and answers

What makes up Google's "Agent Platform"?

Gemini Enterprise Agent Platform (the new name for Vertex AI, 2026) has four pillars. Build: ADK, Agent Studio, Managed Agents API, Skill Registry, Model Garden. Scale: Agent Runtime, Sessions, Memory Bank, Code Execution. Govern: Agent Identity, Agent Registry, Agent Gateway, Model Armor. Optimize: evaluation, prompt optimizer, traces and Topology (docs).

Is Skill Registry a Google service?

Yes, a Preview part of Agent Platform: a private, versioned store for skills. An agent loads a skill from it instead of shipping the skill inside its own code (docs; lesson 10).

Can a plugin be deployed or registered by itself too?

No. An ADK plugin is code that runs inside the agent's process (like middleware). It ships with the agent. Agents, MCP servers and skills are the three things that are deployed and registered on their own.

Is "Optimize" like LangSmith for LangChain?

Roughly, yes: evaluation, traces and prompt optimization in one place. The difference is that Google keeps the data in your own GCP project. Langfuse is the open-source, self-hostable equivalent; we compare them in lesson 16.

Remember this

  • An agent, an MCP server and a skill are three separate things, each built, deployed and registered on its own.
  • Identity says who is calling; IAM and the Agent Gateway decide what it may use.
  • Every claim in this repo is labelled verified, docs or guess.
Lesson 1Setup2026-11-24done

The basics

This lesson was plumbing. Before an agent can think, your machine needs a login that Google's libraries can use, a project to bill the calls to, and the right APIs switched on. We set that up and made one Gemini call to prove it works.

What we did

Key ideas

Questions and answers

Where is the "Vertex AI API"? The console home page doesn't show it.

The "Welcome to Gemini Platform" page is the product console. The API switch and its traffic graphs live under APIs & Services → Enabled APIs, as aiplatform.googleapis.com. Its Metrics tab showed our GenerateContent call.

Remember this

  • Two logins: gcloud auth login is for the CLI, ADC is for libraries like ADK.
  • APIs are switched on per project; each lesson turns on only what it needs.
  • We use Google Cloud, not an API key, because identity, IAM and audit logs only exist there.
Lesson 2First ADK agent2026-11-24 → 2026-11-25done

The basics

An ADK agent is just a Python object: a name, an instruction and some tools. It does nothing until a Runner runs it. adk run, adk web and our own script are three different hosts for the same agent; they differ only in how you talk to it and where the conversation is saved. Langfuse shows every model call.

What we did

The big picture: one agent class, many hosts

The same agent run by four different hosts adk run, adk web, our runner_demo script and Agent Runtime each create a Runner. Each Runner holds the same root_agent and stores conversations in a different place: a SQLite file, memory, or Google's managed Sessions service. The Runner calls Gemini on every turn. adk run you type in the terminal Runner stores in: SQLite file .adk/session.db · user "test_user" adk web you type in the browser Runner stores in: SQLite file .adk/session.db · user "user" runner_demo.py your own code Runner stores in: memory InMemorySessionService · gone at exit Agent Runtime (lesson 8) other apps call it over HTTP Runner stores in: managed Sessions always-on server · AdkApp wrapper each Runner holds the same agent root_agent = Agent(...) name · instruction · tools · output_key just a Python object: it doesn't know who runs it Gemini gemini-3.5-flash · global every turn Purple = on this server. Dashed teal = later, in the cloud.

The agent is the controller; the Runner is the ASP.NET pipeline that runs it. Whoever creates the Runner decides where conversations are stored. On Agent Runtime, Google's AdkApp wrapper creates the Runner and uses the managed Sessions service (docs).

What the Runner does on each message

  1. Loads the conversation (session) from its storage.
  2. Sends the instruction, the conversation so far and your new message to Gemini.
  3. If Gemini asks for a tool (remember_analyst), runs that Python function and sends the result back.
  4. Repeats until Gemini gives a final answer.
  5. Saves every step as an event, and every state change with it.
  6. Hands each event to whoever called it, as it happens (terminal, browser, your script).

Where the data lives: state scopes are real tables

Key in codeTable in session.dbLasts for
user:analyst_name, user:teamuser_states, one row per app + user, saved without the prefixAll of that user's conversations
last_answer, times_remembered (no prefix)sessions.state, one row per conversationThis conversation only
app:… (not used yet)app_statesEveryone using the app
temp:… (not used yet)not storedThis turn only
every message, tool call and tool resultevents, JSON in event_dataThe conversation (deleted with it, ON DELETE CASCADE)

Findings (verified)

Questions and answers

What is the adk web UI?

ADK's developer UI: a small local web server that runs your agent and shows each step. Events (every message and tool call), State (the keys), Trace (timings) and a graph of agent → tools. It's for development, not for end users (lesson 14 builds a real one).

Where was the analyst name saved, from the terminal or the web app?

In both cases, in the same SQLite file agents/ga4_guide/.adk/session.db, table user_states, but under different user IDs. Nothing was saved in Google Cloud.

What does output_key="last_answer" mean?

"After every reply, also save the reply text into session state as last_answer." Nothing reads it yet. In lesson 7 one agent writes with output_key="draft_sql" and the next reads it with {draft_sql} in its instruction: that's how sub-agents pass work along. Like Session["last_answer"] = result at the end of an action.

Is SQLite open source? Can I query it after the app stops?

It's public domain, a whole database in one file, with no server, and it's built into Python, phones and browsers (like SQL Server LocalDB, only lighter). Yes: open it read-only with sqlite3 -readonly -box agents/ga4_guide/.adk/session.db. The queries are in the Lesson 2 README, Step 4b.

Why write runner_demo.py at all?

So far we only used ADK's ready-made apps (adk run, adk web). Eventually your program (a website, a test) has to talk to the agent. The script is the smallest such program: make a session, send a message, print what comes back. It's like driving an automatic, then trying a manual once.

Is the script an HTTP client calling the agent?

No. It imports the agent as Python code and runs it in its own process: a project reference to a class library, not HttpClient. HTTP comes when the agent is deployed (lesson 8) and a web app calls it (lesson 14).

Is the agent a server that gets started and killed for each question?

Locally, no: the agent is just an object, and nothing runs between messages. Each message is a loop of calls to Gemini. On Agent Runtime there is a server: Google runs a container that holds your agent and a Runner and stays up, waiting for HTTP requests.

What is the Runner?

The engine. The agent only describes what to do (name, instruction, tools); the Runner does it: load the session, call Gemini, run tools, save events, hand them back. Runner(agent=root_agent, ...): the Runner holds the agent; the agent doesn't know about the Runner. That's why the same agent works in every host in the diagram.

Does adk run also use a Runner?

Yes. adk run, adk web and our script all create a Runner. They differ only in how you talk to it and where it stores sessions.

What is InMemorySessionService?

The simplest session storage: an ordinary Python dictionary in RAM, forgotten when the script ends. The SQLite file isn't touched. The agent never chooses its storage; whoever runs it does. Like Entity Framework's InMemory provider vs SQL Server: same code, one line decides.

What are GOOGLE_GENAI_USE_ENTERPRISE and noqa?

GOOGLE_GENAI_USE_ENTERPRISE=1 picks the Gemini "door": Google Cloud with your ADC login and IAM (set), or AI Studio with an API key (not set). We use Cloud, because identity and governance only exist there. noqa: E402 tells the linter "this import is late on purpose": it must come after load_dotenv and sys.path.insert. It does nothing at run time (like #pragma warning disable).

Langfuse shows LANGFUSE_* variables, you gave me OTEL_* ones. What's the difference?

Same keys, different carrier. LANGFUSE_* are read by Langfuse's own Python package (not installed). OTEL_* are the open OpenTelemetry settings that ADK already understands: endpoint = where to send spans, headers = the login (Authorization: Basic base64(public:secret), so both keys), service name = a label. We used OTel, so nothing new was installed.

Do we change agent.py for tracing?

No. The agent doesn't know who watches it. ADK already creates a span per model and tool call; the host decides where they go. Tracing is switched on by the package's __init__.py (for adk run and scripts) and by adk web itself when the settings are in the shell; on Agent Runtime it goes to Cloud Trace (lesson 16). Start ADK through scripts/adk.sh.

Langfuse only shows "invoke" names, and no prompt or reply. Is that right?

Names: yes, mostly. ADK 2.x runs every agent as a graph workflow, so invoke_workflow and invoke_agent wrap the Gemini calls and the tool call, matching the events in the terminal. Text: at first it was missing, because ADK 2.15 sends message text as log events and we only export traces. Two settings fix it: OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental and OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY. Then click the generate_content row (not the top row) to see the prompt and the reply (verified). The top rows still show null.

What does the model actually receive?

Seen in Langfuse: the instruction text, with {user:analyst_name?} and {user:team?} already filled in from state, plus the conversation. Before remember_analyst runs it reads (team: ); the very next model call reads Priya (team: merch analytics). The instruction is rebuilt for every model call.

At work I installed the Langfuse SDK instead. Is that different?

Yes. The langfuse package (three LANGFUSE_* variables plus an import) captures the text itself. ADK's own OpenTelemetry spans need no new package but need the two content settings above. Both reach the same Langfuse.

Would a web app do the same as the script?

Either A: the web app imports the agent and runs its own Runner, exactly like the script (that's what adk web is); or B: the agent is deployed on Agent Runtime and the web app calls it over HTTP, and Google's server runs the Runner. We do A now and B in lessons 8 and 14.

Remember this

  • The agent describes what to do; the Runner does it.
  • State keys: no prefix = this conversation, user: = this user across conversations, app: = everyone, temp: = one turn.
  • Tracing is the host's job, not the agent's. The agent code doesn't change.
Lesson 3Real tools: Knowledge Catalog MCP and BigQuery2026-11-25done

The basics

Tools are how an agent does things instead of guessing. We gave it two toolsets: Google's hosted Knowledge Catalog (read the table's real schema) and BigQuery (run read-only SQL). MCP is the standard protocol a server uses to offer tools to any agent.

What we're doing

Facts checked before the lesson (verified 2026-11-25)

Key ideas

Results (verified)

Questions and answers

Is the function tool different from a toolset? Why is one a "server"?

All three look the same to the model: a tool with a name, a description and inputs. The difference is where the code runs. remember_analyst is your own function. BigQueryToolset is a bundle of ready-made Python functions that run in your process and then call the BigQuery API. McpToolset is only the client: you give it an address, it fetches the menu from Google's MCP server, and the server runs the tool. Only that one crosses the network.

We use 3 of the 15 tools. Do we copy them?

No. Nothing is copied or converted; the tools keep running at Google. tool_filter only decides which menu items the agent may see. The hidden ones (delete_entry, set_entry_group_iam_policy, …) can't be ordered by an agent that doesn't know they exist.

Why isn't BigQuery also an MCP server?

It is: Google hosts one at bigquery.googleapis.com/mcp (9 tools, verified). ADK's library toolset came first or serves ADK only, and it has extras (forecast, ask_data_insights). We use the library here and switch to the hosted server in lesson 11, because Agent Gateway can govern MCP calls but not a function inside your own process (docs).

Why was the Langfuse row for MCP send tools/list empty?

It's protocol plumbing (asking the server for its menu). The prompt and results are on the generate_content and tool rows.

Is search_entries the call that lists all tables?

No. The agent already knew the table name from its instruction, so it searched for that one table to get its catalog address. lookup_context then returned the details. With many similar tables the agent would have to choose among the results; our instruction doesn't tell it to ask the user.

Text: lessons/03-tools-and-mcp · evidence: results/03-tools-and-mcp.md.

Remember this

  • tool_filter is the cheapest guardrail: the agent never learns the hidden tools exist.
  • The order is search, then look up, then run the SQL.
  • Grounding has a price: about $0.10 per question here, mostly the catalog text resent on every model call.
Lesson 4A skill2026-11-26done

The basics

A skill is a cheat sheet in a folder: written rules the agent reads before it acts. Ours holds the rules for querying the table (use the partition date column, wrap refunds in IFNULL, drop the last 3 days, never show city names). The main point is that the agent behaves the same way every time.

What we're doing

Key ideas

Facts checked before the lesson (verified 2026-11-25)

Results (verified, from Langfuse, 2026-11-26)

Lesson 3 agentWith the skill
Daily revenue: drops the last 3 days (3 runs each)0 of 3: the catalog text had the rule, the agent ignored it3 of 3, and says why
Top cities: shows city names1 of 2 partial attempts ran SQL by geo.city0 of 3 (+ 1 of 1 on "names of the cities that spent the most")
Daily revenue: model calls / biggest input6 / about 35,000 tokens4 / about 12,500 tokens
Daily revenue: cost per questionabout $0.13about $0.06 (-52%)
Top cities: cost per question$0.065 (one run, not comparable)$0.062 to $0.106
Catalog callsevery runnone

Questions and answers

Isn't a skill about repeatable behavior? Why did the lesson talk about cost?

Yes, repeatable behavior is the main point: the same notes, applied the same way on every question. Cost is a side effect we measured. The lesson now leads with repeatability and runs each question 3 times.

What are "the rules" in the skill?

Notes about how to query our table correctly, which the model can't know alone: filter on event_date_dt; the data spans 2020-11-01 to 2021-01-31; use the USD revenue columns and wrap refunds in IFNULL (they are empty on every purchase row); a day is final 72 hours after it ends (a policy), so drop the last 3 days for daily or "final" figures; exclude '(data deleted)' for traffic sources; never show city or metro, and don't export user_pseudo_id; read nested arrays with UNNEST. Think of a new employee's cheat sheet.

Which level of a skill is always in the prompt, and why does the description matter?

Level 1: name and description (314 characters). It's all the model sees before it decides to load the skill, so a vague description means the skill never gets loaded.

Skill vs MCP tool?

A skill is text that enters the prompt: knowledge, nothing runs. An MCP tool runs code on a server and returns a result: an action.

Why filter out run_skill_script?

A skill can carry code, and we don't need that. It's the same idea as lesson 3's tool_filter: the agent never learns about a tool it doesn't need.

Why must name equal the folder name?

ADK's loader checks it (verified), so a skill can be found by one stable name.

Why label the 72-hour rule as a policy?

The data shows no gap in the last days, so nobody can verify the rule from the table. "Policy" tells readers who owns it and stops us claiming the data proves it.

Why run each question 3 times?

One run can't show whether behavior repeats. The baseline missed the 3-day rule 3 of 3 times and the skill got it right 3 of 3; a single run each could have hidden both patterns.

Is "Resource exhausted" a credentials problem?

No. The tool call before it worked, and tiny Gemini calls with the same credentials returned 200. A 429 means rate limit or capacity; an auth problem is a 401 or 403.

Text: lessons/04-skill · evidence: results/04-skill.md.

Remember this

  • Repeatable behavior first, cost second: the revenue question followed the 3-day rule 3 of 3 times with the skill vs 0 of 3 without, at about half the cost.
  • A skill is knowledge, not enforcement. Hard guarantees need code-level guardrails (lessons 9 and 11).
  • The description decides whether the skill is ever loaded.
Lesson 5Our own MCP server2026-11-26done

The basics

In lesson 3 we used other people's MCP servers. Now we write one: a small program that serves the catalog's pages about our table (the ones Knowledge Studio wrote) by name, reading them live from Knowledge Catalog, so any agent can fetch them, not just one that carries the skill folder. A server offers three kinds of things: tools (the model chooses), resources (the application attaches) and prompts (the user picks).

What we're doing

Facts checked before the lesson (verified 2026-11-26)

How the pieces fit (from the kc-okf POC)

BigQuery table ga4_sample.events
   │ Google creates the entries itself
   ▼
Knowledge Catalog
├─ @bigquery: dataset + table entries   (schema only; 0 of 24 columns described)
└─ context set ga4-merch-context        (Studio's pages, approved by a reviewer)
      │                         │
      │ kcmd pull (a copy)      │ read live (our Lesson 5 server)
      ▼                         ▼
   OKF files on disk         okf_guide agent
   (kcmd mcp serves them;
    they drift)

Questions and answers

What happened (verified 2026-11-26)

StepResult
1. List the pages8 entries in the context set, all made in the kc-okf POC (Studio, plus the hand-written playbook pushed with kcmd push). Nothing in this lesson creates entries.
3. stdio3 tools; search_pages('72') found the 72-hour rule on the events page and the metrics page; result parts ['content', 'isError'].
4. HTTPSame output on port 8808. "All connection attempts failed" meant the server wasn't running yet: start it first.
5. Duplicate copyWith @mcp.tool() the count was 1 (structuredContent appears); with structured_output=False it's 0.
5b. CacheOff: 2.00 / 1.69 / 1.59 s. 60 s cache: 1.87 / 0.00 / 0.00 s.
7. okf_guide7 tool calls (list, 2 searches, 4 pages), 8 model calls, $0.059; correct answer citing the pages. ga4_guide on the same question: 3 to 6 tool calls, $0.049 to $0.096, correct, no sources.

Does Studio fill in the column descriptions on the table entry?

No (verified). Even when asked to, it wrote the column meanings as text in its pages and left 0 of 24 columns described on the BigQuery table entry. The table entry mirrors BigQuery; the pages live in the context set and link to the table. Why Google designed it that way is a guess: real column descriptions belong in BigQuery.

What do kcmd and OKF do, and why read the catalog live instead?

kcmd pull copies the pages to disk as OKF files (Markdown with a header), kcmd push writes edited files back without the reviewer (verified), and kcmd mcp serves the copy on disk, not the catalog. A copy drifts as soon as someone approves a change in Studio. Our agents have a Google login, so reading the catalog live gives one source of truth.

Then why do kcmd and OKF exist at all?

Mostly a guess: for agents that can't reach Google, for editing pages like code (editor, Git, bulk push), to save tokens (files used about a third of MCP's tokens, verified in kc-okf), and for an open format that any vendor's tools can read.

Where does caching fit?

In three places. Data: our server can keep a page for a few seconds (lesson 5, Step 5b: a repeated search went from about 2 s to 0.00 s, verified), at the price of a page being up to that old. Tool results: an agent can keep a fetched page in session state for the rest of the conversation. Model input: Gemini can reuse the repeated start of a long prompt at a lower price; that's where the money is (lesson 4's biggest input was about 35K tokens, resent on every call). Lesson 23, taken after lesson 6, measures the last two.

Google's catalog server already has tools for this. Why write our own?

Mostly to learn the server side. Google's 15 tools can probably fetch a page too (guess, not tested). Ours adds a smaller menu (3 tools for one job), control over the output (no duplicate copy), and something of our own to deploy, register and guard later (lessons 10 and 11). In real projects you write one when the data has no ready-made server.

Which functions in server.py are MCP tools?

Only the decorated ones. @mcp.tool, @mcp.resource and @mcp.prompt register a function; its name, docstring and type hints become what clients see. _get, _page_names and _read have no decorator: helpers that clients never see. A server can offer tools, resources and prompts, plus an instructions note.

Where does the cache live, and can we cache Google's server?

In our server's process memory, between the server and the catalog API. With stdio each client starts a fresh process, so the cache starts empty; an HTTP server keeps it while it runs and shares it with every caller. For someone else's server you can only cache on your side: an ADK callback or plugin, or session state (lesson 23).

Does adk web agents start every agent?

It starts one web server that lists every agent folder and loads an agent when you first use it. The dropdown picks which one gets your message. Our first question went to ga4_guide by mistake because it comes first alphabetically.

Is okf_guide reading local files?

No. Each get_page goes agent → our server (port 8808) → Knowledge Catalog, and comes back with the approved page. ga4_guide's skill is the copy; okf_guide's pages are live.

Why build an MCP server when we already have a skill?

A skill only helps an agent that carries the folder. An MCP server serves the same pages to any agent, and a page can change without redeploying the agents. It's also the piece that gets deployed, registered and guarded on its own later.

stdio or HTTP?

stdio: the client starts the server as a child process and talks through its input and output. No port, no login, private to one machine. HTTP: the server runs by itself at a URL and many agents can share it, so it must be secured (Part B).

Text: lessons/05-own-mcp-server · evidence: results/05-own-mcp-server.md.

Remember this

  • An MCP server is a program that offers tools (the model picks), resources (the app attaches) and prompts (the user picks). A decorator is what makes a function visible.
  • stdio: the client starts the server. HTTP: you start it first, and then it must be secured.
  • Read the source of truth live; a copy (skill, kcmd pull) drifts. A short cache is drift with a known limit.
  • The duplicate structuredContent is a server setting: ours is off, Google's we can't change.
Lesson 6Evaluate the agent2026-11-26done

The basics

An evaluation is a test suite for an agent. You write each question with a good answer once; adk eval runs the agent and scores each answer from 0 to 1 against a threshold. Because answers are free text, some checks use another model as the judge. A simulated user is a model that plays the user for a whole conversation, following a plan.

What we're doing

Facts checked before the lesson (verified 2026-11-26)

Questions and answers

What happened (verified 2026-11-26)

CaseResultAnswer
Total sessionspass360,129 (plus an unasked "final days" count: the 72-hour rule leaking again)
Net revenue, Decemberpass$160,555
Engaged sessions, Januaryfail111,119 instead of 106,301: GA4's own flag, not our policy's definition. The tool path still passed: right tools, wrong meaning
Top 5 citiespassrefused cities (tier C3), gave regions
Net revenue, January, final dayspass$57,001, dropped 29 to 31 January
Simulated NOVICE (Part B)failtask success 0.67, simulator quality 0.5

Same ideas, other names (docs/guess)

IdeaADKDeepEvalRagas
Judge grades against your criteriarubric_based_final_response_quality_v1G-Evalaspect critique
Matches a reference answerfinal_response_match_v2answer correctnessanswer correctness
Called the right toolstool_trajectory_avg_scoretool correctnesstool call accuracy
Answer sticks to tool resultshallucinations_v1faithfulnessfaithfulness
Multi-turn goal reachedmulti_turn_task_success_v1 + simulated userconversation simulator, task completionagent goal accuracy
Fetched the right context, and only thatnone built in; custom metriccontextual precision / recallcontext precision / recall
Platform featureLangfuseLangSmithGoogle
Question sets per versiondatasets, experimentsdatasets, experimentsADK eval sets; Vertex AI Gen AI evaluation service
Judge on live trafficonline evaluatorsonline evaluatorsonline evaluation with AutoRaters (lesson 17)
People label answersannotation queuesannotation queuesto check
Suggests better prompts from failuresto checkprompt improvementVertex prompt optimizer, adk optimize (lesson 17)

DeepEval and Ragas score answers; Langfuse and LangSmith store and run evaluations around traces, and can hold DeepEval or Ragas scores too. Ragas grew out of RAG, so its signature metrics judge retrieval: in lesson 5, okf_guide read 4 whole pages for one question, which a context-precision score would flag.

What is a rubric?

A yes/no checklist line a judge model checks, like a teacher's marking sheet: "the answer gives about $57,001", "the answer leaves out 29 to 31 January and says why". The score is the share of lines met. It needs no exact reference answer.

What goes in the eval set, and what in the config?

The eval set is the exam paper: question, reference answer, expected tools, rubrics, starting state. The config is the marking scheme: which metrics, their thresholds, which judge. Thresholds live only in the config.

Eval set vs simulated eval set?

In an eval set you write every user message, word for word: a regression test. In a simulated set you write only the first message, a plan and a persona (NOVICE, EXPERT or your own), and a model writes the user's next messages from the agent's replies: a test of messy, multi-turn behavior.

Will we also look at Google's own traces, not just Langfuse?

Yes: lesson 16 compares Cloud Trace and Langfuse span by span (agent, model, tool and MCP calls, tokens, A2A hops). adk web already has --otel_to_cloud and --trace_to_cloud (verified in ADK 2.15), so we can try it locally first.

Text: lessons/06-evaluate · evidence: results/06-evaluate.md.

Remember this

  • An eval is a test suite for an agent: write the question and what good looks like once, run it after every change.
  • Use more than one kind of check: the right tools can still give the wrong meaning (q11).
  • A judge model grades free text; rubrics make its job concrete.
  • When a simulated run fails, read the conversation: the judge or the simulator can be the problem.
Lesson 7Multi-agent2026-11-26done

The basics

A team of small agents instead of one big one, built two ways:

  • The model decides (ReAct agents): a front desk transfers the conversation to a specialist, or one agent calls another as a tool.
  • The code decides (a Workflow): a graph of steps (nodes) joined by edges, with routes like "approved" and "fix".

Every Agent is a ReAct loop: think, call a tool, look at the result, repeat. A Workflow only fixes the order between steps; the steps can still be ReAct agents. ADK 2.15 deprecates SequentialAgent, ParallelAgent and LoopAgent in favor of Workflow (chain = sequential, fan-out = parallel, a route pointing back = loop).

How we set it up: ga4_team (the model decides)

ga4_team  (front desk: greets, routes)
 |-- transfer --> policy_expert   explains rules, no SQL
 '-- transfer --> data_analyst    writes + runs SQL
                    '-- calls as a tool --> sql_reviewer   replies APPROVED or problems
sql_reviewer = Agent(name="sql_reviewer", instruction="...reply APPROVED or list problems...",
                     tools=[skill])

policy_expert = Agent(name="policy_expert",
                      description="Explains the data team's rules ... Does not run queries.",
                      tools=[skill])

data_analyst = Agent(name="data_analyst",
                     description="Answers questions that need numbers ...",
                     instruction="...Before running SQL, call `sql_reviewer`...",
                     tools=[skill, bigquery, AgentTool(agent=sql_reviewer)])   # agent as a TOOL

root_agent = Agent(name="ga4_team",                                          # the front desk
                   instruction="Rule question -> policy_expert. Numbers -> data_analyst.",
                   tools=[remember_analyst],
                   sub_agents=[policy_expert, data_analyst])                 # agents it can TRANSFER to
adk web: ga4_team graph with policy_expert, data_analyst and the sql_reviewer tool; the answer 106,301
Your run: the team as a tree (left); data_analyst calls sql_reviewer as a tool, then execute_sql; answer 106,301 (plus an unasked "final" 97,780).

How we set it up: ga4_flow (the code decides)

START -> start_question (code: reset) -> sql_writer -> sql_reviewer -> check_review (code)
                                            ^                               |        |
                                            '------------ "fix" ------------'   "approved"
                                                     (at most 3 tries)               |
                                                                              answer_writer -> END
sql_writer   = Agent(name="sql_writer",   instruction="...feedback: {review?} ...",
                     tools=[skill, get_table_info], output_key="draft_sql")      # saves to state
sql_reviewer = Agent(name="sql_reviewer", instruction="Draft SQL: {draft_sql} ...",
                     tools=[skill], output_key="review")
answer_writer = Agent(name="answer_writer", instruction="Run {draft_sql} ...", tools=[execute_sql])

def start_question(ctx):                     # plain Python node
    ctx.state["tries"] = 0; ctx.state["review"] = ""

def check_review(ctx, review: str):          # reads state["review"]
    ctx.state["tries"] += 1
    if review.startswith("APPROVED") or ctx.state["tries"] >= 3:
        return Event(route="approved")
    return Event(route="fix")

root_agent = Workflow(name="ga4_flow", edges=[
    ("START", start_question, sql_writer, sql_reviewer, check_review),   # a chain
    (check_review, {"approved": answer_writer, "fix": sql_writer}),      # a routing map
])
adk web: ga4_flow graph START, start_question, sql_writer, sql_reviewer (2x), check_review, answer_writer, END; answer 106,301
Your run: writer and reviewer ran 2x (the reviewer sent the first draft back), route: approved, then answer_writer: 106,301.

What happened (verified 2026-11-26)

Your run, "engaged sessions in January?"ga4_teamga4_flow
Answer (policy: 106,301)106,301 (+ unasked "final" 97,780)106,301
Pathpolicy_expert → back to ga4_team → data_analyst → reviewer tool → SQLwriter → reviewer → fix → writer → reviewer → approved → answer
Model calls / tokens / cost11 / 84,767 / $0.1817 / 59,555 / $0.17
Claude's eval run (lesson 6 set, one run each)ga4_guidega4_teamga4_flow
Passed4 of 55 of 53 of 5
Engaged sessions111,119 (GA4 flag)106,301106,166
Tokens per case45K to 133K30K to 74K18K to 37K
Cost of the run$0.52$0.64$0.47

Questions and answers

What are Sequential, Parallel and Loop agents, and why deprecated?

Older fixed-order wrappers: run in order, at the same time, or repeat. ADK 2.15 replaces all three with one Workflow graph, which also does branches and plain Python steps. ga4_flow's loop would have needed a LoopAgent before.

What is AgentTool(agent=sql_reviewer)?

A wrapper that makes an agent look like a tool. The analyst calls it with a request, ADK runs the reviewer, and its reply comes back as the tool result. A sub-agent instead takes over the conversation.

What is SkillToolset with list_skills, load_skill, load_skill_resource?

ADK's tools for reading our one skill folder (skills/ga4-context), the same as lesson 4: list the skills, read SKILL.md, read one reference file. tool_filter leaves out run_skill_script.

Which team guarantees the review?

ga4_flow. In ga4_team the instruction asks the analyst to call the reviewer; in ga4_flow the graph makes it run before any SQL. When a step must not be skipped, put it in the graph.

Text: lessons/07-multi-agent · evidence: results/07-multi-agent.md.

Remember this

  • Transfer = hand the conversation over. Agent as a tool = ask once, stay in charge. Workflow = the code fixes the order.
  • Steps share work through state: output_key writes, {name} reads.
  • A reviewer step catches mistakes, but only those on its checklist.
  • Measure a team with the same eval set; one run is not enough to rank.
Lesson 8Deploy to Agent Runtime2026-11-26done

The basics

Agent Runtime is Google's managed hosting for agents (formerly Vertex AI Agent Engine; the console calls the product Gemini Platform / Agent Platform). adk deploy agent_engine uploads one folder, builds a container and starts it. With Agent Identity the deployed agent is its own principal ("who is making this call"), so it can do only what it has been allowed, not what you can do.

Who is "who": locally vs deployed

Locally (adk web):
  you ──► agent code ──► BigQuery        every call arrives as YOU (your ADC login)  -> works

Deployed (Agent Runtime):
  you ──(1)──► ga4-guide ──(2)──► BigQuery
       principal = you      principal = the agent:
                            principal://agents.global.proj-NUMBER.system.id.goog/.../reasoningEngines/ID
                            no BigQuery role yet  -> 403

How we deployed

agents/ga4_guide/agent.py, __init__.py ──copy──►  build/ga4_guide/agent.py, __init__.py
skills/ga4-context/                   ──copy──►  build/ga4_guide/skills/ga4-context/   (only the folder is uploaded)
agents/ga4_guide/.env (Langfuse key)      ✗      build/ga4_guide/.env  (3 GOOGLE_* lines only)
                                                 build/ga4_guide/requirements.txt  google-adk[a2a,agent-identity,mcp,gcp]
                                                 build/ga4_guide/.agent_engine_config.json  AGENT_IDENTITY, min 0, max 1
                                                          │
                                   adk deploy agent_engine --region us-central1 build/ga4_guide

What happened (verified 2026-11-26)

Console page (Agents → Scale → Deployments → ga4-guide)What we sawWhen we turn it on
Playgroundworks, like adk webnow
Traces, Dashboard"not available", "No data"redeploy with --otel_to_cloud (lesson 16, maybe sooner)
Sessions, Memory Bank, Identity, Security"API not enabled: apphub.googleapis.com" or greyed outenable App Hub (cost checked first), lessons 9 and 13
Agent Registry"Enable Agent Registry API"lesson 10
Policies, GatewaysAPI or network setuplesson 11
Topology"A project owned by an organization is required"lesson 16, only if we get an organization

Questions and answers

What does "principal" mean?

Who is making the call: the thing IAM checks before allowing it, like .NET's ClaimsPrincipal. People, service accounts and agent identities are all principals. principal:// marks the string as a principal ID; the parts after it go from general (the agents directory for this project) to specific (reasoningEngines/ID, this one agent).

Is the "who" me or the agent?

Both, in different calls. When you ask the agent, the principal is you. When the agent calls BigQuery, the principal is the agent. The agent does not borrow your permissions, which is why it gets 403 although you have access.

Why can't we deploy agents/ga4_guide as it is?

Only that folder is uploaded (the skill is outside it), and every line of its .env becomes a cloud setting (it holds the Langfuse key). stage_deploy.py builds a clean folder instead.

Where does our agent show up in the console, and why are pages empty?

Agents → Scale → Deployments → ga4-guide. Traces need --otel_to_cloud; Sessions and Memory Bank need the App Hub API; Registry, Policies and Gateways come in lessons 10 and 11; Topology needs an organization. Agent Garden is Google's sample agents, not ours.

Text: lessons/08-deploy · evidence: results/08-deploy.md.

Remember this

  • A deployed agent acts as itself: its own principal, only its own roles. A 403 means "not allowed yet", not "broken".
  • adk deploy uploads one folder, including its .env: build a clean copy.
  • When a deploy fails, read the container log.
  • Every console feature has a switch (an API, a flag, an organization); we turn each on when its lesson comes.
Lesson 9Identity, IAM and guardrails in code2026-11-26done

The basics

Every call goes through two checks: authentication ("is this ID card real?", fails with 401) and authorization ("does this ID have the role?", fails with 403). IAM decides what the agent's principal can reach; we granted only what it needs, on the smallest scope (least privilege). A plugin decides what the agent may do inside that, on every tool call, whatever the model decides: log, block, or pause for a human (tool confirmation).

model decides a tool call
   │
   ▼  GuardrailsPlugin.before_tool_callback   code: log / BLOCK / ask a human
   │
   ▼  the tool calls Google as the agent's principal (over mTLS)
   │
   ▼  1. authentication: token + certificate accepted?   401 if not
   ▼  2. authorization:  does the principal have the role? 403 if not

Part A: the roles the agent has now (verified)

ScopeRoleLets it
all agents (principalSet)aiplatform.agentDefaultAccessGemini, sessions (added by Google)
projectbigquery.jobUserstart query jobs
dataset ga4_sample onlybigquery.dataViewerread that dataset's tables
projectdataplex.catalogViewersearch and read catalog entries
projectserviceusage.serviceUsageConsumerbill API calls to the project
projectmcp.toolUsercall tools on Google's MCP servers

The catalog: four fixes, found by reading the container log

What the log saidMeaningFix
"Server returned an error response"no catalog roledataplex.catalogViewer, serviceUsageConsumer
401 on dataplex.googleapis.comcredentials not accepted on the plain dooruse dataplex.mtls.googleapis.com
403 on tools/call onlyno permission to call MCP toolsroles/mcp.toolUser
still 403, 32 s after the grantIAM not propagated yetwait a few minutes
Locally:   your login (normal ID card)               ──► any door works
Deployed:  agent token tied to its client certificate ──► only the mTLS door:
           BigQuery's library picks bigquery.mtls.googleapis.com by itself   -> works
           our catalog URL was the plain door, dataplex.googleapis.com       -> 401
           fix: CATALOG_MCP_URL=https://dataplex.mtls.googleapis.com/mcp in the build's .env

The mTLS explanation is a guess that fits every log line; that the fix works is verified. mcp.toolUser never mattered locally because you're the project Owner.

Part B: the guardrails plugin (verified)

RuleWhat we saw
Log every tool calltool call: ... lines locally and in Cloud Logging from the deployed container
Ask before a query without event_date_dtadk web: adk_request_confirmation → Approved → 4,295,584 rows
Block write SQL and geo.cityblocked in tests; the city question in adk web was already refused by the skill (regions instead)
Stop after 3 failed callsin the cloud: tool error 1/3, 2/3, 3/3, then BLOCKED (lesson 8's agent retried 8 times)
class GuardrailsPlugin(BasePlugin):
    async def before_tool_callback(self, *, tool, tool_args, tool_context):
        log.info("tool call: %s %s", tool.name, tool_args)
        ...                                   # return None = run it; return a dict = skip it,
        return {"status": "BLOCKED", ...}     # and the model gets our dict as the result

app = App(name="ga4_guide", root_agent=root_agent, plugins=[GuardrailsPlugin()])
adk web: execute_sql paused by adk_request_confirmation, Approved, then 4,295,584 rows
Your run in adk web: the plugin paused a full-table count (adk_request_confirmation), you clicked Approved, and it ran: 4,295,584 rows.
runtime.py ask: three failed search_entries calls, then BLOCKED
The deployed agent, while the catalog still failed: 3 failed search_entries, then the plugin BLOCKED the next call.

Skill = advice the model usually follows. IAM = what it can reach. Plugin = rules in code it can't skip. Lesson 11 adds the network layer.

Questions and answers

Is an ADK plugin like a Claude Code plugin?

No. A Claude Code or VS Code plugin is a package you install (commands, skills, MCP connectors). An ADK plugin is code that runs around the agent's work, like .NET middleware.

Callback, plugin, tool confirmation?

Callbacks are hooks ADK calls at fixed moments (before or after an agent, model or tool). Set on one agent, it's a callback; registered on the App, it's a plugin and runs for every agent. Tool confirmation is one thing a hook can do: pause the call until a human approves or rejects.

Why did BigQuery work without mTLS setup but the catalog didn't?

Both use mTLS. BigQuery's library chooses the mTLS door itself; the catalog's address was one we typed, the plain door. The roles fixed authorization for both; the mTLS URL fixed authentication for the catalog.

What does runtime.py do?

It talks to the already-deployed agent: info, principal (the IAM member string), ask (invoke it), delete. Deploying is adk deploy's job.

What does GA mean?

General Availability: stable and supported, as opposed to Preview.

Text: lessons/09-identity-and-guardrails · evidence: results/09-identity-and-guardrails.md.

Remember this

  • 401 = your credentials aren't accepted; 403 = you're known but not allowed.
  • Grant one role at a time, read the error, grant the next: that's how least privilege works in practice.
  • IAM changes take a few minutes; the admin audit log shows when each one happened.
  • Deployed agents call Google's mTLS hosts; libraries usually switch for you, hand-typed URLs don't.
  • A plugin's before_tool_callback can log, block, or ask a human, and the model can't skip it.
Lesson 10Agent Registry2026-11-26done

The basics

Agent Registry is the phone book for agents, MCP servers and skills. Each entry has a description and connection details; people and code search it. Code asks the registry "how do I reach X?" instead of carrying the address. Agent Runtime agents and Google's own MCP servers and agents appear by themselves; our own things are registered as services, and skills are uploaded as ZIPs with revisions and a state (only Active ones can be downloaded). The registry is free (docs).

What's in the registry now (verified)

TabOursGoogle's
Agents (47)ga4-guide, in us-central1, type CUSTOM, no agent card ("Non A2A")46 × Workspace Agent (one per location), type A2A_AGENT with a URL and skills
MCP Servers (15)OKF pages (lesson 5), Runtime "MCP" (a service we created, with its tool spec)14 servers named after their APIs, e.g. dataplex.googleapis.com, bigquery.googleapis.com
Skillsprivate-ga4-context, STATE_ACTIVE100+ such as cloud.google.com-bigquery-migration-validator
Agent Registry Agents tab: many Workspace Agent rows and ga4-guide (Agent Runtime, us-central1, Non A2A)
Agents tab: Google's Workspace Agent once per location, and ours, ga4-guide (Agent Runtime, us-central1, Non A2A).
Agent Registry MCP Servers tab: OKF pages (lesson 5) with runtime MCP above Google MCP servers
MCP Servers tab: our OKF pages (lesson 5) (ID ...services:okf-pages, Runtime "MCP") above Google's servers ("Google MCP").

Carried vs looked up

ga4_guide (lessons 4-9)                         ga4_registry (lesson 10)
  skill:   skills/ga4-context/ folder,             skill:   search_skills("words") -> private-ga4-context
           copied into every build                          load_skill downloads it from the registry
  catalog: URL typed in the code                   catalog: "dataplex.googleapis.com" looked up by name,
           (plain or mTLS), our own token                   address and auth from the registry
  update:  edit files, redeploy every agent        update:  upload a new skill revision; no redeploy
  needs:   nothing else                            needs:   the registry to be reachable
skills = SkillToolset(registry=GCPSkillRegistry(project_id=PROJECT, location="global"),
                      tool_filter=["search_skills", "load_skill", "load_skill_resource"])
catalog = registry_mcp_toolset("dataplex.googleapis.com",
                               ["search_entries", "lookup_context", "lookup_entry"])

Your run: search_skills → "1 skill found: private-ga4-context" → load_skill → dataplex_googleapis_com_search_entries / ..._lookup_context → load_skill_resource from private-ga4-context → the 72-hour rule, citing the Skill Registry. About 26 s, $0.11. No skill folder and no catalog URL in the agent's code.

adk web: ga4_registry search_skills found private-ga4-context, load_skill, dataplex tools, answer citing the Skill Registry
ga4_registry in adk web: search_skills → 1 skill found → load_skill("private-ga4-context") → catalog tools from the registry → answer citing the Skill Registry.
Langfuse trace tree for the ga4_registry run with load_skill selected
The same run in Langfuse, read top to bottom as a tree: each line is a span; load_skill's input is private-ga4-context.

Questions and answers

Who created all those agents?

Google: the 46 Workspace Agents are one A2A agent repeated per location, listed automatically, like the 14 Google MCP servers and 100+ Google skills. Only ga4-guide is ours.

Which script does what?

registry.py: agents and MCP servers (agents, mcp, show NAME, tools NAME). skill_registry.py: skills (upload, list, show, activate, search).

Why did search work with "random text"?

It takes words, not a name: the registry matches them against skill names and descriptions, like a search engine. An agent does the same through search_skills, then loads the skill by the name it gets back.

How do I read a Langfuse trace?

Top to bottom, as a tree. The trace is the whole request (POST /run_sse); each line is a span, one step with its own time and, for model calls, tokens and cost. Indentation means "happened inside": the agent contains the model and tool calls, and a catalog tool contains its MCP send tools/call. Click a span for its input and output. The flat Observations list is the same spans without the tree: good for sorting and filtering, confusing for reading the story.

Does ga4_registry use our okf-pages MCP server?

No: it uses Google's Knowledge Catalog server. Ours is registered (findable) but runs only on the laptop (127.0.0.1), so nobody else can reach it until it's on Cloud Run.

Text: lessons/10-registry · evidence: results/10-registry.md.

Remember this

  • The registry is a phone book: find agents, MCP servers and skills by name or by searching, instead of hard-coding them.
  • Google's own entries appear automatically; ours are services (MCP servers, agents) or uploaded skills.
  • An auto-registered ADK agent has no agent card; A2A needs one.
  • Registry toolsets give the whole server: filter the tools yourself.
  • When docs and an API disagree on fields, read the API's discovery document.
Lesson 11Agent Gateway and policies2026-11-27done

The basics

Agent Gateway is a door every outgoing call of a deployed agent must pass: Gemini, sessions, logging, BigQuery, MCP servers. At the door stands a guard (IAP, Identity-Aware Proxy) that checks each call against a list (an IAM access policy): "this agent may reach these addresses". Anything not on the list is blocked (default deny). The agent's code can't go around it, and IAM (lesson 9) still applies at the destination. It worked in our project without an organization or a preview sign-up (verified).

The four pieces, and how they connect

ga4-guide ──(deploy setting)──► 🚪 ga4-egress ──(🔗 ga4-egress-authz)──► 💂 ga4-iap-guard (IAP) ──(reads)──► 📋 ga4-guide-egress
 the agent    agent_gateway_config   the door      the hookup:                  the guard, DRY_RUN            the list (IAM access policy):
                                                   "this door uses this guard"   then ENFORCED                 platform hosts, BigQuery, catalog
PieceMade withWhere to see it
🚪 Gateway ga4-egress (Agent-to-Anywhere)gcloud network-services agent-gateways import + YAMLAgents → Govern → Gateways
💂 Guard ga4-iap-guard (authz extension, IAP V2)gcloud beta service-extensions authz-extensions importNetwork Services → Service Extensions
🔗 Hookup ga4-egress-authz (authz policy)gcloud network-security authz-policies importgcloud only (no console page found)
📋 List ga4-guide-egress (access policy + binding)scripts/egress_rules.py → gcloud iam access-policies create/updateAgents → Govern → Policies
Agent → doorstage_deploy.py --gateway, then adk deployagent → Service configuration → Agent to Anywhere (Egress)
Gateways page with ga4-egress, Agent-to-Anywhere (egress), us-central1
The door: ga4-egress, Agent-to-Anywhere, us-central1.
Service Extensions page with ga4-iap-guard, type Authorization
The guard: ga4-iap-guard, type Authorization. "In use by: None" only counts load balancers.
Policies page: access policy rules for ga4-guide listing unregistered endpoints
The list, grouped under our agent: part 1 and part 2, ten Google addresses each (a list may hold at most 10).
Agent service configuration showing Agent to Anywhere (Egress) set to ga4-egress
The agent connected to the door: "Agent to Anywhere (Egress)" = .../agentGateways/ga4-egress.

What happened (verified)

ModeListWhat the gateway log said
DRY_RUN20 Google platform hostsALLOWED for every call (65), BigQuery and the catalog too. Dry run shows what goes out, not what would be blocked
ENFORCEDplatform + BigQuery, no catalogcatalog: 403 DENIED ×4, everything else ALLOWED. Blocked although IAM allows it (mcp.toolUser)
ENFORCEDplatform + BigQuery + catalogfinal state; the catalog is allowed again
Terminal table of catalog calls: four 403 DENIED tools/list, two earlier 200 ALLOWED tools/call
Every call to the catalog: dry run (200 ALLOWED, with the tool name) and enforced (403 DENIED).
Logs Explorer filtered to authzPolicyInfo.result DENIED, four POST 403 rows to dataplex
Logs Explorer, jsonPayload.authzPolicyInfo.result="DENIED".

Tracing turned on

Redeployed with --otel_to_cloud (plus cloudresourcemanager enabled, which ADK needs to label traces). One question = one trace = 20 spans, 26 s, 120.6K input tokens: 7 Gemini calls around 6 tool calls. A session groups several traces; each log line carries its trace ID. Prompt text isn't stored unless you turn it on.

Trace timeline: invoke_agent with alternating generate_content and execute_tool spans
Timeline: think (Gemini) → tool → think, 20 spans in 26 s.
Trace graph: invoke_agent fanning out to Gemini calls and tool calls, with MCP and BigQuery children
The same trace as a graph: MCP calls and BigQuery jobs sit under their tool span.

Cost check

Billing → Reports: $41.51 this month, all Vertex AI (Gemini), $22 of it on Nov 22 (the kc-okf POC). One question ≈ 120K tokens ≈ $0.11, and evals multiply that. The gateway's price isn't published; it may be billed per hour, so it gets turned off between lessons (README Part E). The $20 project budget warns, it doesn't stop spending.

Questions and answers

IAM vs IAP?

IAM (Identity and Access Management) holds the rules: who may do what. IAP (Identity-Aware Proxy) is the guard that checks those rules on the network as calls pass. IAP also guards web apps and SSH; the gateway uses it for outgoing agent calls.

Why "proxy"?

A middleman that makes the call for you. Every call passes through it, so it can check, log or block each one.

Two things are called "policy"?

The authz policy is the hookup (this door uses this guard). The access policy is the list (this agent may reach these addresses).

Agent identity vs service account?

IAM roles are just as coarse for both. Per-tool control comes from the gateway; its rules name the agent identity, which Agent Runtime requires for a gateway. An agent identity is also one per agent, never shared.

Cloud Run vs Agent Runtime?

Cloud Run runs any container. Agent Runtime runs agents, with sessions, memory, agent identity, gateway support and the agent tabs (Playground, Traces...). "Agent Engine" is its old name, still in adk deploy agent_engine.

Logs vs traces?

Logs are lines ("this happened"). A trace is one question's timeline, made of spans (steps). The Playground's log panel shows only the agent's own logs; the gateway's are in Logs Explorer.

Text: lessons/11-gateway · evidence: results/11-gateway.md.

Remember this

  • Door (gateway) → hookup (authz policy) → guard (IAP) → list (access policy), plus the agent's deploy setting.
  • Enforced egress = default deny: the agent's own needs (Gemini, sessions, telemetry) must be on the list too.
  • Dry run lets everything through; to see real decisions, enforce and read authzPolicyInfo.result.
  • Tool-level rules need the MCP server registered in the gateway's region.
  • A gateway may cost per hour: turn it off after the lesson.
Lesson 12A2A: agents calling agents2026-11-27done

The basics

A2A (Agent2Agent) is an open protocol for one agent to send a task to another over HTTP, even if the other runs elsewhere, is owned by another team, or is built in another framework. Each A2A agent publishes an agent card at /.well-known/agent-card.json: its name, what it does, its skills and where to reach it (like an OpenAPI document). In ADK, to_a2a(agent) turns an agent into an A2A server and builds the card; RemoteA2aAgent(agent_card=URL) is the caller's stand-in for the remote agent.

What we did (locally, verified)

lesson 7:  data_analyst ──AgentTool──► sql_reviewer                         (same process: a function call)
lesson 12: ga4_a2a      ──AgentTool──► RemoteA2aAgent ══A2A/HTTP══► sql_reviewer server :8001   (another process)
FileRole
agents/sql_reviewer/agent.pylesson 7's reviewer, copied into its own agent (skill only)
agents/sql_reviewer/a2a_app.pyto_a2a(root_agent, port=8001), run with uvicorn (terminal A)
agents/ga4_a2a/agent.pythe analyst: skill + BigQuery + AgentTool(RemoteA2aAgent(agent_card="http://localhost:8001/.well-known/agent-card.json"))
adk web trace: sql_reviewer tool span of 11.2 s with many short a2a.client.transport spans under it
The analyst's trace: sql_reviewer took 11.2 of 25 s. Under it, only the A2A "wire" (a2a.client.transport, microseconds each). The reviewer's own Gemini calls ran in the other process, so the caller sees a black box: a duration and an answer.

In the cloud (not run, by choice)

StepWhat would happen
Deploythe reviewer becomes a second Agent Runtime agent with its own agent identity and its own deploys
Findits card goes into Agent Registry as an A2A agent; the analyst finds it by name, not URL (docs; our ADK agent was "Non A2A" in lesson 10, to check)
AllowIAM on the reviewer decides which identities may call it (guess); a gateway rule on destination.agent_registry.agent.name controls agent-to-agent calls (docs)
Costidle free during the Preview; each question pays Gemini on both agents

Questions and answers

What did you change, and did you move anything?

Nothing was moved: ga4_team is unchanged. Two new folders: the reviewer as its own agent (plus its A2A server file), and a new analyst that calls it by URL.

Why does the remote agent show as a tool?

Because we wrapped it in AgentTool: the model calls it like a function and gets the verdict back, and behind it is an HTTP call over A2A.

If agents are found "by name", what about look-alikes? How does it know it's allowed?

"By name" means the resource name (projects/.../locations/.../agents/ID), unique like a primary key; display names can collide. For agents that act, pin it in config instead of letting the model search. Finding is not permission: the gateway rule and IAM check the same resource name at call time, and default deny blocks look-alikes.

REVIEWER = "projects/kc-okf-poc-261122/locations/us-central1/agents/<unique-id>"
sql_reviewer = AgentRegistry(project_id=..., location="us-central1").get_remote_a2a_agent(REVIEWER)
# gateway: destination.agent_registry.agent.name == REVIEWER

Text: lessons/12-a2a · evidence: results/12-a2a.md.

Remember this

  • Agent card = the agent's public description and address, at /.well-known/agent-card.json.
  • to_a2a serves an agent; RemoteA2aAgent calls one.
  • Remote agents are black boxes to the caller: answer and timing, not their steps.
  • Locally you need the address; in the cloud, the registry name plus identity and IAM.
Lesson 13Memory Bank2026-11-27done

The basics

Memory Bank is Agent Platform's long-term memory. It belongs to an Agent Runtime instance. After a conversation, its own model reads it and keeps short facts about the user; a later conversation searches those facts by meaning. We used the deployed ga4-guide's Memory Bank from a local adk web, so nothing new was created.

Three ways to "remember"

Sessionuser: state (lesson 2)Memory Bank
Whatevery event of one conversationkeys our code writes (name, team)short facts a model extracts
Where hereagents/ga4_memory/.adk/session.db (SQLite, also for adk web)the same SQLite fileGoogle, in the Agent Runtime instance
Found bysession iduser id, always all of ita search with the new message (app + user scope)
.NET comparisonchat history tableuser profile tablea search index of notes

How it flows (verified in the ADK code and our run)

SAVE   answer done → after_agent_callback → add_session_to_memory()
       → ingest_events (HTTPS, fire-and-forget, scope app+user) → Memory Bank:
         buffer → its Gemini model extracts facts → merge with existing → store
         (our run: facts existed 5 s later)

USE    new message → before EACH Gemini call, preload_memory searches with that message
       → matching facts come back → ADK adds a temporary user message:
         "The following content is from your previous conversations with the user...
          <PAST_CONVERSATIONS> ... </PAST_CONVERSATIONS>"
       (not in the system instruction, not saved in the session)

What we saw

Questions and answers

Do adk run and adk web keep sessions in different places?

No: in ADK 2.15 both use a SQLite file per agent folder (.adk/session.db). Only our scripts used the in-RAM session service.

How does the conversation get to Memory Bank, and how often are facts extracted?

After each answer our callback sends the whole session (without thinking text) with your Google login. Memory Bank's own model extracts facts of certain kinds (preferences, personal details, instructions: docs) and merges them with what it has. Here that took 5 seconds; the trigger can be configured.

How does a later conversation know about them, even locally?

Same app name and user id. preload_memory searches with the new message before each Gemini call and inserts the matches into that request.

What's behind Memory Bank: SQLite, Redis?

Google doesn't say. It's a managed API with similarity search over the facts. Like BigQuery, you call it; you don't run it.

Did the answer prove memory was used?

Not on its own: the question already said "week", and the skill already nets refunds. The Request view proves the facts reached the model; a question without "week" would show a preference changing an answer (skipped).

Text: lessons/13-memory · evidence: results/13-memory.md.

Remember this

  • Session = one conversation; user: state = keys you choose; Memory Bank = facts a model chooses.
  • Memories are scoped by app and user, and found by searching with the new message.
  • Look at the request, not the answer, to see what memory added.
  • Use the full Agent Runtime resource name for agentengine://.
  • Check what was stored, and delete what shouldn't stay.
Lesson 23Caching and cost2026-11-27done

The basics

Every Gemini call re-sends the whole conversation so far: instruction, skill text, every tool result. One question made 6–7 calls, so a big tool result is paid for again on each call after it. The catalog's lookup_context returns its answer twice (content as text and structuredContent as JSON). This lesson measured four switches, run locally with scripts/measure_tokens.py (2 questions in one session).

Three caches and one trim

analyst question
   │
   ▼
 ADK agent loop ──► Gemini ◄── implicit cache (Google, automatic, always on)
   │                  ▲        explicit context cache (ADK setting, from turn 2)
   ▼                  │ (results join the conversation)
 tool call ── tool cache plugin (skip a repeat catalog call)
          ── trim plugin (cut the duplicate half of the result; not a cache)
   ▼
 catalog MCP
SwitchWhat it isWho does itSaves
COST_TRIMTrimMcpPlugin: drops structuredContentour plugin (cost.py)tokens, on every later call
COST_TOOL_CACHEToolCachePlugin: same call, same arguments → answer from session state (a HIT)our plugin (cost.py)a catalog call, not tokens
COST_CONTEXT_CACHEADK ContextCacheConfig: Gemini stores the conversation's start on purposebuilt into ADK, one setting on Applower price, from turn 2
(always on)implicit cache: Gemini notices a repeated start by itselfGoogle, automaticlower price, not guaranteed

What we measured (verified)

RunSwitches onGemini callsQ1 inputQ2 inputTotal inputCached by Geminivs baseline
1none9142,12373,785215,908132,952 (62%)—
2trim8102,33551,113153,44899,704 (65%)−29%
3trim + tool cache8100,50351,824152,32791,614 (60%)−29%
4+ context cache7101,52025,176 ⚠️126,696 ⚠️69,327 (55%)not comparable

Questions and answers

What does HIT mean? Is it an acronym?

No, just the word: you looked in the cache and found it. The opposite is a miss: not there, so the real call runs and the answer is saved.

Where is the tool cache saved?

In session state, under cache:TOOL:ARGS: process memory for the script and local adk web, Google's session store for the deployed agent. It lasts as long as the conversation. Session state isn't sent to Gemini unless the instruction pulls it in with {...}.

Why plugins, and why isn't the context cache one?

A plugin wraps every tool call of the App in one place (like ASP.NET middleware), without touching the MCP tools ADK builds for us, and is easy to switch on and off. The context cache is about the request to Gemini, not tool calls, and ADK has it built in: one setting, like turning on a feature in options.

How do the switches reach the agent?

COST_TRIM=1 uv run ... sets an environment variable for that one run. When the script imports ga4_guide.agent, the bottom of agent.py checks each switch and adds the plugin (or the cache setting) to the App. Nothing is saved between runs.

Implicit vs explicit caching?

Both happen at Google. Implicit: Google notices by itself that a request starts like a recent one and bills that part lower; no setup, no guarantee. Explicit: ADK tells Google to store the start and gets an ID; later calls send the ID. Guaranteed, from turn 2, with a small storage fee per hour (guess). Like a barista who sometimes remembers your order, vs saving your order in the app.

Is human-in-the-loop a hook or plugin, or something else?

Both ways exist. On a tool: FunctionTool(fn, require_confirmation=True). From a plugin: tool_context.request_confirmation(...) in before_tool_callback, which is what our lesson 9 guardrail does. Either way ADK pauses, emits adk_request_confirmation, waits, and resumes on yes or no. (Claude first said it wasn't a plugin thing; run 4 showed otherwise.)

Text: lessons/23-caching · evidence: results/23-caching.md.

Remember this

  • Every Gemini call re-sends everything so far: shrink big tool results first.
  • Trim isn't a cache; it was the 29% saving.
  • A tool cache saves calls, not tokens, and only if calls repeat.
  • Implicit caching is free and automatic (~60% here); explicit caching needs setup and turn 2.
  • Unattended test runs stop at human-in-the-loop guardrails.

Troubleshooting and lessons learned

Every problem we hit, with its cause and fix, for later reference. Also in docs/troubleshooting.md.

LessonSymptomCauseFix
4429 RESOURCE_EXHAUSTED from GeminiVertex rate limit or capacity on big (~35K-token) bursts; not credentials (tiny calls worked)Wait and retry, run fewer things in parallel (adk eval --parallelism 1)
4, 9, 10The README preview shows old textThe editor's Markdown preview didn't reload after the file changedClose the preview tab and open it again (or open the file itself)
5jq: parse errorThe script printed Python dicts (single quotes, False), not JSONPrint the text parts, or use json.dumps
5ConnectionError: All connection attempts failedThe HTTP MCP server wasn't runningStart the server first (terminal A), keep it running
5The question went to the wrong agent in adk webadk web agents lists every agent folder; the dropdown picks one (alphabetical first)Choose the agent in the dropdown, then New Session
6Rubric metric says NOT_EVALUATED, log: "Rubrics are required."Each rubric needs a type the metric filters onAdd "type": "FINAL_RESPONSE_QUALITY" to each rubric
6adk eval exits with an error codeOne or more cases failed, like a test runnerRead the summary; --print_detailed_results for one case (file.json:case_id)
6, 7A simulated or single run fails or passes "by luck"Free text and model choices vary run to run; judges and simulators can be wrong tooRead the conversation; use --num_runs 3 before deciding
7The reviewer approved a wrong queryA reviewer is only as good as its checklistGive it explicit checks (e.g. "GA4's built-in fields do NOT replace our definitions")
7A pipeline step answered without the reasonEach Workflow step knows only what you pass it (state, instruction)Pass the needed context, or give that step the skill
8Deploy: "container failed to start"The image installed only google-adk[a2a] (no mcp)Read the container log (gcloud logging read 'resource.labels.reasoning_engine_id="ID"'); add requirements.txt
8Secrets would be uploadedadk deploy turns every line of the agent folder's .env into a cloud settingDeploy a clean build folder (scripts/stage_deploy.py)
8Skill missing when deployedOnly the agent folder is uploadedCopy the skill into the build folder
8404 NOT_FOUND for gemini-3.5-flashThe model is served only on global; --region sets GOOGLE_CLOUD_LOCATIONGemini(model=..., client_kwargs={"location": "global"})
8Console Traces / Dashboard empty; Sessions asks for App HubDeployed without --otel_to_cloud; apphub.googleapis.com offTurn each on in its lesson (16, 13), after checking cost
8, 16Topology: "A project owned by an organization is required"Our project has no organizationNeeds Cloud Identity / Workspace (a later decision)
8The deployed agent retried 8 failing callsNothing told it to stopGuardrail plugin: block tools after 3 errors in a turn (lesson 9)
9, 10400 INVALID_ARGUMENT, empty log results, or IndexError in a scriptA placeholder (ID, NAME) was sent literallySet ID=... once and use $ID; scripts accept display names
9"The member is of an unknown type" (nothing between the spaces)$P was empty: a new terminal tabRun the R= / P= lines again in this tab
9A bq job ran in another projectbq uses its own default projectAlways pass --project_id
9grep principalSet didn't show the new roleThe role is on the single principal://, not the principalSet groupgrep reasoningEngines, or the console IAM page
9Catalog MCP: generic "Server returned an error response"ADK hides the server's replyRead the container log for the HTTP status
9Catalog MCP: 401 on dataplex.googleapis.comThe deployed agent's token is accepted only on mTLS hosts (guess, fits the logs)CATALOG_MCP_URL=https://dataplex.mtls.googleapis.com/mcp in the build's .env
9Catalog MCP: 403 on tools/call onlyCalling tools on Google MCP servers needs mcp.tools.callGrant roles/mcp.toolUser
9Still 403 right after a grantIAM takes a few minutes to propagateWait; the admin audit log shows when each grant happened
10Skill upload 400 ... type is requiredRequired fields not in the docs pageRead the API's discovery document ($discovery/rest?version=v1): type: SIMPLE, targetState
10409 The resource is being createdThe skill was still being createdWait; targetState: ACTIVE at creation makes activate unnecessary
10The registry's MCP toolset offers write toolsget_mcp_toolset returns the whole serverSet toolset.tool_filter = [...] afterwards
11gcloud services list doesn't show an API you just enabledWithout --project it lists your default project (ml-ops)Always pass --project kc-okf-poc-261122
11Gateway import: YAML rejected or fields ignoredThe docs' YAML didn't match gcloud's schemaRead $(gcloud info --format='value(installation.sdk_root)')/lib/googlecloudsdk/schemas/networkservices/v1/AgentGateway.yaml: protocols: [MCP] required, governedAccessPath under googleManaged
11EXCEEDS_MAX_CONDITION_LIST_SIZE on access-policies createA condition's list may hold at most 10 items (the docs' example has 20)Split into rules of 10 (scripts/egress_rules.py)
11POLICY_NOT_FOUND on policy-bindings createThe policy create before it had failedFix the policy first; if it says "recently created", wait a minute
11Traces tab empty; log: "Cloud Resource Manager API has not been used"ADK's tracing looks up the project; the API was off. Span view with "only agent invocations" also looked emptyEnable cloudresourcemanager.googleapis.com; use Trace view
11IAP log empty or all granted: trueIAP logged only the MCP initialize, even for calls the door deniedRead the gateway log: jsonPayload.authzPolicyInfo.result (ALLOWED / DENIED)
11DRY_RUN shows ALLOWED for everythingIn dry run the guard lets every call through and the gateway log says ALLOWEDEnforce briefly to see real DENIED results
11Blocked tool, but the agent still answered (and named the blocked source)The same knowledge was in the skill and BigQuery; the model claimed the catalog anywayCheck traces and the gateway log, not just the answer
11Redeployed without --gateway, but the agent is still boundA missing setting keeps its old value on updatePATCH ?updateMask=spec.deploymentSpec.agentGatewayConfig with an empty deploymentSpec (lesson 11 Part E)
12"Ignoring a session state delta from a remote A2A peer"Each agent keeps its own session stateExpected: return what the caller needs in the reply
13404 The ReasoningEngine does not exist from Memory Bankagentengine://ID (short) takes the region from .env (global); the agent is in us-central1Use the full agentengine://projects/P/locations/us-central1/reasoningEngines/ID
13[Errno 98] address already in use (port 8000)A second adk web while the first still runsUse the running one, or stop it first
23A script run stops early; adk_request_confirmation in the tools listLesson 9's guardrail asked a human to approve SQL without event_date_dt; nobody answers in a scriptTreat that run as incomplete and run it again, or test in adk web and approve
23No [tool_cache] HITThe model didn't repeat a catalog call; it used the answer already in the conversationExpected: the cache only helps when calls repeat

Lessons learned

Glossary

Every term used here, in one line, with a .NET or SQL Server comparison. The full version is docs/glossary.md.

TermWhat it isCompare to

How claims are labelled

verifiedWe ran it and saw it. Evidence is in results/.
docsFrom Google's documentation or a spec, not yet checked here.
guessOur expectation, not checked.

Everything on this page is docs or guess until a lesson verifies it. Google renamed Vertex AI to Gemini Enterprise Agent Platform in April 2026, and Agent Engine to Agent Runtime, so older guides use the old names.