<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Karthigayan Devan</title>
    <description>The latest articles on DEV Community by Karthigayan Devan (@karthidec).</description>
    <link>https://dev.to/karthidec</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3519305%2F8ffd958a-5a3c-487b-b4c6-3cb1d19e32bd.png</url>
      <title>DEV Community: Karthigayan Devan</title>
      <link>https://dev.to/karthidec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karthidec"/>
    <language>en</language>
    <item>
      <title>Kanakku: Real-Time Google Cloud Cost &amp; CUD Savings in Your Chrome Side Panel</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sun, 29 Nov 2026 10:40:07 +0000</pubDate>
      <link>https://dev.to/gde/kanakku-real-time-google-cloud-cost-cud-savings-in-your-chrome-side-panel-bb0</link>
      <guid>https://dev.to/gde/kanakku-real-time-google-cloud-cost-cud-savings-in-your-chrome-side-panel-bb0</guid>
      <description>&lt;p&gt;If you work in &lt;a href="https://console.cloud.google.com/" rel="noopener noreferrer"&gt;Google Cloud Console&lt;/a&gt; every day, you probably know this feeling:&lt;/p&gt;

&lt;p&gt;You open Cloud Run, GKE, or Compute Engine to check a service, tweak a setting, or look at logs — and &lt;strong&gt;nowhere on that screen does it tell you what that resource actually costs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To find out, you have to leave what you are doing, open Cloud Billing, filter by project/service/label, and decode list price vs. discounts vs. credits. In practice, most engineers don't do that until month-end when someone pings the Slack channel about a spike.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;Kanakku for Google Cloud&lt;/strong&gt; (&lt;em&gt;"Kanakku"&lt;/em&gt; is Tamil for "accounts", pronounced &lt;em&gt;KUH-nuk-koo&lt;/em&gt;) — an independent, open-source (Apache 2.0) Chrome extension that puts live cost context in a side panel right next to Google Cloud Console.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chrome Web Store:&lt;/strong&gt; &lt;a href="https://chromewebstore.google.com/detail/pjbajldgiboklgbbkdpbdlhdnkekipmc" rel="noopener noreferrer"&gt;https://chromewebstore.google.com/detail/pjbajldgiboklgbbkdpbdlhdnkekipmc&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/karthidec/kanakku-for-google-cloud" rel="noopener noreferrer"&gt;https://github.com/karthidec/kanakku-for-google-cloud&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7go7gld1np7a5559myx4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7go7gld1np7a5559myx4.gif" alt=" " width="560" height="315"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why a Side Panel (and Zero Backend Servers)?
&lt;/h2&gt;

&lt;p&gt;When I started designing this, I had two strict rules for myself:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Zero backend servers.&lt;/strong&gt; I didn't want to host an API, store anyone's credentials, or ask teams to send billing data to a third party.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never expose the full billing export to every developer.&lt;/strong&gt; FinOps/platform admins usually don't want every engineer querying the raw &lt;code&gt;gcp_billing_export_resource_v1_*&lt;/code&gt; table directly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is how Kanakku solves both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An admin runs &lt;a href="https://github.com/karthidec/kanakku-for-google-cloud/blob/main/sql/create_daily_summary.sql" rel="noopener noreferrer"&gt;&lt;code&gt;sql/create_daily_summary.sql&lt;/code&gt;&lt;/a&gt; &lt;strong&gt;once&lt;/strong&gt; as a BigQuery scheduled query. That creates a small, partitioned summary table called &lt;code&gt;daily_resource_costs&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Developers only get read-only access (&lt;strong&gt;BigQuery Data Viewer&lt;/strong&gt; on that summary table + &lt;strong&gt;BigQuery Job User&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;The extension reads &lt;strong&gt;only the active &lt;code&gt;console.cloud.google.com&lt;/code&gt; URL&lt;/strong&gt; (never DOM content or form inputs) to detect which project, service, or resource you're viewing, and queries your own &lt;code&gt;daily_resource_costs&lt;/code&gt; table directly from Chrome using &lt;code&gt;bigquery.readonly&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3rza0j182q66fwk9wg7v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3rza0j182q66fwk9wg7v.png" alt=" " width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What You Actually See Beside the Console
&lt;/h2&gt;

&lt;p&gt;Instead of a single vague number, Kanakku breaks down the real math:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full Cost Waterfall:&lt;/strong&gt; List price → Contract discount → Before credits → CUD credits (&lt;code&gt;COMMITTED_USAGE_DISCOUNT*&lt;/code&gt;, &lt;code&gt;FEE_UTILIZATION_OFFSET&lt;/code&gt;) → Other credits → &lt;strong&gt;Final price this month&lt;/strong&gt; + total savings %.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;30-Day Daily Trend &amp;amp; Burn Rate:&lt;/strong&gt; Plain-SVG bar chart with hover tooltips, % change vs. the same days last month, estimated month-end pace, and data freshness (&lt;code&gt;as of X hours ago&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action Required Alerts &amp;amp; Budget Pacing:&lt;/strong&gt; Highlights flat always-on costs, recent spend spikes, credits masking underlying spend, missing CUD coverage, and an optional monthly budget progress bar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service Lists &amp;amp; Console Home:&lt;/strong&gt; On service list pages (like Cloud Run or Compute Engine) or Console Home (&lt;code&gt;/home/dashboard&lt;/code&gt;), it ranks your top spenders and lets you &lt;strong&gt;Download CSV&lt;/strong&gt; in one click.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local Summary + Optional Gemini:&lt;/strong&gt; Includes a built-in rule-based &lt;strong&gt;Standard Summary&lt;/strong&gt; locally, plus an opt-in &lt;strong&gt;Gemini&lt;/strong&gt; summary (&lt;code&gt;gemini-2.5-flash&lt;/code&gt;) if you choose to enable it with your own API key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Currently supported resource &amp;amp; service views include &lt;strong&gt;Cloud Run, Compute Engine, Cloud Storage, GKE, BigQuery, Vertex AI, Cloud SQL, Cloud Pub/Sub, and Artifact Registry&lt;/strong&gt;, plus all billed services on &lt;strong&gt;Console Home&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9x4epyf7zvitzbis88qf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9x4epyf7zvitzbis88qf.png" alt=" " width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb54zqbkcv0j2d27aa611.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb54zqbkcv0j2d27aa611.png" alt=" " width="799" height="359"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Trying It Out (Takes ~5–10 Minutes)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Admin one-time setup (~5 mins):&lt;/strong&gt; Follow the 4-step &lt;a href="https://github.com/karthidec/kanakku-for-google-cloud/blob/main/docs/admin-guide.md" rel="noopener noreferrer"&gt;Admin Guide&lt;/a&gt; to create and schedule &lt;code&gt;daily_resource_costs&lt;/code&gt; from your Detailed usage cost BigQuery export.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developer setup (~2 mins):&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Install from the &lt;a href="https://chromewebstore.google.com/detail/pjbajldgiboklgbbkdpbdlhdnkekipmc" rel="noopener noreferrer"&gt;Chrome Web Store&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Options&lt;/strong&gt; → &lt;strong&gt;Sign in with Google&lt;/strong&gt; (&lt;code&gt;bigquery.readonly&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Enter your Billing export project ID, Dataset name, and &lt;code&gt;daily_resource_costs&lt;/code&gt;, then click &lt;strong&gt;Test connection&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Open Google Cloud Console and click the Kanakku toolbar icon.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Built in the Open
&lt;/h2&gt;

&lt;p&gt;Kanakku is 100% open source under Apache 2.0, written in TypeScript (Manifest V3, bundled with &lt;code&gt;esbuild&lt;/code&gt;, tested with &lt;code&gt;vitest&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;If you're working in GCP FinOps, SRE, or platform engineering, I'd love for you to try it out, star the repo, or open an issue with which GCP service you'd like supported next:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/karthidec/kanakku-for-google-cloud" rel="noopener noreferrer"&gt;https://github.com/karthidec/kanakku-for-google-cloud&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chrome Web Store:&lt;/strong&gt; &lt;a href="https://chromewebstore.google.com/detail/pjbajldgiboklgbbkdpbdlhdnkekipmc" rel="noopener noreferrer"&gt;https://chromewebstore.google.com/detail/pjbajldgiboklgbbkdpbdlhdnkekipmc&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Disclaimer: Kanakku for Google Cloud is an independent community project and is not affiliated with or endorsed by Google. OAuth verification is currently in review&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>discuss</category>
      <category>googlecloud</category>
      <category>finops</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Your Laptop Is the First Environment: Building on PostgreSQL, Running on AlloyDB</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Tue, 24 Nov 2026 13:28:32 +0000</pubDate>
      <link>https://dev.to/gde/your-laptop-is-the-first-environment-building-on-postgresql-running-on-alloydb-4b9a</link>
      <guid>https://dev.to/gde/your-laptop-is-the-first-environment-building-on-postgresql-running-on-alloydb-4b9a</guid>
      <description>&lt;p&gt;Every team I've worked with has a "dev, test, prod" diagram somewhere. And almost every one of those diagrams leaves out the place where most of the real work happens: the developer's laptop.&lt;/p&gt;

&lt;p&gt;That's a mistake. Your laptop is where the schema gets designed, where queries get rewritten ten times, and where you find out your idea doesn't work. If it's treated as a scratchpad instead of a real environment, you get the classic problem. Everything works locally, then breaks the moment it hits the cloud.&lt;/p&gt;

&lt;p&gt;In this post, I'll walk through the workflow I'd use for a PostgreSQL app that ends up on AlloyDB. Three stages, one schema, one connection string pattern, and as few surprises as possible:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Local:&lt;/strong&gt; PostgreSQL in Docker on your laptop&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shared test:&lt;/strong&gt; AlloyDB Express, cheap and quick to spin up&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Production:&lt;/strong&gt; full AlloyDB&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'll also be honest about the gaps between these stages, because that's where things usually go wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule that makes this work
&lt;/h2&gt;

&lt;p&gt;Before any setup, here's the one idea the whole workflow depends on:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your app should never know which stage it's running in.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Same SQL. Same migration files. Same connection pattern. The only thing that changes between stages is one environment variable. If you find yourself writing &lt;code&gt;if (env === "prod")&lt;/code&gt; around database code, something has leaked, and it will bite you later.&lt;/p&gt;

&lt;p&gt;Keep that in mind. Every decision below is about protecting it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 1: Your laptop
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Match the version first
&lt;/h3&gt;

&lt;p&gt;AlloyDB Express runs &lt;strong&gt;PostgreSQL 18 only&lt;/strong&gt;. So the first thing I'd do is make sure my laptop runs 18 too. Version drift is the quietest bug there is. A query planner change or a new function in one version can make something work locally and fail in the cloud, or the other way around.&lt;/p&gt;

&lt;p&gt;Here's a &lt;code&gt;docker-compose.yml&lt;/code&gt; that gives you PostgreSQL 18 with pgvector already installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pgvector/pgvector:pg18&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localdev&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"5432:5432"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pgdata:/var/lib/postgresql/data&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pgdata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your local connection string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DATABASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"postgres://postgres:localdev@127.0.0.1:5432/app?sslmode=disable"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember that &lt;code&gt;127.0.0.1:5432&lt;/code&gt;. We're going to keep using it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use migrations from day one
&lt;/h3&gt;

&lt;p&gt;I know it's tempting to just run &lt;code&gt;CREATE TABLE&lt;/code&gt; in a SQL editor while you're exploring. Do that for an hour if you want. But the moment the schema starts to settle, move it into migration files. Migrations are the thing that carries your schema from the laptop to production. Without them, every stage drifts a little.&lt;/p&gt;

&lt;p&gt;I like &lt;a href="https://github.com/amacneil/dbmate" rel="noopener noreferrer"&gt;dbmate&lt;/a&gt; for this because it uses plain SQL files and reads &lt;code&gt;DATABASE_URL&lt;/code&gt;, which fits the "only one variable changes" rule perfectly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dbmate new create_products
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That creates a file in &lt;code&gt;db/migrations/&lt;/code&gt;. Fill it in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- migrate:up&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;EXTENSION&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="kt"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;          &lt;span class="kt"&gt;SERIAL&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;        &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="kt"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;price&lt;/span&gt;       &lt;span class="kt"&gt;NUMERIC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;embedding&lt;/span&gt;   &lt;span class="kt"&gt;VECTOR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;768&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- migrate:down&lt;/span&gt;
&lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dbmate up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any migration tool works here. Flyway, Liquibase, Prisma, Alembic, whatever your team already uses. What matters is that the schema lives in version control, not in someone's memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  The gap nobody warns you about: AlloyDB-only features
&lt;/h2&gt;

&lt;p&gt;Here's where most "local to cloud" guides stop being useful. AlloyDB has features plain PostgreSQL doesn't have. The big one for AI apps is the &lt;code&gt;embedding()&lt;/code&gt; function from the &lt;code&gt;google_ml_integration&lt;/code&gt; extension, which lets you create vectors directly in SQL by calling Vertex AI models.&lt;/p&gt;

&lt;p&gt;That's great in the cloud. On your laptop, the extension doesn't exist, so this migration would fail:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;EXTENSION&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;google_ml_integration&lt;/span&gt; &lt;span class="k"&gt;CASCADE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have a few choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create embeddings in your app code instead of SQL. This works everywhere, but you give up one of the nicest AlloyDB features.&lt;/li&gt;
&lt;li&gt;Keep separate SQL for local and cloud. This breaks the "app doesn't know where it runs" rule.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write one migration that adapts to where it runs.&lt;/strong&gt; This is what I'd do.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's that migration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- migrate:up&lt;/span&gt;
&lt;span class="k"&gt;DO&lt;/span&gt; $$
&lt;span class="k"&gt;BEGIN&lt;/span&gt;
  &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;pg_available_extensions&lt;/span&gt;
             &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'google_ml_integration'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="c1"&gt;-- On AlloyDB: use the real thing&lt;/span&gt;
    &lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;EXTENSION&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;google_ml_integration&lt;/span&gt; &lt;span class="k"&gt;CASCADE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;ELSE&lt;/span&gt;
    &lt;span class="c1"&gt;-- On a laptop: a fake embedding() with the same shape&lt;/span&gt;
    &lt;span class="no"&gt;EXECUTE&lt;/span&gt; &lt;span class="nv"&gt;$fn&lt;/span&gt;$
      &lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;OR&lt;/span&gt; &lt;span class="k"&gt;REPLACE&lt;/span&gt; &lt;span class="k"&gt;FUNCTION&lt;/span&gt; &lt;span class="nf"&gt;embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_id&lt;/span&gt; &lt;span class="kt"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="kt"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;RETURNS&lt;/span&gt; &lt;span class="kt"&gt;REAL&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="no"&gt;LANGUAGE&lt;/span&gt; &lt;span class="n"&gt;sql&lt;/span&gt; &lt;span class="no"&gt;IMMUTABLE&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="nv"&gt;$body&lt;/span&gt;$
        &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nb"&gt;array_agg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'x'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;substr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;md5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;bit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;
            &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;2147483647.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;real&lt;/span&gt;
          &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nf"&gt;generate_series&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;768&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
      &lt;span class="nv"&gt;$body&lt;/span&gt;$
    &lt;span class="nv"&gt;$fn&lt;/span&gt;$&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt; $$&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- migrate:down&lt;/span&gt;
&lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;FUNCTION&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="nf"&gt;embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On AlloyDB, it installs the real extension. On your laptop, it creates a stand-in function with the same name and the same output size. The stand-in returns a made-up vector based on a hash of the text. The same text always gives the same vector, so your tests are repeatable.&lt;/p&gt;

&lt;p&gt;Now this query runs unchanged in all three stages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;embedding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'text-embedding-005'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'. '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Be clear about what the fake does and doesn't do.&lt;/strong&gt; It lets you test that your SQL runs, your schema fits, your app handles the results, and your indexes build. It does &lt;strong&gt;not&lt;/strong&gt; give you meaningful search results. "Waterproof jacket" and "rain shell" won't land near each other locally. That's fine. Checking whether search results actually make sense is exactly what the next stage is for.&lt;/p&gt;

&lt;p&gt;The same thinking applies to indexes. AlloyDB has ScaNN, which plain Postgres doesn't. I'd start with an HNSW index from pgvector, because it works the same on your laptop and on AlloyDB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;products_embedding_idx&lt;/span&gt;
  &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="k"&gt;USING&lt;/span&gt; &lt;span class="n"&gt;hnsw&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;embedding&lt;/span&gt; &lt;span class="n"&gt;vector_cosine_ops&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you're in production and want to try ScaNN, add it as its own migration and test it there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 2: AlloyDB Express for shared testing
&lt;/h2&gt;

&lt;p&gt;Your laptop is great for you. It's not great for your team. You need a shared place where teammates, a CI pipeline, or a product manager can see the real thing, with real embeddings and real search results.&lt;/p&gt;

&lt;p&gt;That used to mean a staging database running all month for something that gets used a few hours a week. AlloyDB Express is a much better fit. It's ready in about 2 seconds, it scales compute to zero when nobody uses it, and it has the full AlloyDB AI feature set even on the smallest size.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create it
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In the Google Cloud console, go to &lt;strong&gt;AlloyDB for PostgreSQL&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On the &lt;strong&gt;Get started&lt;/strong&gt; page, find the &lt;strong&gt;AlloyDB Express&lt;/strong&gt; card and click &lt;strong&gt;Create cluster&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Cluster ID&lt;/strong&gt; (I'll use &lt;code&gt;app-test&lt;/code&gt;), a &lt;strong&gt;Password&lt;/strong&gt;, and a &lt;strong&gt;Region&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create cluster&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Express is only in seven regions right now: asia-east1, asia-east2, asia-northeast1, asia-southeast1, australia-southeast1, europe-west2, and us-west1. In the US, that means us-west1.&lt;/p&gt;

&lt;p&gt;Then give AlloyDB permission to call Vertex AI, so the real &lt;code&gt;embedding()&lt;/code&gt; works. Go to &lt;strong&gt;IAM &amp;amp; Admin&lt;/strong&gt;, then &lt;strong&gt;IAM&lt;/strong&gt;, turn on &lt;strong&gt;Include Google-provided role grants&lt;/strong&gt;, click &lt;strong&gt;Grant access&lt;/strong&gt;, and give &lt;code&gt;service-YOUR_PROJECT_NUMBER@gcp-sa-alloydb.iam.gserviceaccount.com&lt;/code&gt; the &lt;strong&gt;Vertex AI User&lt;/strong&gt; role.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Express settings worth knowing
&lt;/h3&gt;

&lt;p&gt;Express keeps things simple, but there are a few settings and fixed values that matter for a shared test environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compute size.&lt;/strong&gt; You get either 1 vCPU with 4 GB RAM, or 2 vCPUs with 8 GB RAM. New instances start at 1 vCPU. If your test suite feels slow, bump it to 2. You only pay while it's awake either way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scale to zero.&lt;/strong&gt; When it's idle, compute goes to zero. The next connection wakes it up in about 20 seconds. For CI, that means the first test might be slow. Add a retry or a short warm-up step to your pipeline instead of letting the first test fail.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connectivity.&lt;/strong&gt; Express supports public DNS and Private Service Connect. It doesn't support a classic public IP. The console turns on both public DNS and Private Service Connect for you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authorized networks.&lt;/strong&gt; If you want to connect with plain psql, open your cluster, go to &lt;strong&gt;Connectivity&lt;/strong&gt;, click &lt;strong&gt;Edit&lt;/strong&gt;, and under &lt;strong&gt;Authorized external networks&lt;/strong&gt; click &lt;strong&gt;Use my IP&lt;/strong&gt;. For team use, I'd skip this and use the Auth Proxy instead (more on that next).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication.&lt;/strong&gt; You can use a regular username and password, or IAM database authentication. For a shared team database, IAM auth is nicer because you're not passing a password around in Slack. Password complexity rules are on by default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connections are fixed at 200.&lt;/strong&gt; The &lt;code&gt;max_connections&lt;/code&gt; flag is locked, and changing it does nothing. Fine for testing, but keep it in mind if your CI runs a lot of parallel jobs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage stops at 20 GB.&lt;/strong&gt; When you hit it, writes stop. Keep test data small and reset it often.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No backups.&lt;/strong&gt; Treat this database as disposable. Everything in it should be recreatable from your migrations and seed scripts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Keep the same connection string
&lt;/h3&gt;

&lt;p&gt;Here's my favorite part of this workflow. Remember &lt;code&gt;127.0.0.1:5432&lt;/code&gt;? We're going to keep it.&lt;/p&gt;

&lt;p&gt;The AlloyDB Auth Proxy runs on your machine (or in CI) and opens a secure tunnel to AlloyDB. Your app connects to localhost like always, and the proxy handles encryption and IAM authentication.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./alloydb-auth-proxy \
  &lt;span class="s2"&gt;"projects/YOUR_PROJECT/locations/us-west1/clusters/app-test/instances/YOUR_INSTANCE"&lt;/span&gt; \
  --public-ip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--public-ip&lt;/code&gt; flag is needed for Express over public DNS. Now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DATABASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"postgres://postgres:YOUR_PASSWORD@127.0.0.1:5432/postgres"&lt;/span&gt;
dbmate up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same migration tool. Same migration files. Same host and port. This time, the &lt;code&gt;DO&lt;/code&gt; block finds &lt;code&gt;google_ml_integration&lt;/code&gt;, installs the real extension, and skips the fake function.&lt;/p&gt;

&lt;p&gt;Stop your local Docker database first, or run the proxy on a different port with &lt;code&gt;--port 5433&lt;/code&gt;, since they'll both want 5432.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use it for what your laptop can't do
&lt;/h3&gt;

&lt;p&gt;This is the stage where you check the things the fake embedding can't tell you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;embedding&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'text-embedding-005'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="s1"&gt;'something to keep me dry on a rainy hike'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;vector&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the results make sense here, your search actually works. If they don't, you found it before your users did.&lt;/p&gt;

&lt;p&gt;A good habit: add a small set of "search quality" checks to your CI that run against Express. For example, "searching for rain gear should return the jacket in the top 3." They're cheap to run, and they catch things unit tests never will.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 3: Full AlloyDB for production
&lt;/h2&gt;

&lt;p&gt;You have two ways to get here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option A: Upgrade your Express cluster in place.&lt;/strong&gt; Go to your cluster, and under &lt;strong&gt;Cluster details&lt;/strong&gt; next to &lt;strong&gt;Cluster ID&lt;/strong&gt;, click &lt;strong&gt;Upgrade&lt;/strong&gt;. Your data, users, and connection string stay the same. This makes sense if your test environment has slowly become the real thing. It happens more often than people admit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option B: Create a fresh production cluster and run your migrations.&lt;/strong&gt; This is what I'd usually do. Production gets its own clean cluster, built from the same migration files, and your Express test environment stays cheap and disposable. Keeping test and production separate is good practice anyway.&lt;/p&gt;

&lt;p&gt;Either way, the connection pattern doesn't change. In Cloud Run, run the Auth Proxy as a sidecar, and your app still talks to &lt;code&gt;127.0.0.1:5432&lt;/code&gt;. Or connect over private networking if that fits your setup better. Your SQL and migrations don't need to know.&lt;/p&gt;

&lt;p&gt;Production is also where you turn on everything Express didn't have: automated backups and point-in-time recovery, high availability with a standby node, read pools, and room to grow past 2 vCPUs and 20 GB. That's also the moment to try ScaNN, in its own migration, measured against the HNSW index you already have.&lt;/p&gt;

&lt;h2&gt;
  
  
  What each stage costs
&lt;/h2&gt;

&lt;p&gt;Since I spend a lot of my time on FinOps, I can't write a post like this without talking about money. The nice thing about this workflow is that cost grows with how real the environment is:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;What you pay for&lt;/th&gt;
&lt;th&gt;Rough cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Laptop&lt;/td&gt;
&lt;td&gt;Nothing&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AlloyDB Express&lt;/td&gt;
&lt;td&gt;Compute per second while awake, storage all the time, embedding calls&lt;/td&gt;
&lt;td&gt;Often free or close to it. The free tier gives 50 compute units and 2 GB of storage a month for the first 12 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AlloyDB production&lt;/td&gt;
&lt;td&gt;Compute per hour, always on, plus storage, backups, and HA if you turn it on&lt;/td&gt;
&lt;td&gt;This is where real spend starts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two cost tips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Do most of your work locally.&lt;/strong&gt; Every query you tune on your laptop is one you don't pay to tune in the cloud.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch embedding calls in Express.&lt;/strong&gt; The database might be nearly free, but every &lt;code&gt;embedding()&lt;/code&gt; call is a paid Vertex AI request. If your CI re-embeds the whole test dataset on every run, that adds up quietly. Seed once, then reuse.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Limitations and caveats
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AlloyDB Express is in preview.&lt;/strong&gt; There's no SLA, and features and pricing can change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PostgreSQL 18 only&lt;/strong&gt; on Express. If your production AlloyDB runs an older version, test on that version too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The fake &lt;code&gt;embedding()&lt;/code&gt; is for development only.&lt;/strong&gt; It checks that your code runs, not that your search is good. Never let it near a real environment. The &lt;code&gt;DO&lt;/code&gt; block guards against this, but review it anyway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extension differences go beyond embeddings.&lt;/strong&gt; If you use other AlloyDB-only features, like the columnar engine, you'll need the same "detect and adapt" approach for each one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Express limits are real:&lt;/strong&gt; 20 GB storage cap, no backups, no HA, 200 connections, and about 20 seconds to wake up from zero.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local Docker isn't AlloyDB.&lt;/strong&gt; Performance numbers from your laptop mean very little. Do load testing on the real thing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Express is only in seven regions&lt;/strong&gt; right now.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The point of this workflow isn't Docker or dbmate or any one tool. It's three habits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Treat your laptop as a real environment, matched to the cloud version.&lt;/li&gt;
&lt;li&gt;Carry your schema forward in migrations, and handle cloud-only features in one place.&lt;/li&gt;
&lt;li&gt;Keep the connection pattern the same everywhere, so your app never knows where it's running.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Do that, and "it works on my laptop" stops being a warning and starts being a pretty good sign.&lt;/p&gt;

&lt;p&gt;If you've found other gaps between local PostgreSQL and AlloyDB, I'd like to hear about them in the comments. I'm sure I haven't hit them all yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/alloydb/docs/express-overview" rel="noopener noreferrer"&gt;AlloyDB Express overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/alloydb/docs/create-manage-express-clusters" rel="noopener noreferrer"&gt;Create and manage AlloyDB Express clusters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/alloydb/docs/ai/configure-vertex-ai" rel="noopener noreferrer"&gt;Integrate AlloyDB with Vertex AI models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/blog/products/databases/introducing-alloydb-express-for-rapid-testing-and-prototyping" rel="noopener noreferrer"&gt;AlloyDB Express announcement on the Google Cloud blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/amacneil/dbmate" rel="noopener noreferrer"&gt;dbmate on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>postgres</category>
      <category>googlecloud</category>
      <category>docker</category>
      <category>devops</category>
    </item>
    <item>
      <title>Build It Friday, Ship It Monday: Taking an AlloyDB Express Prototype to Production</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sun, 22 Nov 2026 18:03:48 +0000</pubDate>
      <link>https://dev.to/karthidec/build-it-friday-ship-it-monday-taking-an-alloydb-express-prototype-to-production-47n4</link>
      <guid>https://dev.to/karthidec/build-it-friday-ship-it-monday-taking-an-alloydb-express-prototype-to-production-47n4</guid>
      <description>&lt;p&gt;Most side projects die in one of two places. Either they never get built because setting up infrastructure eats the whole weekend, or they get built on something cheap and throwaway, and then the founder has to rebuild everything the moment real users show up.&lt;/p&gt;

&lt;p&gt;AlloyDB Express is Google Cloud's attempt at fixing both. It gives you a PostgreSQL database in seconds that scales to zero when nobody's using it, and when you're ready, you upgrade it in place to full AlloyDB. No migration, no new connection string.&lt;/p&gt;

&lt;p&gt;I wanted to see how that plays out over the life of a real product, not just a hello world. So in this post I follow one small app from a Friday night idea to its first real users, and I look at the bill at every stage. I spend most of my day job on FinOps, so the money side is what I care about most here: what it costs, what signals to watch, and when paying more is actually the right call.&lt;/p&gt;

&lt;h2&gt;
  
  
  The app: TrailBuddy
&lt;/h2&gt;

&lt;p&gt;Here's the idea. TrailBuddy helps people find a hiking partner. You write a short bio like "I like slow sunrise hikes, about 5 miles, and I always bring too many snacks," and the app finds people who sound like a good match. It's not keyword matching. It's matching by meaning, using vector search.&lt;/p&gt;

&lt;p&gt;The stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Next.js&lt;/strong&gt; for the web app and API routes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Run&lt;/strong&gt; to host it, because it scales to zero&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AlloyDB Express&lt;/strong&gt; for the database, with vector search built in&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every piece in this stack can go idle and stop charging you for compute. That matters a lot when you have zero users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Friday night: build it
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create the database (about 2 minutes)
&lt;/h3&gt;

&lt;p&gt;In the Google Cloud console:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;AlloyDB for PostgreSQL&lt;/strong&gt;. You land on the &lt;strong&gt;Get started&lt;/strong&gt; page.&lt;/li&gt;
&lt;li&gt;On the &lt;strong&gt;AlloyDB Express&lt;/strong&gt; card, click &lt;strong&gt;Create cluster&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Cluster ID&lt;/strong&gt; (I used trailbuddy-db), a &lt;strong&gt;Password&lt;/strong&gt; for the postgres user, and a &lt;strong&gt;Region&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create cluster&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A quick note on regions. Express is only in seven regions right now: asia-east1, asia-east2, asia-northeast1, asia-southeast1, australia-southeast1, europe-west2, and us-west1. If you're in the US, us-west1 is your only option. Put your Cloud Run service in the same region, because cross-region traffic adds latency and can add data transfer charges.&lt;/p&gt;

&lt;p&gt;The console opens AlloyDB Studio when it's done. Paste this in and click &lt;strong&gt;Run&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;EXTENSION&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="kt"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;EXTENSION&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;google_ml_integration&lt;/span&gt; &lt;span class="k"&gt;CASCADE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;hikers&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;         &lt;span class="kt"&gt;SERIAL&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;       &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;city&lt;/span&gt;       &lt;span class="kt"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;bio&lt;/span&gt;        &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;bio_vector&lt;/span&gt; &lt;span class="kt"&gt;VECTOR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;768&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="kt"&gt;TIMESTAMPTZ&lt;/span&gt; &lt;span class="k"&gt;DEFAULT&lt;/span&gt; &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To let AlloyDB create embeddings, give its service agent the &lt;strong&gt;Vertex AI User&lt;/strong&gt; role. Go to &lt;strong&gt;IAM &amp;amp; Admin&lt;/strong&gt;, then &lt;strong&gt;IAM&lt;/strong&gt;, turn on &lt;strong&gt;Include Google-provided role grants&lt;/strong&gt;, click &lt;strong&gt;Grant access&lt;/strong&gt;, and add &lt;code&gt;service-YOUR_PROJECT_NUMBER@gcp-sa-alloydb.iam.gserviceaccount.com&lt;/code&gt; with the &lt;strong&gt;Vertex AI User&lt;/strong&gt; role. It can take a few minutes to start working.&lt;/p&gt;

&lt;h3&gt;
  
  
  The matching query
&lt;/h3&gt;

&lt;p&gt;This is the whole "AI" part of the app. One query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;bio_vector&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'text-embedding-005'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;vector&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;hikers&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When someone signs up, you store their embedding once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;hikers&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bio&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bio_vector&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'text-embedding-005'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Next.js side
&lt;/h3&gt;

&lt;p&gt;Here's a simple API route for matches, using the &lt;code&gt;pg&lt;/code&gt; package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/api/match/route.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Pool&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"pg"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Pool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5432&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"postgres"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;DB_PASS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"postgres"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;bio&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sb"&gt;`SELECT id, name, city,
            bio_vector &amp;lt;=&amp;gt; embedding('text-embedding-005', $1)::vector AS distance
     FROM hikers ORDER BY distance LIMIT 5`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;bio&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the host is &lt;code&gt;127.0.0.1&lt;/code&gt;. The docs list language connectors for Go, Python, and Java with Express, but not Node.js. So for a Next.js app, I run the AlloyDB Auth Proxy as a sidecar container next to the app in Cloud Run. The proxy handles encryption and IAM auth, and the app just talks to localhost. The proxy needs the &lt;code&gt;--public-ip&lt;/code&gt; flag to reach an Express instance over public DNS.&lt;/p&gt;

&lt;p&gt;Also notice &lt;code&gt;max: 5&lt;/code&gt; on the pool. Keep that in your head. It comes back later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy to Cloud Run
&lt;/h3&gt;

&lt;p&gt;Cloud Run's multi-container support lets you deploy the app and the proxy together. The short version of the service setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Container 1:&lt;/strong&gt; your Next.js app, listening on port 8080&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Container 2:&lt;/strong&gt; the AlloyDB Auth Proxy image, with arguments pointing at your instance URI (&lt;code&gt;projects/PROJECT_ID/locations/us-west1/clusters/trailbuddy-db/instances/INSTANCE_ID&lt;/code&gt;) and the &lt;code&gt;--public-ip&lt;/code&gt; flag&lt;/li&gt;
&lt;li&gt;The Cloud Run service account needs the &lt;strong&gt;AlloyDB Client&lt;/strong&gt; and &lt;strong&gt;Service Usage Consumer&lt;/strong&gt; roles&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before you hit deploy, add two things that are pure FinOps hygiene:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;--max-instances=4 \
--labels=app=trailbuddy,env=prototype,owner=yourname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--max-instances&lt;/code&gt; is your cost ceiling. If a bot hammers your URL at 3 a.m., Cloud Run won't scale to 100 instances and run up a bill. Labels are how you'll find this app's costs later in billing reports. It takes ten seconds now and saves you an hour of digging later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Saturday: set up the money guardrails
&lt;/h2&gt;

&lt;p&gt;This is the step everyone skips, and it's the one I care about most. Do it before you tell anyone about your app.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Budget alert
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In the console, go to &lt;strong&gt;Billing&lt;/strong&gt;, then &lt;strong&gt;Budgets &amp;amp; alerts&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create budget&lt;/strong&gt; and scope it to your project.&lt;/li&gt;
&lt;li&gt;Set the amount to something you'd be okay losing, like $25.&lt;/li&gt;
&lt;li&gt;Keep the alerts at 50%, 90%, and 100%, and click &lt;strong&gt;Finish&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A budget alert doesn't stop spending. It just emails you. But for a weekend project, an email at $12.50 is usually all you need.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Billing export to BigQuery
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Billing&lt;/strong&gt;, then &lt;strong&gt;Billing export&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;BigQuery export&lt;/strong&gt;, click &lt;strong&gt;Edit settings&lt;/strong&gt; for &lt;strong&gt;Detailed usage cost&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Pick a project and create a dataset like &lt;code&gt;billing_export&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It only collects data from the moment you turn it on, so turn it on early. Later, when you're trying to work out what each user costs you, you'll be glad you have the history.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Know what "idle" really costs
&lt;/h3&gt;

&lt;p&gt;Here's the part of Express pricing that's easy to miss. Compute scales to zero, but storage doesn't. You pay for storage every hour, awake or asleep.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What&lt;/th&gt;
&lt;th&gt;How it's billed&lt;/th&gt;
&lt;th&gt;Free each month&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Express compute&lt;/td&gt;
&lt;td&gt;Per second while awake. 1 vCPU = 1 compute unit, 2 vCPU = 2&lt;/td&gt;
&lt;td&gt;50 compute unit hours, first 12 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Express storage&lt;/td&gt;
&lt;td&gt;Per GB used, all the time&lt;/td&gt;
&lt;td&gt;2 GB, first 12 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vertex AI embeddings&lt;/td&gt;
&lt;td&gt;Every &lt;code&gt;embedding()&lt;/code&gt; call&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloud Run&lt;/td&gt;
&lt;td&gt;Requests and CPU time&lt;/td&gt;
&lt;td&gt;Monthly free tier&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;At launch, Google's announcement priced compute at around $0.115 per compute unit hour and storage at $0.30 per GB-month. Prices can vary by region and change after preview, so check the current pricing page before you plan around these numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monday: ship it
&lt;/h2&gt;

&lt;p&gt;You post TrailBuddy in a couple of hiking groups. A few dozen people sign up. Here's what the bill looks like in that first month, using a 1 vCPU instance and those launch prices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The database is awake maybe 2 to 3 hours a day while people browse. That's roughly 60 to 90 compute unit hours. The first 50 are free, so you're paying for 10 to 40. Call it &lt;strong&gt;$1 to $5&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Storage is under 2 GB. &lt;strong&gt;$0&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;A few hundred embedding calls. &lt;strong&gt;Cents&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Cloud Run stays inside the free tier. &lt;strong&gt;$0&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the whole first month comes in around the price of a coffee. That's the real promise of Express. Not that it's fast, but that an idea with no users costs almost nothing to keep alive.&lt;/p&gt;

&lt;p&gt;One honest trade-off: after about 15 minutes of no traffic the database pauses, and the next request takes around 20 seconds while it wakes up. For a hobby app, that's fine. For a landing page you just shared with 5,000 people, the first visitor might bounce. Know it's there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Day 30: people actually show up
&lt;/h2&gt;

&lt;p&gt;A local hiking blog writes about TrailBuddy. Signups jump. Now the bill and the limits start to matter, and this is where FinOps thinking pays off.&lt;/p&gt;

&lt;h3&gt;
  
  
  Signal 1: the database never sleeps anymore
&lt;/h3&gt;

&lt;p&gt;Scale to zero only saves money if there's quiet time. When you have users in a few time zones, the database stays awake almost all day. Let's do the math for a 2 vCPU instance that's awake 24/7:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;730 hours x 2 compute units = 1,460 compute unit hours&lt;/li&gt;
&lt;li&gt;Minus 50 free = 1,410&lt;/li&gt;
&lt;li&gt;At $0.115 each, that's about &lt;strong&gt;$162 a month&lt;/strong&gt; in compute&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's still not much. But notice what changed. You're no longer paying for "only when used." You're paying for "always on," just billed by the second. The main reason to be on Express is gone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Signal 2: the limits start to bite
&lt;/h3&gt;

&lt;p&gt;This is where I'd stop looking at the bill and start looking at risk. Express has hard limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;20 GB of storage&lt;/strong&gt;, and when you hit it, writes stop. Signups would just fail.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No backups and no point-in-time recovery.&lt;/strong&gt; One bad migration and your users' data is gone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No high availability&lt;/strong&gt;, and &lt;strong&gt;no SLA&lt;/strong&gt;. If the zone has a problem, your app is down.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;max_connections is fixed at 200&lt;/strong&gt;, and changing the flag does nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember that &lt;code&gt;max: 5&lt;/code&gt; on the pool? Each Cloud Run instance opens up to 5 connections. If you raise &lt;code&gt;--max-instances&lt;/code&gt; to 50 to handle traffic, that's up to 250 connections, which is more than Express allows. Your cost ceiling and your connection ceiling are the same knob. Plan them together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Signal 3: your unit cost is going up, not down
&lt;/h3&gt;

&lt;p&gt;Here's the FinOps metric I'd actually track: &lt;strong&gt;cost per active user&lt;/strong&gt;. If your billing export is in BigQuery with labels, you can get a rough number with a query like this (adjust the table name to yours):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="no"&gt;FORMAT_DATE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'%Y-%m'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;DATE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usage_start_time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;ROUND&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;trailbuddy_cost&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="sb"&gt;`your-project.billing_export.gcp_billing_export_resource_v1_XXXXXX`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;UNNEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'app'&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'trailbuddy'&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Divide that by your monthly active users. In a healthy setup, the cost per user goes down as you grow. If it's going up, something isn't scaling the way you think. Labels only cover what you labeled, so treat this as a direction, not an exact number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Day 31: the upgrade
&lt;/h2&gt;

&lt;p&gt;The upgrade itself is the easy part:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;AlloyDB for PostgreSQL&lt;/strong&gt;, then &lt;strong&gt;Clusters&lt;/strong&gt;, and click your cluster.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Cluster details&lt;/strong&gt;, next to &lt;strong&gt;Cluster ID&lt;/strong&gt;, click &lt;strong&gt;Upgrade&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Type your cluster ID and click &lt;strong&gt;Confirm&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your data, users, extensions, and connection string all stay the same. Your Next.js code doesn't change at all. If you're on 1 vCPU in a region without C4A machines, the console asks you to resize to 2 vCPUs first.&lt;/p&gt;

&lt;p&gt;But before you click, understand what changes on the bill:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scale to zero turns off.&lt;/strong&gt; The instance runs all the time and is billed per hour at normal AlloyDB rates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory doubles.&lt;/strong&gt; Express runs 1 vCPU to 4 GB. AlloyDB runs 1 vCPU to 8 GB. So a 2 vCPU instance goes from 8 GB to 16 GB of RAM, and you pay for that memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There's no going back.&lt;/strong&gt; You can't downgrade to Express later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a rough comparison using example list rates I saw on the AlloyDB pricing page (about $0.066 per vCPU hour and $0.0112 per GB of memory per hour). Rates vary by region, so plug in your own:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setup&lt;/th&gt;
&lt;th&gt;Rough monthly compute&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Express, 2 vCPU, awake 24/7&lt;/td&gt;
&lt;td&gt;About $162&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AlloyDB, 2 vCPU / 16 GB, single zone&lt;/td&gt;
&lt;td&gt;About $227&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AlloyDB, 2 vCPU / 16 GB, with 1-year commitment&lt;/td&gt;
&lt;td&gt;About $170&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AlloyDB with regional high availability&lt;/td&gt;
&lt;td&gt;Roughly double the single-zone number, since it runs a standby node&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So the upgrade isn't free, but it's not a cliff either. For about $65 more a month, you get backups, no 20 GB cap, room to scale up to 288 vCPUs, and the option to add high availability with a 99.99% SLA.&lt;/p&gt;

&lt;h3&gt;
  
  
  The FinOps moves after the upgrade
&lt;/h3&gt;

&lt;p&gt;Now that you're on regular AlloyDB, a few things open up that weren't available on Express:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Committed use discounts.&lt;/strong&gt; Express doesn't support them. Regular AlloyDB does, with 1-year and 3-year options. Once your usage is steady for a couple of months, a 1-year commitment brings that $227 down to around $170. Don't commit in month one, though. Commit once you know your baseline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Right-size before you scale.&lt;/strong&gt; Watch CPU and memory on the cluster's &lt;strong&gt;Overview&lt;/strong&gt; page and in &lt;strong&gt;System insights&lt;/strong&gt;. Don't jump from 2 to 8 vCPUs because one chart spiked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add high availability when downtime costs more than the standby.&lt;/strong&gt; For a free hobby app, single zone is often fine. Once people pay you, an hour of downtime probably costs more than a month of the standby node.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn on backups right away.&lt;/strong&gt; This is the one I wouldn't wait on.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My "when to upgrade" checklist
&lt;/h2&gt;

&lt;p&gt;If two or more of these are true, it's time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] The database is awake more than about 18 hours a day&lt;/li&gt;
&lt;li&gt;[ ] Storage is past 10 GB and growing&lt;/li&gt;
&lt;li&gt;[ ] You'd be in real trouble if you lost today's data&lt;/li&gt;
&lt;li&gt;[ ] Users are paying you, or you've promised uptime to someone&lt;/li&gt;
&lt;li&gt;[ ] You need more Cloud Run instances than 200 connections can support&lt;/li&gt;
&lt;li&gt;[ ] You need Terraform or Config Connector to manage the database (Express doesn't support them yet)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If none of these are true, stay on Express and enjoy the tiny bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations and caveats
&lt;/h2&gt;

&lt;p&gt;Being honest about what this setup can't do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AlloyDB Express is in &lt;strong&gt;preview&lt;/strong&gt;. There's no SLA, and support may be limited. Pricing and features can change before general availability.&lt;/li&gt;
&lt;li&gt;It runs &lt;strong&gt;PostgreSQL 18 only&lt;/strong&gt;, on a single zonal instance with 1 or 2 vCPUs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No backups, no PITR, no read pools, no HA, no cross-region replication.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;20 GB storage cap&lt;/strong&gt;, and writes stop when you hit it.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;cost numbers in this post are estimates&lt;/strong&gt; based on launch announcements and example list rates. Run your own numbers in the Google Cloud pricing calculator for your region.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embedding calls are billed separately&lt;/strong&gt; through Vertex AI. If you embed a large dataset or re-embed often, that line can grow faster than the database itself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cold starts are about 20 seconds&lt;/strong&gt; after the database pauses.&lt;/li&gt;
&lt;li&gt;Node.js isn't in the list of language connectors the Express docs mention, so I used the Auth Proxy sidecar. Check the docs in case that has changed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The best thing about this setup isn't any single feature. It's that your infrastructure bill can follow your traction. When nobody uses the app, you pay almost nothing. When people show up, you pay a bit more. And when it's a real business, you upgrade in place and unlock the tools that real businesses need, including the discounts.&lt;/p&gt;

&lt;p&gt;Build it Friday. Ship it Monday. Upgrade when the numbers tell you to, not before.&lt;/p&gt;

&lt;p&gt;If you try this, I'd like to know what your first-month bill looked like. Drop it in the comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/blog/products/databases/introducing-alloydb-express-for-rapid-testing-and-prototyping" rel="noopener noreferrer"&gt;AlloyDB Express announcement on the Google Cloud blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/alloydb/docs/express-overview" rel="noopener noreferrer"&gt;AlloyDB Express overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/alloydb/docs/create-manage-express-clusters" rel="noopener noreferrer"&gt;Create and manage AlloyDB Express clusters (including the upgrade)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/alloydb/pricing" rel="noopener noreferrer"&gt;AlloyDB pricing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://itbrief.co.nz/story/google-launches-alloydb-express-for-ai-coding-agents" rel="noopener noreferrer"&gt;IT Brief: Google launches AlloyDB Express for AI coding agents (launch pricing)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>alloydb</category>
      <category>googlecloud</category>
      <category>alloydbsprint</category>
    </item>
    <item>
      <title>Zero to Running in Minutes: Building Your First App on AlloyDB Express</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sun, 22 Nov 2026 16:34:02 +0000</pubDate>
      <link>https://dev.to/karthidec/zero-to-running-in-minutes-building-your-first-app-on-alloydb-express-42g0</link>
      <guid>https://dev.to/karthidec/zero-to-running-in-minutes-building-your-first-app-on-alloydb-express-42g0</guid>
      <description>&lt;p&gt;Every time I start a side project, the database is where I slow down. I open the console, and before writing any code, I am picking machine sizes, setting up networking, and doing math on what it will cost if I forget to turn it off over the weekend.&lt;/p&gt;

&lt;p&gt;So when Google Cloud announced AlloyDB Express in preview, I wanted to see if it really fixes that. I tried it end to end, and this post is my notes from that run. I will show you every click in the console, from an empty project to a small app running on Cloud Run with AI search. If you follow along, you should stay inside the free tier.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what is AlloyDB Express?
&lt;/h2&gt;

&lt;p&gt;Think of it as a small, quick version of AlloyDB for PostgreSQL. It is meant for prototypes, demos, and AI coding agents that need a database right now, not in ten minutes.&lt;/p&gt;

&lt;p&gt;A few things stood out to me when I read the docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is ready in about 2 seconds if you use public DNS. With Private Service Connect it takes about 20 seconds.&lt;/li&gt;
&lt;li&gt;When nobody is using it, compute goes down to zero and you stop paying for compute. The next query wakes it up, and that takes about 20 seconds.&lt;/li&gt;
&lt;li&gt;Even on the smallest size you get the AlloyDB AI features: pgvector, ScaNN vector search, natural language queries, and SQL functions that create embeddings and call Gemini.&lt;/li&gt;
&lt;li&gt;You get one instance with either 1 vCPU and 4 GB RAM, or 2 vCPUs and 8 GB RAM. Storage grows on its own up to 20 GB.&lt;/li&gt;
&lt;li&gt;When you are ready for production, you can upgrade it to regular AlloyDB with one click. Your data, users, and connection string stay the same, so your app code does not change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is how it compares to regular AlloyDB:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;AlloyDB Express&lt;/th&gt;
&lt;th&gt;AlloyDB&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Time to create&lt;/td&gt;
&lt;td&gt;About 2 seconds&lt;/td&gt;
&lt;td&gt;A few minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Compute&lt;/td&gt;
&lt;td&gt;1 or 2 vCPU, goes to zero when idle&lt;/td&gt;
&lt;td&gt;Up to 288 vCPUs, always on&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Storage&lt;/td&gt;
&lt;td&gt;Up to 20 GB&lt;/td&gt;
&lt;td&gt;Up to 128 TB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;High availability&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backups&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SLA&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;99.99% with regional HA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PostgreSQL&lt;/td&gt;
&lt;td&gt;18 only&lt;/td&gt;
&lt;td&gt;14 to 18&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pricing&lt;/td&gt;
&lt;td&gt;Pay for what you use, monthly free tier&lt;/td&gt;
&lt;td&gt;Hourly compute, 30-day free trial&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Before you start
&lt;/h2&gt;

&lt;p&gt;You do not need special credits for this. You just need a Google Cloud project with billing turned on.&lt;/p&gt;

&lt;p&gt;The free tier gives you 50 compute units and 2 GB of storage every month, per billing account, for the first 12 months. Compute is billed by the second and only while the database is awake. Storage is billed all the time, even when it is asleep, so keep your test data small.&lt;/p&gt;

&lt;p&gt;One thing to check early is the region. Right now AlloyDB Express only runs in asia-east1, asia-east2, asia-northeast1, asia-southeast1, australia-southeast1, europe-west2, and us-west1. I am in the US, so I used us-west1, and I put my Cloud Run app there too so the app and the database talk to each other in the same region.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a project
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to console.cloud.google.com and sign in.&lt;/li&gt;
&lt;li&gt;At the top of the page, click the project dropdown.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;New project&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Type a name, for example alloydb-express-demo, and click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Wait a few seconds, then pick your new project from the same dropdown.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Make sure billing is linked
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Click the menu icon (three lines) at the top left.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Billing&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If it says the project has no billing account, click &lt;strong&gt;Link a billing account&lt;/strong&gt; and choose yours.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 3: Turn on the APIs
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;From the menu, go to &lt;strong&gt;APIs &amp;amp; Services&lt;/strong&gt;, then &lt;strong&gt;Library&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Search for &lt;strong&gt;AlloyDB API&lt;/strong&gt;, open it, and click &lt;strong&gt;Enable&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Go back to the Library and search for &lt;strong&gt;Vertex AI API&lt;/strong&gt;. In some consoles it now shows up as &lt;strong&gt;Agent Platform API&lt;/strong&gt;. Open it and click &lt;strong&gt;Enable&lt;/strong&gt;. We need this later for embeddings.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 4: Set a budget alert
&lt;/h3&gt;

&lt;p&gt;I always do this before trying anything new. It takes one minute and saves you from surprises.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;From the menu, go to &lt;strong&gt;Billing&lt;/strong&gt;, then &lt;strong&gt;Budgets &amp;amp; alerts&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create budget&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Pick your project, set the amount to something like $10, and keep the default alert levels.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Finish&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you created the project yourself, you already have the Owner role, which is enough. If someone else owns it, ask them for the &lt;strong&gt;AlloyDB Admin&lt;/strong&gt; role.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Create the AlloyDB Express cluster
&lt;/h2&gt;

&lt;p&gt;Honestly, this part surprised me. It is three fields and one button.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the menu icon at the top left and go to &lt;strong&gt;AlloyDB for PostgreSQL&lt;/strong&gt;. You can also type "AlloyDB" in the search bar at the top.&lt;/li&gt;
&lt;li&gt;You land on the &lt;strong&gt;Get started&lt;/strong&gt; page. You will see three cards: &lt;strong&gt;AlloyDB Express&lt;/strong&gt;, &lt;strong&gt;Production (single zone)&lt;/strong&gt;, and &lt;strong&gt;Production (multi-zone)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On the &lt;strong&gt;AlloyDB Express&lt;/strong&gt; card, click &lt;strong&gt;Create cluster&lt;/strong&gt;. A pane opens on the right.&lt;/li&gt;
&lt;li&gt;Fill in the three fields:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cluster ID&lt;/strong&gt;: I used express-demo. You can also keep the default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Password&lt;/strong&gt;: this is for the postgres user. Click &lt;strong&gt;Generate&lt;/strong&gt; if you want, but copy it somewhere safe because you will need it again. Password rules are on by default, so a weak one will be rejected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Region&lt;/strong&gt;: pick us-west1, or any other supported region close to you.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create cluster&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That is all. The console creates the cluster and a 1 vCPU instance, turns on both public DNS and Private Service Connect for you, and then opens AlloyDB Studio so you can start running SQL.&lt;/p&gt;

&lt;p&gt;If your project already has AlloyDB clusters, you will land on the &lt;strong&gt;Clusters&lt;/strong&gt; page instead of Get started. Just click &lt;strong&gt;Create cluster&lt;/strong&gt; in the toolbar and you will see the same three cards.&lt;/p&gt;

&lt;h3&gt;
  
  
  If you like the command line
&lt;/h3&gt;

&lt;p&gt;You can do the same thing from Cloud Shell. One difference: gcloud does not turn on public DNS by default, so I add it on the instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud beta alloydb clusters create express-demo \
    --region=us-west1 \
    --password=YOUR_PASSWORD \
    --enable-express \
    --project=YOUR_PROJECT_ID

gcloud beta alloydb instances create express-demo-primary \
    --cluster=express-demo \
    --region=us-west1 \
    --instance-type=PRIMARY \
    --cpu-count=1 \
    --enable-public-dns \
    --project=YOUR_PROJECT_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The instance has to start at 1 vCPU. If you need more later, you can change it to 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Add a table in AlloyDB Studio
&lt;/h2&gt;

&lt;p&gt;AlloyDB Studio is a SQL editor inside the console. I like it for quick tests because you do not have to install psql or open any firewall rules.&lt;/p&gt;

&lt;p&gt;If you closed it, here is how to get back:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;AlloyDB for PostgreSQL&lt;/strong&gt;, then &lt;strong&gt;Clusters&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click your cluster name. You will see a small &lt;strong&gt;Express&lt;/strong&gt; tag next to it.&lt;/li&gt;
&lt;li&gt;In the left menu, click &lt;strong&gt;AlloyDB Studio&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Sign in with database postgres, user postgres, and the password you saved.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now for some data. We will build a tiny product catalog for an outdoor gear shop. Paste this into the &lt;strong&gt;Editor 1&lt;/strong&gt; tab and click &lt;strong&gt;Run&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;EXTENSION&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="kt"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;          &lt;span class="kt"&gt;SERIAL&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;        &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="kt"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;price&lt;/span&gt;       &lt;span class="kt"&gt;NUMERIC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;embedding&lt;/span&gt;   &lt;span class="kt"&gt;VECTOR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;768&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Trail Runner Shoes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Lightweight shoes with strong grip for muddy hiking trails'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;89.99&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Rain Shell Jacket'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Waterproof jacket that packs into its own pocket'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;120.00&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Insulated Water Bottle'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Keeps drinks cold for 24 hours, great for long hikes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;29.50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Camping Lantern'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Rechargeable LED lantern with three brightness modes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.00&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Wool Hiking Socks'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Warm, breathable socks that do not cause blisters'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;18.00&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see five rows at the bottom in the &lt;strong&gt;Results&lt;/strong&gt; pane. At this point I had a working database and had not touched a single network setting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connecting from your laptop (optional)
&lt;/h3&gt;

&lt;p&gt;If you want to use psql or your own SQL tool, the easiest way I found is the gcloud connect command. It encrypts the connection for you, and you do not need to add your IP anywhere:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud beta alloydb connect express-demo-primary \
    --cluster=express-demo \
    --region=us-west1 \
    --public-ip \
    --user=postgres \
    --database=postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to connect with plain psql instead, you first need to allow your IP:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your cluster and click &lt;strong&gt;Connectivity&lt;/strong&gt; in the left menu.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Edit&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Authorized external networks&lt;/strong&gt;, click &lt;strong&gt;Use my IP&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Update instance&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the public DNS name from the same page and use it as your host.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 7: Add AI search
&lt;/h2&gt;

&lt;p&gt;This was the part I was most curious about. With regular PostgreSQL, adding semantic search usually means a separate vector database or an extra pipeline. Here it is just SQL.&lt;/p&gt;

&lt;h3&gt;
  
  
  7a. Give AlloyDB permission to call Vertex AI
&lt;/h3&gt;

&lt;p&gt;You only do this once per project. AlloyDB calls Vertex AI using its own service agent, and that agent needs a role.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the Google Cloud logo at the top left to open the &lt;strong&gt;Welcome&lt;/strong&gt; page. Copy your &lt;strong&gt;Project number&lt;/strong&gt; (the number, not the project ID).&lt;/li&gt;
&lt;li&gt;From the menu, go to &lt;strong&gt;IAM &amp;amp; Admin&lt;/strong&gt;, then &lt;strong&gt;IAM&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Turn on the checkbox &lt;strong&gt;Include Google-provided role grants&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Grant access&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;New principals&lt;/strong&gt;, paste this, with your project number in place of the placeholder:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service-YOUR_PROJECT_NUMBER@gcp-sa-alloydb.iam.gserviceaccount.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In &lt;strong&gt;Select a role&lt;/strong&gt;, search for and pick &lt;strong&gt;Vertex AI User&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Give it a few minutes before the next step. The role can take up to 7 minutes to kick in, so if your first embedding call fails with a permission error, just wait a bit and run it again.&lt;/p&gt;

&lt;h3&gt;
  
  
  7b. Create embeddings
&lt;/h3&gt;

&lt;p&gt;Go back to AlloyDB Studio and run this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;EXTENSION&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;google_ml_integration&lt;/span&gt; &lt;span class="k"&gt;CASCADE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;embedding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'text-embedding-005'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'. '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now every product has a vector of 768 numbers that describes what it is about.&lt;/p&gt;

&lt;h3&gt;
  
  
  7c. Search by meaning
&lt;/h3&gt;

&lt;p&gt;Try a question that does not use any of the words in your product names:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;embedding&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'text-embedding-005'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'something to keep my feet dry and comfy on a long walk'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;vector&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the socks and the trail shoes near the top, even though the words "dry" and "comfy" are nowhere in the data. That is semantic search in one query.&lt;/p&gt;

&lt;p&gt;With five rows you do not need an index. Once you have thousands of rows, add a ScaNN or HNSW index so searches stay fast.&lt;/p&gt;

&lt;h3&gt;
  
  
  7d. Ask in plain English
&lt;/h3&gt;

&lt;p&gt;AlloyDB Studio also has Gemini built in. In the editor, click the Gemini (spark) icon and type something like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Show me all products under 50 dollars, cheapest first&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Gemini writes the SQL. Read it first, then click &lt;strong&gt;Run&lt;/strong&gt;. I find this really handy in live demos, and it is the same idea AI coding agents use when they work with your database.&lt;/p&gt;

&lt;p&gt;One thing to keep in mind on cost: every embedding() call is a paid Vertex AI request. For a few hundred rows it is pennies, but check the pricing before you embed a big dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 8: Put a small app on Cloud Run
&lt;/h2&gt;

&lt;p&gt;A database alone is not much of a demo, so let's add a tiny search API in front of it. I picked Cloud Run because it also scales to zero. When nobody is using the app, neither the app nor the database costs you compute.&lt;/p&gt;

&lt;h3&gt;
  
  
  8a. Open Cloud Shell
&lt;/h3&gt;

&lt;p&gt;At the top right of the console, click the &lt;strong&gt;Activate Cloud Shell&lt;/strong&gt; button (it looks like &lt;code&gt;&amp;gt;_&lt;/code&gt;). A terminal opens at the bottom of the page. If you prefer a code editor, click &lt;strong&gt;Open Editor&lt;/strong&gt; in the Cloud Shell toolbar.&lt;/p&gt;

&lt;h3&gt;
  
  
  8b. Let Cloud Run talk to AlloyDB
&lt;/h3&gt;

&lt;p&gt;Cloud Run runs as the default compute service account unless you choose another one. That account needs two roles. Paste this into Cloud Shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;gcloud config get-value project&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;PROJECT_NUMBER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;gcloud projects describe &lt;span class="nv"&gt;$PROJECT_ID&lt;/span&gt; --format=&lt;span class="s1"&gt;'value(projectNumber)'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;SA&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$PROJECT_NUMBER-compute@developer.gserviceaccount.com"&lt;/span&gt;

gcloud projects add-iam-policy-binding &lt;span class="nv"&gt;$PROJECT_ID&lt;/span&gt; \
  --member=&lt;span class="s2"&gt;"serviceAccount:$SA"&lt;/span&gt; --role=&lt;span class="s2"&gt;"roles/alloydb.client"&lt;/span&gt;

gcloud projects add-iam-policy-binding &lt;span class="nv"&gt;$PROJECT_ID&lt;/span&gt; \
  --member=&lt;span class="s2"&gt;"serviceAccount:$SA"&lt;/span&gt; --role=&lt;span class="s2"&gt;"roles/serviceusage.serviceUsageConsumer"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8c. Write the app
&lt;/h3&gt;

&lt;p&gt;Make a folder for it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir express-app &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; express-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file called requirements.txt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flask
gunicorn
pg8000
google-cloud-alloydb-connector
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then create main.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;jsonify&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cloud&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alloydbconnector&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Connector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;IPTypes&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;connector&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Connector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="no"&gt;INSTANCE_URI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"INSTANCE_URI"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_conn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;connector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="no"&gt;INSTANCE_URI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pg8000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"postgres"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"DB_PASS"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"postgres"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;ip_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;IPTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PUBLIC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/search"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"q"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_conn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"""SELECT name, price FROM products
           ORDER BY embedding &amp;lt;=&amp;gt; embedding('text-embedding-005', %s)::vector
           LIMIT 3"""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I used the AlloyDB Python connector here. It encrypts the connection and handles auth with IAM, so you do not have to allowlist any IP addresses.&lt;/p&gt;

&lt;h3&gt;
  
  
  8d. Deploy it
&lt;/h3&gt;

&lt;p&gt;Still inside the express-app folder, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud run deploy express-search \
  --source . \
  --region us-west1 \
  --allow-unauthenticated \
  --set-env-vars &lt;span class="nv"&gt;INSTANCE_URI&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;projects/&lt;span class="nv"&gt;$PROJECT_ID&lt;/span&gt;/locations/us-west1/clusters/express-demo/instances/express-demo-primary,DB_PASS=YOUR_PASSWORD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it asks to turn on the Cloud Run, Cloud Build, or Artifact Registry APIs, type y. The first deploy takes a few minutes. When it is done, it prints a Service URL.&lt;/p&gt;

&lt;h3&gt;
  
  
  8e. Try it
&lt;/h3&gt;

&lt;p&gt;Open your Service URL in a browser and add a search at the end, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://express-search-xxxxx.us-west1.run.app/search?q=gear for a rainy hike
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get the top three matching products back as JSON. You can find the app again anytime in the console under &lt;strong&gt;Cloud Run&lt;/strong&gt;, then &lt;strong&gt;Services&lt;/strong&gt;, then &lt;strong&gt;express-search&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A small heads up: if the database has been idle for a while, the first request takes around 20 seconds because the instance is waking up. After that it responds normally.&lt;/p&gt;

&lt;p&gt;Also, putting the password in an environment variable is okay for a quick test, but not for anything real. For that, move it to Secret Manager or use IAM database authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it costs, what it can't do, and how to clean up
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Cost
&lt;/h3&gt;

&lt;p&gt;For a small test like this, the bill should be close to zero:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;What you pay for&lt;/th&gt;
&lt;th&gt;Free allowance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AlloyDB Express&lt;/td&gt;
&lt;td&gt;Compute by the second while awake, storage all the time&lt;/td&gt;
&lt;td&gt;50 compute units and 2 GB storage a month, first 12 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloud Run&lt;/td&gt;
&lt;td&gt;Requests and CPU time&lt;/td&gt;
&lt;td&gt;Monthly free tier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vertex AI embeddings&lt;/td&gt;
&lt;td&gt;Each embedding() call&lt;/td&gt;
&lt;td&gt;No free allowance, but small tests cost pennies&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To keep an eye on usage, open your cluster's &lt;strong&gt;Overview&lt;/strong&gt; page. Under &lt;strong&gt;Cluster details&lt;/strong&gt;, &lt;strong&gt;Total storage used&lt;/strong&gt; shows how much of the 20 GB you have used. The &lt;strong&gt;CPU utilization&lt;/strong&gt; and &lt;strong&gt;Active connections&lt;/strong&gt; charts show compute. For more detail, click &lt;strong&gt;System insights&lt;/strong&gt; in the left menu.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limits to know before you build on it
&lt;/h3&gt;

&lt;p&gt;I would not put production data on Express yet. Here is why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is in preview, so there is no SLA and support may be limited.&lt;/li&gt;
&lt;li&gt;It runs PostgreSQL 18 only.&lt;/li&gt;
&lt;li&gt;You get one zonal instance with 1 or 2 vCPUs. No read pools, no high availability, no cross-region replication.&lt;/li&gt;
&lt;li&gt;Storage stops at 20 GB. Once you hit it, writes stop working.&lt;/li&gt;
&lt;li&gt;There are no backups and no point-in-time recovery. Only keep data you can recreate.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;max_connections&lt;/code&gt; is fixed at 200, and changing the flag does nothing.&lt;/li&gt;
&lt;li&gt;Memory-heavy extensions can run out of memory on these small sizes.&lt;/li&gt;
&lt;li&gt;Terraform and Config Connector are not supported yet, and neither are customer-managed encryption keys.&lt;/li&gt;
&lt;li&gt;Only seven regions so far, and us-west1 is the only one in the US.&lt;/li&gt;
&lt;li&gt;Waking up from zero takes about 20 seconds.&lt;/li&gt;
&lt;li&gt;You don't pick a maintenance window. Updates are usually applied when the instance wakes up, or during quiet hours if it is running.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Moving to production
&lt;/h3&gt;

&lt;p&gt;When your prototype is ready to grow up, you can upgrade it in place:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;AlloyDB for PostgreSQL&lt;/strong&gt;, then &lt;strong&gt;Clusters&lt;/strong&gt;, and click your cluster.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Cluster details&lt;/strong&gt;, next to &lt;strong&gt;Cluster ID&lt;/strong&gt;, click &lt;strong&gt;Upgrade&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Type your cluster ID to confirm and click &lt;strong&gt;Confirm&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your data, users, and connection string stay the same, so your app keeps working. Two things to keep in mind: after the upgrade the database no longer scales to zero and is billed at normal AlloyDB rates, and you can't go back to Express. If you are on 1 vCPU in a region that does not support C4A machines, the console will ask you to resize to 2 vCPUs first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cleaning up
&lt;/h3&gt;

&lt;p&gt;When you are done playing, delete everything so nothing keeps charging you:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Cloud Run&lt;/strong&gt;, select express-search, and click &lt;strong&gt;Delete&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;AlloyDB for PostgreSQL&lt;/strong&gt;, then &lt;strong&gt;Clusters&lt;/strong&gt;, and click your cluster.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Instances in your cluster&lt;/strong&gt;, click the three dots next to your instance, choose &lt;strong&gt;Delete&lt;/strong&gt;, and type the instance ID.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Delete cluster&lt;/strong&gt; and type the cluster ID.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Or from Cloud Shell, in one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud alloydb clusters delete express-demo --region=us-west1 --force
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is permanent. Express has no backups, so there is no undo.&lt;/p&gt;

&lt;h2&gt;
  
  
  My take
&lt;/h2&gt;

&lt;p&gt;In one sitting we went from an empty project to a real app: a PostgreSQL database that was ready in seconds, semantic search written in plain SQL, questions in plain English through Gemini, and a Cloud Run API on top. And when nobody uses it, almost all of it goes quiet and stops charging for compute.&lt;/p&gt;

&lt;p&gt;It is still a preview, and the limits are real. No backups and a 20 GB cap mean I would keep it to prototypes, hackathons, demos, and agent experiments for now. But for those, it takes away most of the setup pain, and the one-click upgrade means you do not have to start over if the idea works.&lt;/p&gt;

&lt;p&gt;If you try it, I would love to hear what you build. Drop it in the comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/blog/products/databases/introducing-alloydb-express-for-rapid-testing-and-prototyping" rel="noopener noreferrer"&gt;AlloyDB Express announcement on the Google Cloud blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/alloydb/docs/express-overview" rel="noopener noreferrer"&gt;AlloyDB Express overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/alloydb/docs/create-manage-express-clusters" rel="noopener noreferrer"&gt;Create and manage AlloyDB Express clusters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/alloydb/docs/ai/configure-vertex-ai" rel="noopener noreferrer"&gt;Integrate AlloyDB with Vertex AI models&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>alloydbsprint</category>
      <category>googlecloud</category>
      <category>alloydb</category>
    </item>
    <item>
      <title>MCP, A2A, UCP, AP2... Confused? A Simple Map of AI Agent Protocols (November 2026)</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sun, 15 Nov 2026 20:09:35 +0000</pubDate>
      <link>https://dev.to/gde/mcp-a2a-ucp-ap2-confused-a-simple-map-of-ai-agent-protocols-november-2026-3ph</link>
      <guid>https://dev.to/gde/mcp-a2a-ucp-ap2-confused-a-simple-map-of-ai-agent-protocols-november-2026-3ph</guid>
      <description>&lt;p&gt;MCP. A2A. AG-UI. A2UI. UCP. AP2. ACP. x402. And as of this week, Poppy.&lt;/p&gt;

&lt;p&gt;If your head spins every time a new agent protocol drops, you're not alone. Even the acronyms collide: "ACP" now means at least two different things depending on who you ask.&lt;/p&gt;

&lt;p&gt;Here's the good news. These protocols are &lt;strong&gt;not competing with each other&lt;/strong&gt;. They are layers, like the network stack. Once you see the layers, the whole thing clicks.&lt;/p&gt;

&lt;p&gt;This guide gives you the map, what's new as of November 2026, a real end-to-end example, and an honest answer to "which ones do I actually need?"&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR: one question picks the protocol
&lt;/h2&gt;

&lt;p&gt;Ask yourself: &lt;strong&gt;what is my agent talking to?&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;My agent is talking to...&lt;/th&gt;
&lt;th&gt;Use this&lt;/th&gt;
&lt;th&gt;In one line&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tools and data&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;MCP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Plug the agent into APIs, databases and files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Another agent&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;A2A&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hand off work to an agent someone else built&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A user's screen&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;AG-UI&lt;/strong&gt; / &lt;strong&gt;A2UI&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Show the user what the agent is doing, live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A store or business&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;UCP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Search, cart, checkout and orders in one standard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A payment&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;AP2&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Prove the user really approved the purchase&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep this table handy. Everything below just adds detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack at a glance
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+---------------------------------------------------+
|  USER          AG-UI (live events) / A2UI (UI)     |
+---------------------------------------------------+
|  PAYMENTS      AP2 (signed mandates), x402         |
+---------------------------------------------------+
|  COMMERCE      UCP (catalog, cart, checkout)       |
+---------------------------------------------------+
|  AGENTS        A2A (agent to agent)                |
+---------------------------------------------------+
|  TOOLS         MCP (agent to tools and data)       |
+---------------------------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One agent can use all five layers in a single task. We'll walk through exactly that later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 1: MCP, the agent's hands
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt; connects an agent to tools and data: your database, GitHub, Slack, a weather API, anything. Build an MCP server once, and any MCP-compatible agent can use it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's new:&lt;/strong&gt; the current spec is &lt;strong&gt;2026-07-28&lt;/strong&gt;, and it's the biggest change yet. MCP moved from a stateful, session-based protocol to a &lt;strong&gt;stateless request and response&lt;/strong&gt; protocol.&lt;/p&gt;

&lt;p&gt;What that means in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No more sessions.&lt;/strong&gt; The session handshake is gone, so any request can go to any server instance. Great news for anyone running MCP servers behind a load balancer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A new discovery call.&lt;/strong&gt; Clients can ask a server what it supports before sending other requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Some features are deprecated.&lt;/strong&gt; Roots, Sampling and Logging are now deprecated, and Tasks moved out of the core into an official extension.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Old transport is on the way out.&lt;/strong&gt; If your server still uses HTTP+SSE, the spec tells you to migrate to Streamable HTTP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you built an MCP server last year, read the changelog before your next upgrade.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use it when:&lt;/strong&gt; your agent needs to read or do something in another system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 2: A2A, agents talking to agents
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Agent2Agent (A2A)&lt;/strong&gt; lets agents built by different teams, vendors or companies work together. Each agent publishes an "Agent Card" describing what it can do, and other agents discover it and delegate tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MCP vs A2A in one line:&lt;/strong&gt; MCP is for tools you control. A2A is for agents you don't own, which have their own brains and make their own decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's new:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;v1.0 shipped on March 12, 2026&lt;/strong&gt;, the first stable version, with JSON-RPC, gRPC and HTTP+JSON bindings. The v1.0.1 patch followed in May.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v1.1 is in the works.&lt;/strong&gt; A release candidate tagged in late October adds two-way streaming while a task runs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It moved in with MCP.&lt;/strong&gt; A2A joined MCP in the Agentic AI Foundation (under the Linux Foundation) in August 2026.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Big vendors are on board.&lt;/strong&gt; Microsoft Copilot Studio now lets you expose an agent as a remote MCP server or an A2A agent.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use it when:&lt;/strong&gt; you need a specialist agent from another team or company, like a travel policy agent, a fraud check agent or a partner's booking agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 3: AG-UI and A2UI, the agent's face
&lt;/h2&gt;

&lt;p&gt;Agents that work silently in the background feel broken to users. These two protocols fix that, and they solve different halves of the problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AG-UI (Agent-User Interaction Protocol)&lt;/strong&gt; is the live wire. It streams events from the agent to your app in real time: "searching hotels...", "found 12 options...", "waiting for your approval." It's event-based and runs over HTTP and Server-Sent Events.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A2UI&lt;/strong&gt; is about &lt;strong&gt;what&lt;/strong&gt; to show. The agent describes UI (cards, forms, approval buttons) in a declarative format, and your app renders it with its own components. No arbitrary code from the agent runs in your app.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simple way to remember it: &lt;strong&gt;A2UI describes the screen, AG-UI delivers it live.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are a few more in this layer worth knowing about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MCP Apps&lt;/strong&gt; is MCP's own extension for showing UI from tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent Client Protocol&lt;/strong&gt; connects coding agents to code editors. (Yes, this is one of the two "ACPs.")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use it when:&lt;/strong&gt; a human watches the agent work or needs to approve something.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 4 and 5: agentic commerce (the most exciting part)
&lt;/h2&gt;

&lt;p&gt;This is where agents stop just answering questions and start &lt;strong&gt;spending money&lt;/strong&gt;. It's also where trust matters most, so two protocols split the job.&lt;/p&gt;

&lt;h3&gt;
  
  
  UCP: the shopping standard
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Universal Commerce Protocol (UCP)&lt;/strong&gt; gives agents one standard way to work with any business, from discovery to checkout and after.&lt;/p&gt;

&lt;p&gt;Its core capabilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Catalog:&lt;/strong&gt; search and browse products&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cart:&lt;/strong&gt; build multi-item carts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Identity linking:&lt;/strong&gt; connect the user's account using OAuth 2.0, without sharing passwords&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Checkout:&lt;/strong&gt; taxes, shipping, discounts, the whole messy reality&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Order:&lt;/strong&gt; confirmation, tracking and returns through webhooks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What's new:&lt;/strong&gt; UCP has grown beyond shopping. The spec site now shows three tracks: &lt;strong&gt;shopping, lodging and food&lt;/strong&gt;. Hotel booking and food ordering specs are still drafts, so expect changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who's behind it:&lt;/strong&gt; the co-developer list reads like a who's who of commerce: Google, Shopify, Etsy, Wayfair, Target, Walmart, Amazon, Microsoft, Meta, Salesforce and Stripe, plus travel players like Booking.com, Expedia Group, Hilton and Marriott, and food players like DoorDash and Uber Eats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The detail businesses care about:&lt;/strong&gt; the business stays the Merchant of Record and keeps the customer relationship. The agent doesn't take over the store.&lt;/p&gt;

&lt;h3&gt;
  
  
  AP2: proof that you said yes
&lt;/h3&gt;

&lt;p&gt;Here's the problem AP2 solves. Every payment system today assumes a human clicked "buy." When an AI agent clicks it, three hard questions appear:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Authorization:&lt;/strong&gt; did the user really give the agent permission for this purchase?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authenticity:&lt;/strong&gt; does the request match what the user actually wanted, or did the agent hallucinate?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accountability:&lt;/strong&gt; if something goes wrong, who's responsible?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Agent Payments Protocol (AP2)&lt;/strong&gt; answers these with &lt;strong&gt;mandates&lt;/strong&gt;: tamper-evident, cryptographically signed records of what the user approved. There are two kinds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Checkout Mandate:&lt;/strong&gt; the items and purchase details agreed with the merchant. Shared with the merchant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Payment Mandate:&lt;/strong&gt; the approval to charge a specific payment method. Shared with the payment network and processors, not with everyone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each comes in two stages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Open:&lt;/strong&gt; your rules up front, like "any hotel under $250 a night, using my Visa." This lets the agent act on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Closed:&lt;/strong&gt; your approval for one specific, final purchase.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AP2 supports both &lt;strong&gt;human present&lt;/strong&gt; (you approve in the moment) and &lt;strong&gt;human not present&lt;/strong&gt; (the agent buys within your limits while you sleep).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's new:&lt;/strong&gt; AP2 v0.2 was released and &lt;strong&gt;donated to the FIDO Alliance&lt;/strong&gt;, the group behind passkeys. Standardization continues in FIDO's working groups.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Roadmap worth watching:&lt;/strong&gt; AP2 starts with cards. The roadmap adds e-wallets, &lt;strong&gt;push payments like UPI (India) and PIX (Brazil)&lt;/strong&gt;, and digital currencies. That matters for huge markets where cards aren't the main way people pay.&lt;/p&gt;

&lt;h3&gt;
  
  
  How UCP and AP2 fit together
&lt;/h3&gt;

&lt;p&gt;UCP runs the shopping flow. AP2 secures the payment inside it. UCP has AP2 support built in, along with MCP and A2A support, so these aren't rival standards. They're designed as a set.&lt;/p&gt;

&lt;h3&gt;
  
  
  Other names you'll hear
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ACP (Agentic Commerce Protocol):&lt;/strong&gt; OpenAI and Stripe's commerce standard. Interestingly, Stripe also co-develops UCP. Watch this space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;x402:&lt;/strong&gt; agent payments built on the old HTTP "402 Payment Required" status code, popular for crypto and pay-per-use APIs. The official AP2 samples include x402 flows.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Putting it all together: "Book me a hotel in Chicago"
&lt;/h2&gt;

&lt;p&gt;Let's see every layer in one real task. You tell your assistant:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Book me a hotel near the conference in Chicago, under $250 a night, for the three nights I'm there."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here's what happens under the hood:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;MCP:&lt;/strong&gt; the agent reads your calendar through an MCP server and finds your conference dates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A2A:&lt;/strong&gt; it asks your company's travel policy agent (built by another team) whether you need approval for this trip.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AP2 (open mandate):&lt;/strong&gt; you've already signed an open mandate: hotels only, under $250 a night, company card.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UCP:&lt;/strong&gt; the agent searches hotel catalogs, builds the booking, and runs checkout with the hotel, which stays the Merchant of Record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A2UI + AG-UI:&lt;/strong&gt; your screen shows three hotel cards live as the search runs, with a "Book this one" button.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AP2 (closed mandate):&lt;/strong&gt; you tap the button, and a signed, closed mandate locks in that exact booking and price.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UCP (order):&lt;/strong&gt; the confirmation and any later changes flow back through order webhooks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Seven steps, five protocols, zero custom integrations. That's the whole promise of this stack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Brand new this week: Poppy
&lt;/h2&gt;

&lt;p&gt;On &lt;strong&gt;November 13, 2026&lt;/strong&gt;, Sierra released &lt;strong&gt;Personal Agent Protocol 1.0&lt;/strong&gt;, nicknamed &lt;strong&gt;Poppy&lt;/strong&gt;. It defines how &lt;strong&gt;your personal AI agent&lt;/strong&gt; connects to a business, through its website, its APIs or the business's own agent. It came out of a draft shared in October and developed with Meta.&lt;/p&gt;

&lt;p&gt;It's two days old, so treat it as one to watch, not one to build on yet. But it points at where things are going: your agent talking to their agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's still missing (the honest part)
&lt;/h2&gt;

&lt;p&gt;The stack is real, but it isn't finished. Before you bet a product on it, know the gaps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No shared memory standard.&lt;/strong&gt; No foundation-backed protocol exists for agents to share one memory. Most teams expose memory through an MCP server and hope for the best.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No privacy signal.&lt;/strong&gt; A recent academic audit found that neither MCP nor A2A carries a privacy field. If a user opts out of ad data sharing, that choice can't travel with a delegated task.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Identity is still open.&lt;/strong&gt; "Which agent is this, and who does it work for?" doesn't have one standard answer yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commerce and payments are early.&lt;/strong&gt; Lodging and food specs in UCP are drafts, and AP2 is at v0.2. Build pilots, not your whole checkout.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's movement here too. The IETF chartered an &lt;strong&gt;Agent Communication Protocols&lt;/strong&gt; working group in October 2026, aiming for a shared base protocol that MCP and A2A could both carry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which ones do you actually need?
&lt;/h2&gt;

&lt;p&gt;Start small. Add layers only when you hit a real need.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start with MCP.&lt;/strong&gt; Almost every agent needs tools. This is the one to learn first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add AG-UI or A2UI&lt;/strong&gt; when a human watches the agent or needs to approve things.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add A2A&lt;/strong&gt; only when you work with agents you don't own. If all your agents live in one codebase, you probably don't need it yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add UCP and AP2&lt;/strong&gt; if your agent shops, books or pays. Start with a pilot, and follow the specs closely, because they're moving fast.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Rule of thumb: MCP by default, A2A at the boundary, UCP and AP2 at the checkout.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  For Google Cloud developers
&lt;/h2&gt;

&lt;p&gt;Several of these protocols started at Google: A2A, UCP (with Shopify) and AP2, plus A2UI. Google's &lt;strong&gt;Agent Development Kit (ADK)&lt;/strong&gt; works with MCP for tools and A2A for agent collaboration, and AP2's official guide pairs ADK, MCP, A2A and AP2 as one stack. If you already build on ADK, you're closer to this full stack than you think.&lt;/p&gt;

&lt;p&gt;The protocols themselves are open and vendor-neutral, so nothing here locks you into one cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  Caveats
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Everything here is as of November 15, 2026.&lt;/strong&gt; These specs change monthly. Check the official sites before you build.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Some items are drafts or previews:&lt;/strong&gt; A2A v1.1, UCP lodging and food, AP2 v0.2, and Poppy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adoption numbers vary by source.&lt;/strong&gt; I've left out partner counts and download stats that I couldn't confirm from official pages.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io/specification/2026-07-28/changelog" rel="noopener noreferrer"&gt;Model Context Protocol: 2026-07-28 changelog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://a2a-protocol.org/latest/" rel="noopener noreferrer"&gt;Agent2Agent (A2A) Protocol&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ucp.dev/" rel="noopener noreferrer"&gt;Universal Commerce Protocol (UCP)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ucp.dev/documentation/ucp-and-ap2/" rel="noopener noreferrer"&gt;UCP and AP2 integration guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ap2-protocol.org/" rel="noopener noreferrer"&gt;Agent Payments Protocol (AP2)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.google/products-and-platforms/platforms/google-pay/agent-payments-protocol-fido-alliance/" rel="noopener noreferrer"&gt;AP2 v0.2 and FIDO Alliance donation, Google blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ag-ui-protocol/ag-ui" rel="noopener noreferrer"&gt;AG-UI on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://a2ui.org/roadmap/" rel="noopener noreferrer"&gt;A2UI roadmap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/microsoft-copilot-studio/whats-new" rel="noopener noreferrer"&gt;Microsoft Copilot Studio: what's new&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>ai</category>
      <category>agents</category>
      <category>mcp</category>
      <category>googlecloud</category>
    </item>
    <item>
      <title>Hydrogen, Carbon or Argon? A Cost-First Guide to Gemini 4 for Every Team</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sun, 15 Nov 2026 19:42:18 +0000</pubDate>
      <link>https://dev.to/gde/hydrogen-carbon-or-argon-a-cost-first-guide-to-gemini-4-for-every-team-205b</link>
      <guid>https://dev.to/gde/hydrogen-carbon-or-argon-a-cost-first-guide-to-gemini-4-for-every-team-205b</guid>
      <description>&lt;p&gt;In the last few weeks, Google shipped three new Gemini 4 models: Argon (GA October 13, 2026), Carbon (GA November 10), and Hydrogen (GA November 12). Then came cyber versions of two of them, plus a world model called Genie 4. The names come from the periodic table, so they tell you nothing about which one is bigger, faster, or cheaper. Hydrogen is the lightest element, but it is not a "lite" model in the old sense.&lt;/p&gt;

&lt;p&gt;Cost sits at the center of this guide, because every role touches the bill. You'll find a section for each team: developers, SREs and platform engineers, security and compliance reviewers, engineering leaders and architects, and of course FinOps. Each one ends with your own cost lever: the one thing in your hands that moves the bill.&lt;/p&gt;

&lt;p&gt;All facts come from the Gemini Enterprise Agent Platform model pages on Google Cloud (last updated November 13, 2026), the Agent Platform pricing page, and Google's launch posts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Find your section
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;If you are...&lt;/th&gt;
&lt;th&gt;Your big question&lt;/th&gt;
&lt;th&gt;Your cost lever&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;FinOps or finance&lt;/td&gt;
&lt;td&gt;What will this cost us, and when does it change?&lt;/td&gt;
&lt;td&gt;Routing policy and request labels&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Developer&lt;/td&gt;
&lt;td&gt;What breaks when I switch models?&lt;/td&gt;
&lt;td&gt;Thinking level on every call&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SRE or platform engineer&lt;/td&gt;
&lt;td&gt;Where does it run, and how long can a call take?&lt;/td&gt;
&lt;td&gt;Timeouts and region choice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security or compliance&lt;/td&gt;
&lt;td&gt;What terms and access rules apply?&lt;/td&gt;
&lt;td&gt;Approval path for Carbon and cyber models&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Engineering leader or architect&lt;/td&gt;
&lt;td&gt;Which model should be our standard?&lt;/td&gt;
&lt;td&gt;Default model and escalation rules&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The 30-second cheat sheet
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gemini 4 Hydrogen (&lt;code&gt;gemini-4-hydrogen&lt;/code&gt;):&lt;/strong&gt; the fast, cheaper workhorse for everyday coding and agent work. Google calls it the upgrade path from Gemini 3.8 Flash. Think of it as your default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gemini 4 Carbon (&lt;code&gt;gemini-4-carbon&lt;/code&gt;):&lt;/strong&gt; Google's strongest model. It thinks the longest and spends the most thinking tokens. Use it for planning, deep debugging and hard root-cause work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gemini 4 Argon (&lt;code&gt;gemini-4-argon&lt;/code&gt;):&lt;/strong&gt; the first frontier Gemini 4 model. Same per-token price as Carbon, but it uses fewer thinking tokens. It fits a narrow middle ground: jobs where Hydrogen falls short and Carbon is too slow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cyber variants (allowlist only):&lt;/strong&gt; special builds of Argon and Carbon for defensive security work. Most teams will never touch these.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Genie 4:&lt;/strong&gt; not a text or code model at all. It's a world model in research preview. Skip it for app building.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What are the cyber variants?
&lt;/h2&gt;

&lt;p&gt;The cyber models are versions of Argon and Carbon tuned for defensive security work: finding vulnerabilities, reverse engineering, verifying exploits and writing patches. You can't just turn them on. Access is allowlist only, through your Google team or the Fairwind Program.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Gemini 4 Argon Cyber Permissive&lt;/th&gt;
&lt;th&gt;Gemini 4 Carbon for cyber&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Model ID&lt;/td&gt;
&lt;td&gt;&lt;code&gt;gemini-4-argon-cyber-permissive&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;gemini-4-carbon-cyber-permissive&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Based on&lt;/td&gt;
&lt;td&gt;Gemini 4 Argon&lt;/td&gt;
&lt;td&gt;Gemini 4 Carbon&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Default thinking level&lt;/td&gt;
&lt;td&gt;HIGH (normal Argon is MEDIUM)&lt;/td&gt;
&lt;td&gt;HIGH (normal Carbon is MEDIUM)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Computer use&lt;/td&gt;
&lt;td&gt;Not supported&lt;/td&gt;
&lt;td&gt;Not supported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Regions&lt;/td&gt;
&lt;td&gt;global, us, eu&lt;/td&gt;
&lt;td&gt;global, us&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Price, global, per 1M tokens in/out&lt;/td&gt;
&lt;td&gt;$4 / $20 (no intro promo)&lt;/td&gt;
&lt;td&gt;$4 / $20 (no intro promo)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Terms&lt;/td&gt;
&lt;td&gt;Section 31 of Service Specific Terms&lt;/td&gt;
&lt;td&gt;Section 31 of Service Specific Terms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things to watch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The naming is not consistent.&lt;/strong&gt; The Carbon version is called "Carbon for cyber" in the docs, but its model ID still ends in "cyber-permissive". Use the model ID, not the display name, in your code and docs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access does not carry over.&lt;/strong&gt; If you already have Argon Cyber Permissive or Gemini 3.8 Flash Cyber, you still need to apply again for Carbon for cyber.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Higher default thinking means higher token spend.&lt;/strong&gt; Both cyber models default to HIGH, so expect more output tokens per call than the base models.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Side by side
&lt;/h2&gt;

&lt;p&gt;On Google Cloud the three base models look almost the same on paper. The real differences are thinking behavior, price, regions, file types and who can get access.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Hydrogen&lt;/th&gt;
&lt;th&gt;Argon&lt;/th&gt;
&lt;th&gt;Carbon&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Model ID&lt;/td&gt;
&lt;td&gt;&lt;code&gt;gemini-4-hydrogen&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;gemini-4-argon&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;gemini-4-carbon&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GA date&lt;/td&gt;
&lt;td&gt;Nov 12, 2026&lt;/td&gt;
&lt;td&gt;Oct 13, 2026&lt;/td&gt;
&lt;td&gt;Nov 10, 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Everyday coding, agents, execution&lt;/td&gt;
&lt;td&gt;Long tasks, fewer thinking tokens than Carbon&lt;/td&gt;
&lt;td&gt;Deepest reasoning, planning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Thinking levels&lt;/td&gt;
&lt;td&gt;LOW, MEDIUM, HIGH (default), XHIGH&lt;/td&gt;
&lt;td&gt;LOW, MEDIUM (default), HIGH&lt;/td&gt;
&lt;td&gt;LOW, MEDIUM (default), HIGH&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output per segment&lt;/td&gt;
&lt;td&gt;65,536 (streaming or not)&lt;/td&gt;
&lt;td&gt;65,536 streaming, 32,768 non-streaming&lt;/td&gt;
&lt;td&gt;65,536 streaming, 32,768 non-streaming&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Office and OpenDocument files&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (PDF and text only)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Regions&lt;/td&gt;
&lt;td&gt;global, us, eu&lt;/td&gt;
&lt;td&gt;global, us, eu, europe-west2, asia-southeast1&lt;/td&gt;
&lt;td&gt;global, us, eu&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access&lt;/td&gt;
&lt;td&gt;Public&lt;/td&gt;
&lt;td&gt;Public&lt;/td&gt;
&lt;td&gt;Verified enterprise customers, select regions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Knowledge cutoff&lt;/td&gt;
&lt;td&gt;March 2026&lt;/td&gt;
&lt;td&gt;Not listed&lt;/td&gt;
&lt;td&gt;March 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Cloud price, global, per 1M tokens in/out&lt;/td&gt;
&lt;td&gt;$1.50 / $7.50&lt;/td&gt;
&lt;td&gt;$2 / $10, then $4 / $20 from Dec 1&lt;/td&gt;
&lt;td&gt;$2 / $10, then $4 / $20 from Dec 1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Prices are Standard PayGo on the global endpoint. Regional (non-global) endpoints cost 10% more on every model.&lt;/p&gt;

&lt;p&gt;What all three share: a 1,048,576-token limit that covers input and output together, long decodes up to that limit, implicit caching only (4,096-token minimum), fixed sampling settings, no Live API, no tuning and no RAG Engine. All three support grounding, function calling, code execution, URL context, computer use, batch, Provisioned Throughput, Standard PayGo and Priority PayGo.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's new this month
&lt;/h2&gt;

&lt;p&gt;The biggest update: Google says Hydrogen at its default HIGH setting slightly outscores Argon on the Artificial Analysis Intelligence Index (51 vs 50, and 54 at XHIGH), at a lower price. If that holds on your workloads, Argon's role gets even smaller.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;What happened&lt;/th&gt;
&lt;th&gt;Why it matters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Nov 13, 2026&lt;/td&gt;
&lt;td&gt;Google Cloud starts billing long completions (past 32K tokens) even when they fail on a timeout&lt;/td&gt;
&lt;td&gt;Timeouts now cost money, not just time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nov 12, 2026&lt;/td&gt;
&lt;td&gt;Hydrogen GA, replacing Gemini 3.8 Flash; now powers the Gemini app and AI Mode in Search&lt;/td&gt;
&lt;td&gt;Google says it's 2.5x faster than 3.8 Flash at its default HIGH level&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nov 12, 2026&lt;/td&gt;
&lt;td&gt;Orchestrator in Google Antigravity: Carbon plans, Hydrogen executes, in one session&lt;/td&gt;
&lt;td&gt;Google reports near-Carbon success with 24% less quota and 19% faster runs on Terminal-Bench 4.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nov 10, 2026&lt;/td&gt;
&lt;td&gt;Carbon GA, plus a /swarm preview in Antigravity that turns one prompt into a team of agents&lt;/td&gt;
&lt;td&gt;Parallel agents multiply token use, so watch spend&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oct 13, 2026&lt;/td&gt;
&lt;td&gt;Argon GA&lt;/td&gt;
&lt;td&gt;First Gemini 4 frontier model&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Dates coming up:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;What changes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Nov 30, 2026&lt;/td&gt;
&lt;td&gt;Intro credits for Argon and Carbon end&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dec 1, 2026&lt;/td&gt;
&lt;td&gt;Argon and Carbon go to $4 / $20 per 1M tokens (global)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jan 1, 2027&lt;/td&gt;
&lt;td&gt;Gemini 3.8 Flash doubles to $1.50 / $7.50 on the Gemini API, the same as Hydrogen&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jan 12, 2027&lt;/td&gt;
&lt;td&gt;Hydrogen gets cache control with TTL; cache writes at $1.875 per 1M tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oct 13, 2027 or later&lt;/td&gt;
&lt;td&gt;Argon's listed retirement on Google Cloud&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  If you own the bill (FinOps)
&lt;/h2&gt;

&lt;p&gt;The headline: from December 1, 2026, Argon and Carbon cost about 2.67 times more per token than Hydrogen. Model choice is now one of the biggest levers on your AI bill.&lt;/p&gt;

&lt;p&gt;Here is a simple example. One request with 20,000 input tokens and 3,000 output tokens, at Google Cloud Standard PayGo prices, per 10,000 requests:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Global endpoint&lt;/th&gt;
&lt;th&gt;Non-global endpoint&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hydrogen&lt;/td&gt;
&lt;td&gt;about $525&lt;/td&gt;
&lt;td&gt;about $578&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Argon or Carbon, until Nov 30&lt;/td&gt;
&lt;td&gt;about $700&lt;/td&gt;
&lt;td&gt;about $770&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Argon or Carbon, from Dec 1&lt;/td&gt;
&lt;td&gt;about $1,400&lt;/td&gt;
&lt;td&gt;about $1,540&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This keeps token counts equal, which real traffic won't. Carbon spends more thinking tokens than Argon, so the real gap is often bigger.&lt;/p&gt;

&lt;p&gt;Three details hide in the footnotes of the Google Cloud pricing page:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The intro price is a credit, not a lower rate.&lt;/strong&gt; Argon and Carbon get 50% credits back on net spend through November 30, 2026. Your invoice may show full price with a credit line, so warn your finance team.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cyber models get no promo.&lt;/strong&gt; Argon Cyber Permissive and Carbon Cyber Permissive cost $4 / $20 per 1M tokens from day one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Failed long calls still bill.&lt;/strong&gt; Since November 13, 2026, any completion past 32K tokens is charged for the tokens that can be retrieved, even when it fails from a client or server timeout.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Where the money hides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Thinking tokens are billed as output.&lt;/strong&gt; Output costs 5 times input. A model that thinks more costs more, even on the same prompt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hydrogen's HIGH default.&lt;/strong&gt; Teams moving from 3.8 Flash (which defaulted to MEDIUM) may see a jump. Start at MEDIUM and compare on your own test set.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching changes.&lt;/strong&gt; All three use implicit caching only. Put stable content (system instructions, reference docs) at the start of the prompt so cache hits happen. From January 12, 2027, Hydrogen gets cache control with TTL, with cache writes at $1.875 per 1M tokens on global (1.25 times input). Cache reads are cheap on every model: 5% of the input price, or $0.075 per 1M tokens on Hydrogen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use batch for non-urgent work.&lt;/strong&gt; It has its own lower rates on the Batch tab of the pricing page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Re-test before December 1.&lt;/strong&gt; If you picked Argon in October, check whether Hydrogen now does the job.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tag your requests.&lt;/strong&gt; Use request labels by model and use case so you can see which team or feature drives Carbon spend.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Your cost lever:&lt;/strong&gt; the routing policy and the labels. Default to Hydrogen, track Carbon spend by team, and re-test anything on Argon or Carbon before December 1.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you build apps (developers)
&lt;/h2&gt;

&lt;p&gt;Switching to Gemini 4 is more than changing the model string. A few old habits now break or silently stop working.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No more temperature tuning.&lt;/strong&gt; &lt;code&gt;temperature&lt;/code&gt;, &lt;code&gt;top_p&lt;/code&gt; and &lt;code&gt;top_k&lt;/code&gt; are ignored. They are fixed at 1.0, 0.95 and 64. If your prompts relied on low temperature for steady output, test again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;thinking_budget&lt;/code&gt; and MINIMAL are gone.&lt;/strong&gt; Sending &lt;code&gt;thinking_budget&lt;/code&gt;, or &lt;code&gt;thinking_level&lt;/code&gt; set to MINIMAL, returns an HTTP 400 error. Use thinking levels instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hydrogen thinks harder by default.&lt;/strong&gt; Its default is HIGH, while Argon and Carbon default to MEDIUM. Set the level on purpose. Don't just accept the default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;XHIGH is Hydrogen only.&lt;/strong&gt; Save it for hard multi-step problems. On simple jobs like extraction it can overthink.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long answers need long decodes.&lt;/strong&gt; One segment stops at 65,536 output tokens (32,768 for Argon and Carbon when not streaming). The Gen AI SDK and Agent Studio continue automatically. A custom loop needs &lt;code&gt;continuation_token&lt;/code&gt;, which only works on the v1beta1 API for now.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Office files work on Hydrogen and Carbon.&lt;/strong&gt; You can send .docx, .pptx, .xlsx and OpenDocument files directly, no conversion. Hydrogen even accepts them inside function responses. Argon still takes only PDF and plain text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Planner plus executor works well.&lt;/strong&gt; Google shows Carbon doing the planning turns and Hydrogen doing the execution turns in one session, linked with &lt;code&gt;previous_interaction_id&lt;/code&gt;. This is a natural fit for multi-agent apps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Your cost lever:&lt;/strong&gt; set the thinking level on every call, and log thinking tokens per feature. Don't let Hydrogen's HIGH default decide your bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you keep it running (SRE and platform)
&lt;/h2&gt;

&lt;p&gt;For reliability, the big questions are where the model runs, how you pay for capacity and how long a call can take.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Regions decide a lot.&lt;/strong&gt; Argon is the only one with single regions (europe-west2 and asia-southeast1). Hydrogen and Carbon run only on global, us and eu. If your data must stay in London or Singapore, Argon is your only Gemini 4 option today.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Carbon is gated.&lt;/strong&gt; Google limits it to verified enterprise customers in select regions, to protect capacity. Don't build a production path on Carbon until your project is approved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No fixed quota.&lt;/strong&gt; All three run on Standard PayGo with usage tiers, Priority PayGo, Provisioned Throughput or batch. Plan capacity with Provisioned Throughput for steady, critical traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expect long calls.&lt;/strong&gt; HIGH and XHIGH thinking plus long decodes can run for minutes. Raise client and gateway timeouts, and stream where you can. Timeouts now cost money too: since November 13, 2026, a completion that runs past 32K tokens is billed for what can be retrieved, even if the call fails on a timeout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Big inputs are allowed.&lt;/strong&gt; Up to 500 MiB compressed on GenerateContent, 3,000 images or documents per prompt, about 45 minutes of video with audio, and around 8.4 hours of audio. Watch your request size limits upstream.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan for retirement.&lt;/strong&gt; Argon's listed retirement is October 13, 2027 or later. Put the model ID in config, not in code, so you can swap it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Your cost lever:&lt;/strong&gt; timeouts and region choice. A timed-out call past 32K tokens still bills, and non-global endpoints cost 10% more. Use global unless data residency says otherwise, and keep Provisioned Throughput for steady traffic you can predict.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you approve it (security and compliance)
&lt;/h2&gt;

&lt;p&gt;For security teams, Carbon and the cyber models come with extra terms. Read them before you sign off.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Carbon is a "Google Frontier Model".&lt;/strong&gt; It falls under Section 34 of the Service Specific Terms, which includes abuse monitoring. Your legal team should review what that means for your prompts and data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cyber models are "Frontier Cyber Models".&lt;/strong&gt; They fall under Section 31 and need allowlist approval. Plan for an approval step in your project timeline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data residency depends on region.&lt;/strong&gt; All three list security controls for data residency, CMEK, VPC-SC and Access Transparency on the model page. Confirm which ones apply to your region and use case before go-live.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free tier prompts may be used by Google.&lt;/strong&gt; On the Gemini API (not Google Cloud), free-tier Hydrogen prompts may be used to improve Google's products. Paid tier is not. For company data, use Google Cloud or a paid tier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Computer use is off for cyber models.&lt;/strong&gt; The base Argon, Carbon and Hydrogen support it, but the cyber versions do not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Your cost lever:&lt;/strong&gt; the approval path. Approve the cheapest model that meets policy. Make Carbon and the cyber models (both $4 / $20 per 1M tokens with no promo for cyber) a named exception, not a default.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you lead the team (engineering leaders and architects)
&lt;/h2&gt;

&lt;p&gt;Your job is to set one simple standard so every team doesn't pick its own model.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pick a default and an escalation rule.&lt;/strong&gt; Hydrogen as the default. Carbon only for named use cases, like planning and deep debugging. Argon only when an eval proves it beats Hydrogen for that job.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Design for mixing models.&lt;/strong&gt; The Carbon-plans, Hydrogen-executes pattern is now built into Google Antigravity's Orchestrator. Google reports near-Carbon results at 24% less quota. Build your own agents the same way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch out for swarms.&lt;/strong&gt; Antigravity's /swarm preview runs many agents in parallel. Great for big tasks, but each agent burns tokens. Set budgets before teams try it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan access early.&lt;/strong&gt; Carbon needs enterprise verification, and cyber models need allowlist approval. Start those requests now if you need them next quarter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep model IDs in config.&lt;/strong&gt; Three Gemini 4 models and two cyber versions shipped in about a month. Expect more changes, and make swapping a config change, not a code change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Your cost lever:&lt;/strong&gt; the default model. Whatever you set as the standard is what most of your traffic will use.&lt;/p&gt;

&lt;h2&gt;
  
  
  So which one should you pick?
&lt;/h2&gt;

&lt;p&gt;Start cheap and move up only when your tests say so. Walk through these in order and stop at the first match.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Is it defensive security work (vulnerability research, patching) and are you allowlisted?&lt;/strong&gt; Use Carbon for cyber or Argon Cyber Permissive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Must the data stay in a single region like europe-west2 or asia-southeast1?&lt;/strong&gt; Use Argon. It's the only Gemini 4 model there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is it everyday work: coding, chat, extraction, summaries, agent steps?&lt;/strong&gt; Use Hydrogen. Set the thinking level yourself, starting at MEDIUM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is it a hard, high-stakes thinking job: planning a big change, deep debugging, complex analysis?&lt;/strong&gt; Use Carbon, if your project has access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Does Hydrogen fall short but Carbon is too slow?&lt;/strong&gt; Try Argon, and prove it on your own eval set.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is it a multi-step agent?&lt;/strong&gt; Mix them. Carbon plans, Hydrogen does the work.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When in doubt, the rule of thumb is simple: Hydrogen by default, Carbon by exception, Argon by evidence.&lt;/p&gt;

&lt;h2&gt;
  
  
  Caveats
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prices here are Google Cloud Standard PayGo list prices.&lt;/strong&gt; Priority PayGo, Batch, Provisioned Throughput and any discounts your company has will change the math. Check the pricing page for your real rates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The cost example is a simple model.&lt;/strong&gt; It holds token counts equal across models. Measure real thinking tokens on your own traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benchmarks are vendor reported.&lt;/strong&gt; Run your own evals before you commit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;This is moving fast.&lt;/strong&gt; Argon, Carbon and Hydrogen all shipped within a month. Prices, regions and access rules can change. Everything here is as of November 14, 2026.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-hydrogen" rel="noopener noreferrer"&gt;Gemini 4 Hydrogen model page, Google Cloud&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-carbon" rel="noopener noreferrer"&gt;Gemini 4 Carbon model page, Google Cloud&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-argon" rel="noopener noreferrer"&gt;Gemini 4 Argon model page, Google Cloud&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/gemini-enterprise-agent-platform/generative-ai/pricing" rel="noopener noreferrer"&gt;Gemini Enterprise Agent Platform pricing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.google/innovation-and-ai/models-and-research/gemini-models/introducing-gemini-4-hydrogen/" rel="noopener noreferrer"&gt;Introducing Gemini 4 Hydrogen, Google blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://importstatic.com/ai/gemini-4-hydrogen-carbon-argon" rel="noopener noreferrer"&gt;Gemini 4 Hydrogen vs Carbon vs Argon, ImportStatic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://antigravity.google/blog/gemini-4-hydrogen-in-google-antigravity/" rel="noopener noreferrer"&gt;Gemini 4 Hydrogen and Orchestrator, Google Antigravity blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>googlecloud</category>
      <category>discuss</category>
      <category>ai</category>
      <category>finops</category>
    </item>
    <item>
      <title>Securing AI Agents on Google Cloud: An SRE and Platform Engineer’s View</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sat, 14 Nov 2026 15:16:47 +0000</pubDate>
      <link>https://dev.to/gde/securing-ai-agents-on-google-cloud-an-sre-and-platform-engineers-view-69d</link>
      <guid>https://dev.to/gde/securing-ai-agents-on-google-cloud-an-sre-and-platform-engineers-view-69d</guid>
      <description>&lt;p&gt;Google Cloud recently published a 28-page ebook called &lt;strong&gt;Secure AI innovation: Securing the agentic enterprise on Google Cloud&lt;/strong&gt;. Six chapters, a lot of product names, and one big message: AI agents are now part of your production estate, so secure them like it.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The core idea is right. Treat AI agents as a new kind of workload with their own identity, their own guardrails, and their own monitoring.&lt;/li&gt;
&lt;li&gt;The 4-stage model (Architect, Inventory, Intercept, Defend) is a useful mental map. I would add a fifth stage: &lt;strong&gt;Operate and Retire&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Many numbers come from Google, Google Cloud Next talks, and Wiz (which is now part of Google). Good signals, but read them as directional.&lt;/li&gt;
&lt;li&gt;The hardest part isn't buying the tools. It's making the secure path the &lt;strong&gt;fastest&lt;/strong&gt; path for developers. That is a platform engineering problem, not a security product problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The ebook at a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Chapter&lt;/th&gt;
&lt;th&gt;Big idea&lt;/th&gt;
&lt;th&gt;My one-line take&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Securing the baseline&lt;/td&gt;
&lt;td&gt;Every agent gets its own identity&lt;/td&gt;
&lt;td&gt;Yes, and keep the audit trail alive after the identity dies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Governing the AI supply chain&lt;/td&gt;
&lt;td&gt;Shadow AI and risky third-party skills&lt;/td&gt;
&lt;td&gt;Shadow AI is a symptom of a slow paved road&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Enforcing the guardrails&lt;/td&gt;
&lt;td&gt;Access checks plus intent checks at runtime&lt;/td&gt;
&lt;td&gt;Measure the latency yourself and decide fail-open vs fail-closed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Fighting AI threats with AI&lt;/td&gt;
&lt;td&gt;Find, prove, and fix vulnerabilities automatically&lt;/td&gt;
&lt;td&gt;Fix generation is cheap. Review capacity is the real bottleneck&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Digital sovereignty&lt;/td&gt;
&lt;td&gt;Key control and three sovereign cloud options&lt;/td&gt;
&lt;td&gt;Each option changes your operating model, not just your compliance story&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6. Velocity vs governance&lt;/td&gt;
&lt;td&gt;A 4-stage agent security lifecycle&lt;/td&gt;
&lt;td&gt;Good map, missing the "operate" and "evaluate" parts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now let's go chapter by chapter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 1: Securing the baseline
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What the ebook says, in short:&lt;/strong&gt; Shared service accounts and long-lived keys were never built for autonomous agents. Each agent should get a dedicated identity that lives only as long as its task, get extra privilege only when needed (Privileged Access Manager), and be fenced in by a Principal Access Boundary. Under that sits the Enterprise Foundations Blueprint: infrastructure as code, Cloud Build pipelines, SLSA Level 3 provenance, Binary Authorization, Shared VPC, and VPC Service Controls.&lt;/p&gt;

&lt;p&gt;One stat that stuck with me: non-human identities already outnumber humans by a huge margin in cloud environments (the ebook says 82x). Agents will push that number higher, fast.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ SRE view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A unique identity per agent is not only a security win. It's an observability win. During an incident, the first question is always "who did this?" With shared service accounts, the honest answer is often "something, somewhere." With per-agent identity, you can actually answer it.&lt;/p&gt;

&lt;p&gt;But there is a catch with identities tied to the task lifecycle. If the identity disappears when the task ends, make sure the evidence does not. Export audit logs to a log sink with retention that matches your compliance needs. Your postmortem might happen three weeks after the agent is gone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🏗️ Platform engineering view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Nobody should hand-craft agent identities. Bake it into the golden path. When a team scaffolds a new agent from your template, it should come with its own identity, a narrow role set, a boundary policy, and labels for owner, environment, and cost center. Those labels pay off twice: once for security, once for FinOps when someone asks why the AI bill doubled.&lt;/p&gt;

&lt;p&gt;On VPC Service Controls: it is powerful, and it is also famous for breaking things on day one. Roll it out in dry-run mode first, watch what would have been blocked, then enforce.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💻 Builder view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The hardest question is not "how do I give an agent an identity?" It's "what permissions does this agent actually need?" Agents are not deterministic. The tools they call can change from one prompt to the next. My approach: start narrow in dev, watch the denied calls, widen permissions on purpose, and treat every permission change like a code change that goes through a PR.&lt;/p&gt;

&lt;p&gt;I also liked the warranty claim example, where a customer-facing agent talks to backend data agents using real identities instead of shared keys. It's boring and practical, which is exactly what this space needs more of.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 2: Governing the AI supply chain
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What the ebook says, in short:&lt;/strong&gt; Under deadline pressure, developers plug in third-party agent skills without review. The ebook claims more than 15% of skills in public marketplaces are malicious, and 68% of organizations run self-hosted models buried inside third-party software without knowing it. The answer is a central hub: Agent Registry, Wiz AI-BOM for discovery, ADK session isolation, Agent Gateway, managed MCP servers, an auth manager that keeps tokens away from the agent, and a security dashboard. Best Buy shares how they isolate high-risk agents on Cloud Run with their own containers and add a human approval step before risky API calls.&lt;/p&gt;

&lt;p&gt;A quick naming note for readers: the ebook says "Gemini acts as the control plane." Many people will picture the chat app. From what I have seen, read it as the Gemini Enterprise agent platform side of Google Cloud, where things like the registry live.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ SRE view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every third-party skill or MCP server is a dependency that can change behavior without you ever deploying anything. That's a reliability risk as much as a security risk. Pin versions. Route skill upgrades through the same change process as any other production change. An unpinned skill is config drift you can't see.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🏗️ Platform engineering view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Shadow AI is a symptom, not the disease. Developers go around IT when the official path is slower than their deadline. We saw this with containers, with npm packages, with Terraform modules. AI skills are just the next round.&lt;/p&gt;

&lt;p&gt;The fix is an internal catalog that is &lt;strong&gt;easier&lt;/strong&gt; to use than the public marketplace: pre-approved skills, one-command onboarding, and a fast review SLA for new requests. If approval takes three weeks, people will find another way. Every time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💻 Builder view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most underrated line in the whole ebook is from Best Buy: keep deploy-time permissions separate from runtime permissions. The pipeline that deploys your agent should never share an identity with the running agent. We learned this lesson years ago with CI service accounts. Let's not learn it again.&lt;/p&gt;

&lt;p&gt;On human-in-the-loop approvals: I'm a fan, with one warning. If a person approves 200 requests a day, they stop reading them. Gate on risk, not on everything. Track how long approvals take and how often people reject. A rejection rate of zero usually means the gate is theater, or it's in the wrong place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 3: Enforcing the guardrails
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What the ebook says, in short:&lt;/strong&gt; Runtime protection has two layers. First, access control at the Agent Gateway, so agents only reach systems they are approved for. Second, intent control, where filters look at what a prompt is really trying to do. Model Armor screens prompts for injection and jailbreak attempts and redacts sensitive data. Agents also validate inputs with strict rules, like checking that a serial number is only letters and numbers before it ever touches BigQuery.&lt;/p&gt;

&lt;p&gt;One quote from Abhishek A. Hemrajani of Google Cloud Security sums it up well: "Agents are the new insider threats." I agree. An agent doesn't need bad intent to drop a table. It just needs to be confused.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ SRE view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every inline check is another hop in the request path. The ebook says Model Armor adds no latency. Maybe it's small, but I would never take that on faith. Measure p95 and p99 in your own setup and include it in your latency SLO.&lt;/p&gt;

&lt;p&gt;More important: decide your failure mode &lt;strong&gt;before&lt;/strong&gt; the incident. If the gateway or the screening service is slow or down, do agents fail open or fail closed? That's a business decision, not a technical one. Write it down and get someone to sign off on it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🏗️ Platform engineering view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Put guardrails in shared infrastructure, not in each agent's code. Ten teams writing ten prompt filters means ten different bugs. Central policy at the gateway, with team-level config for what's allowed.&lt;/p&gt;

&lt;p&gt;And from a FinOps angle: screening every prompt and response is not free. Budget for it per agent, and watch it, especially for chatty agents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💻 Builder view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The serial number example is my favorite part of this chapter because it's old-school engineering. Input validation. Parameterized queries. LLM guardrails don't replace basic hygiene. Never let a model build a raw SQL string from user text. A smart filter in front is great, but a strict schema behind it is what saves you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 4: Fighting AI threats with AI defense
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What the ebook says, in short:&lt;/strong&gt; Attackers move at machine speed. The ebook cites an estimated mean time to exploit of negative seven days, meaning exploits often show up before the patch does. The answer is a find-and-fix loop: Wiz maps risks across your stack, CodeMender proves a vulnerability is real by trying to exploit it in a sandbox, and then generates a tested fix that shows up as a pull request for a human to approve. Wiz Red Agent tests from the outside, Wiz Blue Agent adds runtime context during incidents, and behavior analytics watch for agents acting out of pattern. The ebook also shares a story of one agent making 42,000 cloud API calls and 300 sensitive IAM changes in a single hour.&lt;/p&gt;

&lt;p&gt;An honest note while reading: Wiz is now part of Google, so when the ebook calls Wiz the recommended standard for multi-cloud, that is Google recommending Google. It doesn't make it wrong. Just read it with that in mind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ SRE view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;42,000 calls in an hour is about 12 calls per second, nonstop. Detecting that at machine speed is good. But my first question is: &lt;strong&gt;why did nothing stop it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Classic SRE tools apply directly to agents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Quotas and rate limits per agent identity&lt;/li&gt;
&lt;li&gt;Circuit breakers when error rates or call volumes spike&lt;/li&gt;
&lt;li&gt;A real kill switch that someone on call can use in seconds&lt;/li&gt;
&lt;li&gt;An alert on &lt;strong&gt;any&lt;/strong&gt; IAM change made by an agent. That should be a rare event, not a dashboard metric.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prevention through limits is cheaper than detection after the fact.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🏗️ Platform engineering view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Automatic patch PRs sound amazing until 40 of them land on a Monday. Fix generation is cheap. Human review is the bottleneck. Route them with CODEOWNERS, batch related fixes, and track merge rate, revert rate, and time to merge. If the revert rate starts climbing, slow the machine down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💻 Builder view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Exploit verification in a sandbox is the feature I'm most excited about in this whole ebook. False positives destroy trust in security scanners. Teams learn to ignore them. Proving a vulnerability is actually exploitable changes the conversation from "your scanner is noisy" to "here's the proof, here's the fix."&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 5: Achieving digital sovereignty
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What the ebook says, in short:&lt;/strong&gt; Regulated industries need control over where data lives and who can touch it. Customers own their keys through Cloud KMS, Key Access Justifications add an approval step before Google can decrypt, and Secret Manager keeps credentials out of agent code. There are three sovereign options: a data boundary in the public cloud through Assured Workloads, dedicated regional clouds run by local operators, and fully air-gapped Google Distributed Cloud. Google also points to its Leader position in the Forrester Wave for sovereign cloud platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ SRE view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each sovereign option changes your operating model, not just your compliance checklist. Air-gapped means no pulling the latest model on a whim, no SaaS observability tools, and patching on your schedule with your own people. Plan for update lag and for on-call depth.&lt;/p&gt;

&lt;p&gt;Also: owning your keys means you can lose your keys. Locking yourself out of your own data is an outage you caused. Test key rotation and break-glass access the same way you test disaster recovery.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🏗️ Platform engineering view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The biggest promise here is a consistent experience across all three options. That's the part I'd verify hardest. Do the same Terraform modules work? The same pipelines? The same agent templates? Wherever they differ, document it clearly in your platform docs so teams don't find out in production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💻 Builder view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I still see API keys sitting in agent code, and sometimes inside system prompts. Remember that agents read their own context, and that context often ends up in logs. A secret in a prompt is a secret in your logs. Pull secrets at runtime, never hardcode them, never put them in prompts.&lt;/p&gt;

&lt;p&gt;One caveat: strong statements like "Google cannot decrypt without approval" depend on how your keys are set up. Check exactly which configuration gives you that guarantee before you repeat it to your auditors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 6: Bridging AI velocity and governance
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What the ebook says, in short:&lt;/strong&gt; It wraps everything into a 4-stage lifecycle. &lt;strong&gt;Architect&lt;/strong&gt; (identity and perimeters), &lt;strong&gt;Inventory&lt;/strong&gt; (discovery, registry, provenance, human approvals), &lt;strong&gt;Intercept&lt;/strong&gt; (gateway control and prompt screening), and &lt;strong&gt;Defend&lt;/strong&gt; (threat detection, behavior monitoring, and automatic fixes). Sovereignty and key control run alongside all four.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My take:&lt;/strong&gt; This is a good map, and I'll probably use it in conversations with leadership. But from an SRE and platform view, two stages are missing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Operate and Retire.&lt;/strong&gt; Who is on call for an agent? Where is the runbook for "agent is doing something weird"? How do you shut down one agent without taking down the others? And when an agent is no longer needed, who revokes its identity, removes its skills, and deletes its connections? Agents rarely die cleanly. A forgotten agent that still has permissions is tomorrow's breach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Evaluate.&lt;/strong&gt; Test agent behavior before production, not just the code. Run red-team prompts in CI. Run regression evals whenever the model version changes. A model upgrade is a deployment. Treat it like one.&lt;/p&gt;

&lt;p&gt;And one more thing none of the four stages mention: &lt;strong&gt;cost&lt;/strong&gt;. Every layer here (screening, telemetry, behavior analytics, sandboxed scans) adds spend. Security that nobody can afford gets turned off quietly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where I'd push back overall
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The numbers.&lt;/strong&gt; Many stats come from vendor reports and conference talks. They are useful signals, but go to the primary sources before you put them in a board deck.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The product density.&lt;/strong&gt; Smaller teams can feel lost here. You don't need every product on day one. Unique identities, no static keys, input validation, rate limits, and good logs will get you far.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New and preview features.&lt;/strong&gt; Some of these capabilities are very new. Check what's generally available before you build a production roadmap on it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Absolute language.&lt;/strong&gt; Words like "total governance" and "never" make me nervous. Security is never total. It's layers, tradeoffs, and good habits.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My Monday morning checklist
&lt;/h2&gt;

&lt;p&gt;If I were starting from this ebook tomorrow, here's my order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;List every agent running today, including the "just an experiment" ones.&lt;/li&gt;
&lt;li&gt;Find any agent using a shared service account or a static key. Fix those first.&lt;/li&gt;
&lt;li&gt;Add per-agent quotas and a kill switch someone on call can actually use.&lt;/li&gt;
&lt;li&gt;Put a central gateway and prompt screening in front of agents, and measure the latency it adds.&lt;/li&gt;
&lt;li&gt;Pin third-party skills and MCP servers, and route upgrades through change management.&lt;/li&gt;
&lt;li&gt;Decide fail-open vs fail-closed for each guardrail, and write it down.&lt;/li&gt;
&lt;li&gt;Label every agent resource with owner, environment, and cost center.&lt;/li&gt;
&lt;li&gt;Write one runbook for "an agent is misbehaving" and run a drill.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Final thought
&lt;/h2&gt;

&lt;p&gt;The ebook says security is the enabler, not the blocker. I agree, with one condition: it's only true if the platform team makes the secure path the easy path. Tools give you the controls. Golden paths, templates, and fast reviews are what get developers to actually use them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Over to you:&lt;/strong&gt; what is the hardest part of securing agents in your org right now? Identity, shadow AI, guardrails, or just knowing which agents exist? Drop it in the comments. I read every one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ebook landing page: &lt;a href="https://cloud.google.com/security/resources/secure-ai-innovation" rel="noopener noreferrer"&gt;https://cloud.google.com/security/resources/secure-ai-innovation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ebook PDF: &lt;a href="https://services.google.com/fh/files/misc/secure_ai_innovation_securing_the_agentic_enterprise_on_google_cloud.pdf" rel="noopener noreferrer"&gt;https://services.google.com/fh/files/misc/secure_ai_innovation_securing_the_agentic_enterprise_on_google_cloud.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;All opinions are my own, based on my experience in SRE, platform engineering, and building with AI agents.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>security</category>
      <category>googlecloud</category>
      <category>ai</category>
    </item>
    <item>
      <title>A Stolen Agent Token Is Useless Here: Inside Google Cloud Agent Identity, Bound Tokens, and the Redeploy Trap</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:33:30 +0000</pubDate>
      <link>https://dev.to/karthidec/a-stolen-agent-token-is-useless-here-inside-google-cloud-agent-identity-bound-tokens-and-the-on3</link>
      <guid>https://dev.to/karthidec/a-stolen-agent-token-is-useless-here-inside-google-cloud-agent-identity-bound-tokens-and-the-on3</guid>
      <description>&lt;h2&gt;
  
  
  The old problem: agents running as service accounts
&lt;/h2&gt;

&lt;p&gt;For most of the last two years, the standard way to give an AI agent access to Google Cloud looked like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a service account.&lt;/li&gt;
&lt;li&gt;Grant it a pile of roles so the agent "just works."&lt;/li&gt;
&lt;li&gt;Attach it to the runtime. Sometimes, sadly, download a JSON key.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That service account is usually shared by several agents, can be impersonated by anyone with the right role, and hands out bearer tokens. A bearer token works like a hotel key card. Whoever holds it gets in. If an agent leaks its token through a prompt injection, a debug log, or a tool response, the attacker can replay it from anywhere until it expires.&lt;/p&gt;

&lt;p&gt;Agents make this worse than normal workloads. They read untrusted text all day, they call tools, and they can be talked into printing things they should not print.&lt;/p&gt;

&lt;p&gt;Google Cloud's answer is &lt;strong&gt;Agent Identity&lt;/strong&gt;, a new IAM identity type built specifically for agents. In this post I will cover how it works under the hood, why its tokens are not useful to a thief, and one lifecycle trap that most teams will hit in their first month.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Agent Identity actually is
&lt;/h2&gt;

&lt;p&gt;Every agent gets its own identity based on the SPIFFE standard. The identity is tied to the resource that hosts the agent, and it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spiffe://agents.global.org-123456789012.system.id.goog/resources/aiplatform/projects/9876543210/locations/us-central1/reasoningEngines/my-test-agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you use it in IAM, you swap &lt;code&gt;spiffe://&lt;/code&gt; for &lt;code&gt;principal://&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;principal://agents.global.org-123456789012.system.id.goog/resources/aiplatform/projects/9876543210/locations/us-central1/reasoningEngines/my-test-agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pieces:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agents.global.org-ORG_ID.system.id.goog&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Trust domain for projects inside an organization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agents.global.proj-PROJECT_NUMBER.system.id.goog&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Trust domain for projects with no organization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;aiplatform&lt;/code&gt; or &lt;code&gt;discoveryengine&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The service hosting the agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The rest&lt;/td&gt;
&lt;td&gt;The full resource path of the agent&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things make this different from a service account, according to the docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is not shared across workloads by default. One agent, one identity.&lt;/li&gt;
&lt;li&gt;It cannot be impersonated.&lt;/li&gt;
&lt;li&gt;You cannot create long-lived keys for it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today the supported hosts are Agent Runtime, Gemini Enterprise, and Cloud Run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Granting access to an agent
&lt;/h2&gt;

&lt;p&gt;Because the agent itself is the principal, you grant roles straight to it. No service account in the middle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;ORG_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"123456789012"&lt;/span&gt;
&lt;span class="nv"&gt;PROJECT_NUMBER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"9876543210"&lt;/span&gt;
&lt;span class="nv"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"my-project"&lt;/span&gt;
&lt;span class="nv"&gt;AGENT_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"projects/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROJECT_NUMBER&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/locations/us-central1/reasoningEngines/my-test-agent"&lt;/span&gt;

&lt;span class="nv"&gt;AGENT_PRINCIPAL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"principal://agents.global.org-&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ORG_ID&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.system.id.goog/resources/aiplatform/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;AGENT_PATH&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

gcloud storage buckets add-iam-policy-binding gs://invoices-raw &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--member&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;AGENT_PRINCIPAL&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"roles/storage.objectViewer"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice what this gives you: least privilege per agent. Your invoice agent can read the invoices bucket. Your HR agent cannot, even though both run in the same project. With a shared service account, that separation was very hard to keep.&lt;/p&gt;

&lt;p&gt;One small gotcha from the docs: you cannot grant agent identities the legacy bucket roles like &lt;code&gt;storage.legacyBucketReader&lt;/code&gt;. Use the modern &lt;code&gt;roles/storage.*&lt;/code&gt; roles instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  How bound tokens work (the part that matters)
&lt;/h2&gt;

&lt;p&gt;This is the core idea, so let's go slowly.&lt;/p&gt;

&lt;p&gt;When an agent with Agent Identity is deployed, Google Cloud gives it two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A SPIFFE identity.&lt;/li&gt;
&lt;li&gt;An X.509 certificate, valid for 24 hours and renewed automatically.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When the agent needs to call a Google Cloud API, it asks for an access token. That token is &lt;strong&gt;cryptographically bound to the agent's certificate&lt;/strong&gt;. The token alone is not enough. To use it, the caller must also prove it holds the private key behind that certificate.&lt;/p&gt;

&lt;p&gt;The proof happens in two ways, depending on where the call goes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;th&gt;Binding method&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Agent to Google Cloud APIs&lt;/td&gt;
&lt;td&gt;mTLS&lt;/td&gt;
&lt;td&gt;The TLS connection itself proves the agent holds the certificate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent through Agent Gateway and beyond&lt;/td&gt;
&lt;td&gt;mTLS to the gateway, plus DPoP&lt;/td&gt;
&lt;td&gt;Each request carries a signed proof that only the key holder can produce&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;DPoP stands for Demonstrating Proof of Possession. Think of it as signing every request with a key the attacker does not have. Google calls the combination "double-bound credentials."&lt;/p&gt;

&lt;p&gt;On top of that, a Google-managed Context-Aware Access policy is applied by default. It enforces the mTLS and DPoP binding so that a bound token cannot be replayed outside its trusted runtime.&lt;/p&gt;

&lt;h3&gt;
  
  
  Walking through a token theft
&lt;/h3&gt;

&lt;p&gt;Let's replay the scary scenario from the start of the post with Agent Identity in place.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An attacker plants a prompt injection in a document.&lt;/li&gt;
&lt;li&gt;The agent reads it and is tricked into echoing its access token into a tool response.&lt;/li&gt;
&lt;li&gt;The attacker copies the token and calls a Google Cloud API from their laptop.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With a service account bearer token, step 3 works. The attacker has your data.&lt;/p&gt;

&lt;p&gt;With a bound token, step 3 fails. The attacker's laptop cannot complete the mTLS handshake with the agent's certificate, and it cannot sign a DPoP proof with the agent's private key. That key never leaves the agent's runtime. The token is just a string with no power.&lt;/p&gt;

&lt;p&gt;This does not make prompt injection harmless. The agent itself can still be tricked into misusing its own access while it is running. What bound tokens remove is the attacker's ability to &lt;strong&gt;take the access and leave with it&lt;/strong&gt;. That shrinks the blast radius from "anything, anywhere, until the token expires" to "whatever the agent can be talked into right now, inside its runtime."&lt;/p&gt;

&lt;p&gt;That is exactly why the next two sections matter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limiting what a tricked agent can reach: Principal Access Boundary
&lt;/h2&gt;

&lt;p&gt;Bound tokens stop theft. They do not stop an agent from misusing permissions it legitimately has. For that, you combine two controls:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Least-privilege IAM grants per agent&lt;/strong&gt;, shown above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Principal Access Boundary (PAB) policies&lt;/strong&gt;, which cap what an agent can ever reach, no matter what roles it collects later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PAB policies on an agent identity are checked on outbound calls. If the agent tries to touch a resource outside its boundary, the call is denied even if some role somewhere would allow it. That protects you from the most common real-world failure: someone grants a broad role "temporarily" during an incident and forgets to remove it.&lt;/p&gt;

&lt;p&gt;A practical pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One PAB boundary per business domain (finance, HR, support).&lt;/li&gt;
&lt;li&gt;Every agent in that domain gets bound to that boundary at deploy time.&lt;/li&gt;
&lt;li&gt;Fine-grained IAM roles inside the boundary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Agent identities can also be used as principals in VPC Service Controls ingress and egress rules, so you can let a specific agent cross a perimeter without opening it to a whole service account.&lt;/p&gt;

&lt;h2&gt;
  
  
  The redeploy trap
&lt;/h2&gt;

&lt;p&gt;Now the part I have not seen anyone write about yet.&lt;/p&gt;

&lt;p&gt;An agent's identity comes from the &lt;strong&gt;resource ID&lt;/strong&gt; of whatever hosts it. For Agent Runtime, that is the &lt;code&gt;reasoningEngines&lt;/code&gt; resource ID. This has two consequences that the docs state plainly but that are easy to miss:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Redeploying creates a brand new identity.&lt;/strong&gt;&lt;br&gt;
If you delete an agent and deploy a replacement, even with the same name, code, and config, the new agent gets a new resource ID and therefore a new principal. None of the old IAM grants apply to it. Your "same" agent suddenly gets permission denied everywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Deleting an agent leaves its grants behind.&lt;/strong&gt;&lt;br&gt;
Deleting the agent does not remove IAM bindings that reference its principal. They stay in your policies as inactive grants until someone removes them by hand.&lt;/p&gt;

&lt;p&gt;Put those together and picture a team that redeploys by delete plus create every sprint. After six months, every bucket, dataset, and secret the agent touched carries a stack of dead principals. Nobody knows which ones are live. Your IAM policies get longer, your audits get noisier, and you are one step away from someone "fixing" an outage by granting a broad role to the wrong principal.&lt;/p&gt;
&lt;h3&gt;
  
  
  How to avoid the trap
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Update in place instead of delete plus create.&lt;/strong&gt; Agent Runtime supports managing revisions and traffic on an existing agent. As long as the hosting resource stays the same, its identity stays the same. Make "never delete to redeploy" a team rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Derive the principal in your IaC, never hardcode it.&lt;/strong&gt; If you use Terraform, build the principal string from the agent resource's output, so a replacement automatically gets fresh bindings and the old ones are destroyed with the old resource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run an orphaned grant audit.&lt;/strong&gt; That is the script below.&lt;/p&gt;
&lt;h3&gt;
  
  
  Finding orphaned agent grants
&lt;/h3&gt;

&lt;p&gt;This script searches IAM policies across your organization for agent principals, checks whether each Agent Runtime agent still exists, and reports the dead ones.&lt;/p&gt;

&lt;p&gt;It uses Cloud Asset Inventory, so the caller needs permission to search IAM policies at the organization level (for example &lt;code&gt;roles/cloudasset.viewer&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# find_orphaned_agent_grants.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;google.auth&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.auth.transport.requests&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;

&lt;span class="n"&gt;ORG_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ORG_ID&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;PRINCIPAL_RE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;principal://agents\.global\.[^/]+/resources/aiplatform/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;(projects/[^/]+/locations/([^/]+)/reasoningEngines/[^/\s]+)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search_agent_bindings&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gcloud&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;asset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;search-all-iam-policies&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--scope=organizations/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ORG_ID&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--query=policy:agents.global&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--format=json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;agent_exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;resource_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-aiplatform.googleapis.com/v1/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;resource_path&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scopes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.googleapis.com/auth/cloud-platform&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="n"&gt;orphans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;search_agent_bindings&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;resource&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;binding&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;policy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{}).&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bindings&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[]):&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;member&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;members&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[]):&lt;/span&gt;
                &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PRINCIPAL_RE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;member&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;continue&lt;/span&gt;
                &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;agent_exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                    &lt;span class="n"&gt;orphans&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;member&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;member&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;orphans&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ORPHAN  &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;  on:     &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;  member: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;member&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Total orphaned agent grants: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orphans&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few notes on the script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It only checks Agent Runtime agents (&lt;code&gt;aiplatform&lt;/code&gt; and &lt;code&gt;reasoningEngines&lt;/code&gt;). Gemini Enterprise agents use &lt;code&gt;discoveryengine&lt;/code&gt; paths, so add a similar check for those if you use them.&lt;/li&gt;
&lt;li&gt;It reports, it does not delete. Review the list before removing anything. Removing a binding is easy; finding out at 2 a.m. that it was still needed is not.&lt;/li&gt;
&lt;li&gt;Run it on a schedule and treat a growing count as a signal that your team is redeploying by delete plus create.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Seeing who really did what: audit logs
&lt;/h2&gt;

&lt;p&gt;One more benefit that SRE and security teams will like. When an agent acts on behalf of a user through delegated OAuth, the audit logs show &lt;strong&gt;both&lt;/strong&gt; the agent's identity and the user's identity.&lt;/p&gt;

&lt;p&gt;With a shared service account, an audit log line told you "the service account did it." With Agent Identity, it tells you "this specific agent did it, for this specific user." During an incident review, that difference saves hours.&lt;/p&gt;

&lt;p&gt;There are also dedicated audit logs for the Agent Identity API and the Agent Identity Credentials API, so you can track when identities and credentials are issued.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick migration checklist
&lt;/h2&gt;

&lt;p&gt;If you have agents on shared service accounts today, here is a sensible order of work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Inventory which agents share which service accounts.&lt;/li&gt;
&lt;li&gt;Turn on Agent Identity for one low-risk agent first.&lt;/li&gt;
&lt;li&gt;Grant that agent's principal only the roles it actually used. Check recent audit logs to find them.&lt;/li&gt;
&lt;li&gt;Add a PAB boundary for its business domain.&lt;/li&gt;
&lt;li&gt;Remove the agent's access to the old shared service account.&lt;/li&gt;
&lt;li&gt;Change your deploy process to update in place, then repeat for the next agent.&lt;/li&gt;
&lt;li&gt;Schedule the orphaned grant audit.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Limitations and caveats
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Agent Identity is supported on Agent Runtime, Gemini Enterprise, and Cloud Run today. Agents hosted elsewhere still need another approach.&lt;/li&gt;
&lt;li&gt;Legacy Cloud Storage bucket roles cannot be granted to agent identities.&lt;/li&gt;
&lt;li&gt;Bound tokens stop token theft and replay. They do not stop a tricked agent from misusing its own access while it is running. You still need least privilege, PAB, input filtering such as Model Armor, and human approval for risky actions.&lt;/li&gt;
&lt;li&gt;DPoP binding applies to traffic across Agent Gateway. Direct calls to Google Cloud APIs rely on mTLS binding.&lt;/li&gt;
&lt;li&gt;Trust domains differ for projects with and without an organization. Hardcoded principal strings will break if a project moves into an organization.&lt;/li&gt;
&lt;li&gt;My audit script assumes the Cloud Asset Inventory query and the &lt;code&gt;reasoningEngines&lt;/code&gt; REST path work in your environment. The platform has been renamed recently, so test it in a sandbox first.&lt;/li&gt;
&lt;li&gt;Features in this area are moving fast. Check the current docs before relying on any detail here.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Agent Identity fixes a real weakness. Agents read untrusted input all day, so their credentials need to be useless outside the agent itself. Bound tokens do exactly that.&lt;/p&gt;

&lt;p&gt;But identity tied to a resource ID brings a new kind of operational debt. Every delete plus create leaves dead grants behind and breaks the "same" agent's access. Update in place, derive principals in code, and audit for orphans, and you get the security benefits without the mess.&lt;/p&gt;

&lt;p&gt;If you run the audit script against your org, I would love to hear how many orphaned grants it finds.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Agent Identity overview: &lt;a href="https://docs.cloud.google.com/iam/docs/agent-identity-overview" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/iam/docs/agent-identity-overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Identity delegation architecture: &lt;a href="https://docs.cloud.google.com/iam/docs/identity-delegation-architecture" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/iam/docs/identity-delegation-architecture&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Authenticate to Google Cloud using an agent's own identity: &lt;a href="https://docs.cloud.google.com/iam/docs/auth-agent-own-identity" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/iam/docs/auth-agent-own-identity&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Agent Gateway overview: &lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/agent-gateway-overview" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/agent-gateway-overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;SPIFFE concepts: &lt;a href="https://spiffe.io/" rel="noopener noreferrer"&gt;https://spiffe.io/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>googlecloud</category>
      <category>security</category>
      <category>agents</category>
      <category>ai</category>
    </item>
    <item>
      <title>Your Agent Changed Last Night and Nobody Deployed Anything: Skill Drift on Google Cloud Skill Registry</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:01:20 +0000</pubDate>
      <link>https://dev.to/gde/your-agent-changed-last-night-and-nobody-deployed-anything-skill-drift-on-google-cloud-skill-1mig</link>
      <guid>https://dev.to/gde/your-agent-changed-last-night-and-nobody-deployed-anything-skill-drift-on-google-cloud-skill-1mig</guid>
      <description>&lt;h2&gt;
  
  
  The incident that never shows up in your deploy log
&lt;/h2&gt;

&lt;p&gt;Here is a scenario that's easy to create on Gemini Enterprise Agent Platform today.&lt;/p&gt;

&lt;p&gt;You build a Managed Agent. You attach a skill from Skill Registry called &lt;code&gt;invoice-triage&lt;/code&gt;. It works great. You ship it.&lt;/p&gt;

&lt;p&gt;Two weeks later, someone on another team updates &lt;code&gt;invoice-triage&lt;/code&gt; to handle a new vendor format. They test it with their own agent. It works for them.&lt;/p&gt;

&lt;p&gt;That same afternoon, your production agent starts misrouting invoices.&lt;/p&gt;

&lt;p&gt;Nobody touched your agent. No pull request, no deploy, no change ticket. Your CI pipeline is green. Your agent config in Git is identical to last week.&lt;/p&gt;

&lt;p&gt;What changed is the skill underneath it. I call this &lt;strong&gt;skill drift&lt;/strong&gt;, and in this post I will show you exactly why it happens, how to measure a second hidden problem that comes with it (the context tax of mounting many skills), and a small lockfile pattern that fixes both.&lt;/p&gt;

&lt;p&gt;Everything here is based on the public Managed Agents API and Skill Registry docs. Both are Preview, so treat the code as a starting point and test it in a sandbox project first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick refresher: how skills reach your agent
&lt;/h2&gt;

&lt;p&gt;A skill is a folder with a &lt;code&gt;SKILL.md&lt;/code&gt; file plus optional &lt;code&gt;scripts/&lt;/code&gt;, &lt;code&gt;references/&lt;/code&gt;, and &lt;code&gt;assets/&lt;/code&gt;. You upload it to Skill Registry as a zipped payload, and the registry keeps a revision history for every update.&lt;/p&gt;

&lt;p&gt;When you create or update a Managed Agent, you mount skills into the agent's sandbox through &lt;code&gt;base_environment.sources&lt;/code&gt;. The docs give you three ways to point at the registry:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Source path&lt;/th&gt;
&lt;th&gt;What the agent gets&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;projects/P/locations/L/skills/SKILL_ID&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The default version, whatever it is right now&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;projects/P/locations/L/skills/SKILL_ID/skill_versions/VERSION&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;One exact version, frozen&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;projects/P/locations/L/skills&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Up to 100 skills from that project and location&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The first and third options are the ones people copy from quickstarts. Both are floating references. That is the root of the problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: floating references are &lt;code&gt;:latest&lt;/code&gt; tags for agent behavior
&lt;/h2&gt;

&lt;p&gt;We learned this lesson years ago with container images. Deploying &lt;code&gt;myapp:latest&lt;/code&gt; to production means your production state is defined by whoever pushed last, not by what you reviewed.&lt;/p&gt;

&lt;p&gt;A skill path without a version is the same thing, except worse in one way: a skill is mostly natural language instructions. A tiny wording change in &lt;code&gt;SKILL.md&lt;/code&gt; can change which tool the model calls, what it refuses, or how it formats output. There is no compiler error. There is no failing unit test unless you wrote evals for it.&lt;/p&gt;

&lt;p&gt;A few details from the docs make this sharper:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;UpdateSkill&lt;/code&gt; can replace the display name, description, and the whole zipped filesystem in one call.&lt;/li&gt;
&lt;li&gt;The skill ID becomes the folder name inside the agent sandbox, so the agent keeps "seeing" the same skill name even after the content changed.&lt;/li&gt;
&lt;li&gt;Skill Registry inherits project level IAM. Anyone with write access in the project can update any skill in it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the blast radius of one skill update is every agent that mounts that skill without a version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 2: the context tax of "mount everything"
&lt;/h2&gt;

&lt;p&gt;The third path above is tempting. One line, and your agent has every skill in the project.&lt;/p&gt;

&lt;p&gt;But think about how skills work. In the Agent Skills pattern, the agent sees each skill's name and description up front so it can decide which one to open. The full &lt;code&gt;SKILL.md&lt;/code&gt; body only loads when the skill is picked. That is called progressive disclosure, and it keeps things cheap when you have a handful of skills.&lt;/p&gt;

&lt;p&gt;With up to 100 skills mounted, those names and descriptions add up. That text rides along on every turn, whether or not any of those skills are relevant.&lt;/p&gt;

&lt;p&gt;There is also a quality cost. More skills with overlapping descriptions means more chances for the model to pick the wrong one. Two skills named &lt;code&gt;invoice-triage&lt;/code&gt; and &lt;code&gt;invoice-review&lt;/code&gt; with similar descriptions is a routing bug waiting to happen.&lt;/p&gt;

&lt;p&gt;You cannot manage what you do not measure, so let's measure it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Measuring the skill metadata budget
&lt;/h3&gt;

&lt;p&gt;This script lists every skill in a project and location, joins the names and descriptions the way an agent would roughly see them, and counts tokens with the Count Tokens API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# skill_context_tax.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;google.auth&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.auth.transport.requests&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;

&lt;span class="n"&gt;PROJECT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GCP_PROJECT_ID&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;LOCATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SKILL_LOCATION&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;us-central1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;MODEL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;MODEL_ID&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# the Gemini model your agent uses
&lt;/span&gt;&lt;span class="n"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-aiplatform.googleapis.com/v1beta1/projects/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;PROJECT&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/locations/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;authed_session&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scopes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.googleapis.com/auth/cloud-platform&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;list_skills&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pageToken&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;BASE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/skills&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skills&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[]))&lt;/span&gt;
        &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;nextPageToken&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;skills&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;authed_session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;skills&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list_skills&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;catalog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;- &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;sk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;displayName&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;sk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sk&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;skills&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vertexai&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PROJECT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;global&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count_tokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;MODEL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;total_tokens&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Skills in &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Metadata tokens per turn (floor estimate): &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Average per skill: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two honest caveats about this number:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It is a floor. The base agent may wrap each skill in extra formatting, file paths, or instructions that you cannot see.&lt;/li&gt;
&lt;li&gt;It uses the registry description. If the &lt;code&gt;description&lt;/code&gt; in your &lt;code&gt;SKILL.md&lt;/code&gt; frontmatter is longer, the real cost is higher. Keep the two in sync.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To turn it into a monthly number, multiply by your turns per month and your model's input price. Here is the math with made up example numbers, just to show the shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;80 skills x 70 tokens         = 5,600 tokens of skill metadata per turn
5,600 x 2,000,000 turns/month = 11.2 billion input tokens per month
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plug in your own skill count, turn volume, and the current price from the pricing page. If the result surprises you, that is the point of measuring.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: a skill lockfile
&lt;/h2&gt;

&lt;p&gt;The pattern is the same one we use for package managers. Floating references are fine for development. Production gets exact, reviewed versions recorded in a file that lives in Git.&lt;/p&gt;

&lt;p&gt;The flow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;author updates skill  -&amp;gt;  registry creates new revision
                       -&amp;gt;  staging agent (floating) picks it up
                       -&amp;gt;  evals run against staging
                       -&amp;gt;  pass? update skills.lock.json in a PR
                       -&amp;gt;  merge -&amp;gt; CI pins prod agent to locked versions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 1: generate and check the lockfile
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# skill_lock.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;google.auth&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.auth.transport.requests&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;

&lt;span class="n"&gt;PROJECT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GCP_PROJECT_ID&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;LOCATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SKILL_LOCATION&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;us-central1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-aiplatform.googleapis.com/v1beta1/projects/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;PROJECT&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/locations/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;LOCKFILE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skills.lock.json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;authed_session&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scopes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.googleapis.com/auth/cloud-platform&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;latest_revision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;skill_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;revs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pageToken&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;BASE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/skills/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;skill_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/revisions&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;revs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skillRevisions&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[]))&lt;/span&gt;
        &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;nextPageToken&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;revs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="n"&gt;revs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;rev&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rev&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;createTime&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;newest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;revs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;revision&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;newest&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;created&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;newest&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;createTime&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;skill_ids&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;authed_session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;project&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;PROJECT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;location&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skills&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{}}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;skill_ids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skills&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;latest_revision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LOCKFILE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;w&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Wrote &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;LOCKFILE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; with &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;skill_ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; skills&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;authed_session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LOCKFILE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;drift&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;locked&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skills&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;latest_revision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;revision&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;locked&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;revision&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="n"&gt;drift&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;locked&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;revision&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;revision&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;drift&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DRIFT &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: locked &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, registry now has &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;drift&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lock&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;check&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python skill_lock.py lock invoice-triage vendor-lookup refund-policy
python skill_lock.py check   &lt;span class="c"&gt;# exits 1 if any skill moved&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;check&lt;/code&gt; command is your drift alarm. It does not block anyone from updating a skill. It just tells you, loudly, that the registry no longer matches what production was approved with.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: pin the production agent to the lockfile
&lt;/h3&gt;

&lt;p&gt;The agent update uses &lt;code&gt;PATCH&lt;/code&gt; with &lt;code&gt;update_mask=base_environment&lt;/code&gt;. There is no &lt;code&gt;update&lt;/code&gt; method in the Python SDK for agents yet, so this goes through REST.&lt;/p&gt;

&lt;p&gt;One gotcha worth calling out: the docs examples resend the whole &lt;code&gt;base_environment&lt;/code&gt; object, including the network allowlist. Treat this update as a full replace, not a merge. If you send only &lt;code&gt;sources&lt;/code&gt;, plan for the possibility that other environment settings go back to defaults. Network access is off by default, so a lost allowlist can break an agent that calls external APIs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# pin_agent.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;google.auth&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.auth.transport.requests&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;

&lt;span class="n"&gt;PROJECT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GCP_PROJECT_ID&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;AGENT_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AGENT_ID&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="c1"&gt;# The agent docs call this segment "skill_versions", while the registry
# returns revision names under "revisions". Confirm which one your project
# accepts, then set it here.
&lt;/span&gt;&lt;span class="n"&gt;PIN_SEGMENT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PIN_SEGMENT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skill_versions&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ALLOWLIST&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;NETWORK_ALLOWLIST&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;domain&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;api.example.com&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;}]&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;AGENT_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://aiplatform.googleapis.com/v1beta1/projects/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;PROJECT&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/locations/global/agents/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;AGENT_ID&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;?update_mask=base_environment&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skills.lock.json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;sources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skills&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;projects/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;project&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/locations/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;location&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/skills/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;PIN_SEGMENT&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;revision&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skill_registry&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;target&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/.agent/skills&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;AGENT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;base_environment&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;remote&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sources&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;network&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;allowlist&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ALLOWLIST&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scopes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.googleapis.com/auth/cloud-platform&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;patch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;AGENT_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Content-Type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;application/json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Update started:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The update is a long running operation, so poll the returned operation name before you call the rollout done.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: run the drift check on a schedule
&lt;/h3&gt;

&lt;p&gt;Any scheduler works. Here is a minimal GitHub Actions version that runs every morning and fails loudly on drift:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;skill-drift-check&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;12&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*"&lt;/span&gt;
  &lt;span class="na"&gt;workflow_dispatch&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;check&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;id-token&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;write&lt;/span&gt;
      &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;google-github-actions/auth@v2&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;workload_identity_provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.WIF_PROVIDER }}&lt;/span&gt;
          &lt;span class="na"&gt;service_account&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.DRIFT_SA }}&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pip install requests google-auth&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;python skill_lock.py check&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;GCP_PROJECT_ID&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.GCP_PROJECT_ID }}&lt;/span&gt;
          &lt;span class="na"&gt;SKILL_LOCATION&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;us-central1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The service account only needs read access, so &lt;code&gt;roles/aiplatform.viewer&lt;/code&gt; is enough for this job.&lt;/p&gt;

&lt;h2&gt;
  
  
  A few more things I noticed while building this
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Skill IDs are a namespace you cannot get back quickly.&lt;/strong&gt; Skill IDs are immutable, and after a delete the ID stays reserved for a while (the docs mention 24 hours in one place and permanent reservation in another, so plan as if it is long). Pick names carefully, and do not use delete plus recreate as a "rollback" strategy. Pinning a previous version is the rollback.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Regions do not line up one to one.&lt;/strong&gt; Managed Agents only support the &lt;code&gt;global&lt;/code&gt; location, while Skill Registry lives in specific regions (&lt;code&gt;us-central1&lt;/code&gt;, &lt;code&gt;europe-west4&lt;/code&gt;, &lt;code&gt;us-east5&lt;/code&gt; at the time of writing). Your mount path includes the skill's region, so write that region into your lockfile instead of assuming it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloud Storage mounts skip validation.&lt;/strong&gt; You can also mount skills straight from a bucket. The docs say the backend does not validate folder content in that case. That makes the registry path the safer choice for production, because uploads go through payload checks and you get revision history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write descriptions for routing, not marketing.&lt;/strong&gt; Since descriptions are both your token cost and the model's routing signal, short and specific beats long and friendly. "Classifies AP invoices by vendor and urgency. Not for refunds." does more work than a paragraph.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations and caveats
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Skill Registry and Managed Agents are Pre-GA. APIs, paths, and field names can change, and the docs say not to use confidential data with the Managed Agents preview.&lt;/li&gt;
&lt;li&gt;At the time of writing, Skill Registry does not support VPC Service Controls, CMEK, or HIPAA. Check the compliance table before you design around it.&lt;/li&gt;
&lt;li&gt;The docs use two different names for a pinned skill path (&lt;code&gt;skill_versions&lt;/code&gt; on the agent side, &lt;code&gt;revisions&lt;/code&gt; on the registry side). My script makes this configurable because I could not confirm which is final. Verify in your own project.&lt;/li&gt;
&lt;li&gt;The token numbers from the context tax script are a lower bound, not an exact bill. The base agent may add text you cannot see.&lt;/li&gt;
&lt;li&gt;A lockfile tells you what changed. It does not tell you whether the change is good. Pair it with evals on a staging agent before promoting.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Skills make agents easier to build and share across teams. That same sharing means a skill update is a production change for every agent that mounts it without a version.&lt;/p&gt;

&lt;p&gt;Three habits fix most of it: pin versions in production, measure what "mount everything" costs you, and run a daily drift check against a lockfile in Git. None of this needs new infrastructure. It is the same discipline we already apply to container images and package managers, pointed at a new kind of artifact.&lt;/p&gt;

&lt;p&gt;If you try this pattern, I would love to hear what your skill metadata token count came out to.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create and manage agents (attach skills, pinning, ListSkills mount): &lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/build/managed-agents/create-manage" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/gemini-enterprise-agent-platform/build/managed-agents/create-manage&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Create and manage skills in Skill Registry: &lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/build/skill-registry/create-manage" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/gemini-enterprise-agent-platform/build/skill-registry/create-manage&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Skills repository (SKILL.md examples): &lt;a href="https://github.com/google/skills" rel="noopener noreferrer"&gt;https://github.com/google/skills&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Agent Skills format conventions: &lt;a href="https://agentskills.io/home" rel="noopener noreferrer"&gt;https://agentskills.io/home&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>googlecloud</category>
      <category>ai</category>
      <category>agents</category>
      <category>devops</category>
    </item>
    <item>
      <title>Postmortem: The Tuesday Our AI Bill Had No Owner</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sun, 25 Oct 2026 11:15:42 +0000</pubDate>
      <link>https://dev.to/gde/postmortem-the-tuesday-our-ai-bill-had-no-owner-34pd</link>
      <guid>https://dev.to/gde/postmortem-the-tuesday-our-ai-bill-had-no-owner-34pd</guid>
      <description>&lt;p&gt;I've read a lot of postmortems. The best ones aren't about blame. They're about the gap between what happened and what the system let you see.&lt;/p&gt;

&lt;p&gt;This one is about that gap. Specifically, the gap between "our AI bill went up" and "here's exactly why."&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is a composite of patterns I've seen across platform teams, written in the standard blameless format. The names are made up. The lesson isn't.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Postmortem: The Tuesday Our AI Bill Had No Owner
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Status&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Resolved&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Severity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;SEV-3 (cost impact, no customer impact)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Time to detect&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~8 hours after the spike started&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Time to root cause&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2 hours 14 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Time it should have taken&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;About 5 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Format&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Blameless&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  1. Summary
&lt;/h2&gt;

&lt;p&gt;At 07:40 on a Tuesday, our daily cost alert fired. Vertex AI spend in the shared platform project had roughly tripled overnight.&lt;/p&gt;

&lt;p&gt;Nine services call Gemini from that project. All of them use the same service account. All of them call the same model.&lt;/p&gt;

&lt;p&gt;The billing console told us &lt;strong&gt;exactly how much&lt;/strong&gt; we spent. It could not tell us &lt;strong&gt;who&lt;/strong&gt;, &lt;strong&gt;which feature&lt;/strong&gt;, or &lt;strong&gt;which step&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The root cause turned out to be a retry loop in the review step of a nightly ticket summarization workflow. Finding it took over two hours of Slack threads, log digging, and educated guessing.&lt;/p&gt;

&lt;p&gt;The deeper root cause: &lt;strong&gt;none of our model calls carried request labels.&lt;/strong&gt; We had cost data, but no way to slice it.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Impact
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Customers:&lt;/strong&gt; None. The job's output was eventually correct.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; About 3x a normal day's AI spend for that project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;People:&lt;/strong&gt; One on-call SRE, two developers, and a FinOps analyst pulled into a two-hour investigation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust:&lt;/strong&gt; Finance asked, fairly, how we'd know if this happened again. We didn't have a good answer.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Timeline
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Monday, 16:30&lt;/strong&gt; A developer ships &lt;code&gt;prompt_version=v4&lt;/code&gt; for the ticket summarization workflow. The new prompt asks the review step to be stricter about tone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monday, 23:00&lt;/strong&gt; Nightly ticket summarization job starts. The stricter reviewer starts rejecting drafts. Each rejection triggers a rewrite with the full ticket history plus the previous draft plus review notes. Context grows on every loop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tuesday, 07:40&lt;/strong&gt; Daily cost alert fires.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;07:52&lt;/strong&gt; On-call SRE opens Cloud Billing. Filters by project. Sees one project, one service (Vertex AI), one SKU group. No breakdown below that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;08:15&lt;/strong&gt; Slack thread in #platform: "Did anyone ship anything AI-related yesterday?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;08:40&lt;/strong&gt; Three teams reply "no." One replies "maybe? we updated a prompt."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;09:05&lt;/strong&gt; SRE starts grepping application logs across services for model call volume. Logs are inconsistent. Some services log token counts, most don't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;09:30&lt;/strong&gt; A developer notices the summarization job ran for six hours instead of the usual forty minutes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;09:54&lt;/strong&gt; Root cause confirmed: review step looping on rejections, with context growing each time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10:10&lt;/strong&gt; Prompt rolled back to v3. Retry cap lowered. Job rerun successfully.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Root cause analysis (5 whys)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why did spend triple?&lt;/strong&gt;&lt;br&gt;
The review step in the summarization workflow rejected most drafts, causing repeated rewrites with growing context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why didn't we see it during the night?&lt;/strong&gt;&lt;br&gt;
Our only cost signal was the daily billing alert. Billing data isn't real-time, so it can't catch a loop while it's happening.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why did root cause take two hours?&lt;/strong&gt;&lt;br&gt;
Billing showed one number for the whole project. Nothing told us which service, workflow, or step was responsible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why couldn't billing break it down?&lt;/strong&gt;&lt;br&gt;
None of our Vertex AI calls carried request labels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why weren't we labeling?&lt;/strong&gt;&lt;br&gt;
We label infrastructure (VMs, buckets, clusters) through Terraform. Model API calls have no resource to label, so they fell through the cracks. Nobody owned the gap.&lt;/p&gt;


&lt;h2&gt;
  
  
  5. What went well
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The daily cost alert existed and fired.&lt;/li&gt;
&lt;li&gt;The team responded fast and without blame.&lt;/li&gt;
&lt;li&gt;Rollback was clean once we knew where to look.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  6. What went wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No per-call attribution for AI spend.&lt;/li&gt;
&lt;li&gt;No real-time token metrics, only delayed billing data.&lt;/li&gt;
&lt;li&gt;No retry ceiling on the review loop.&lt;/li&gt;
&lt;li&gt;Prompt changes weren't tracked anywhere cost-related.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  7. Background: how Vertex AI request labels work
&lt;/h2&gt;

&lt;p&gt;Before the action items, here's the feature we were missing. If you already know it, skip to section 8.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Naming note:&lt;/strong&gt; Vertex AI docs are moving under the &lt;strong&gt;Gemini Enterprise Agent Platform&lt;/strong&gt; name. If a docs link redirects there, it's the same feature.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In Google Cloud, labels live at three layers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Attached to&lt;/th&gt;
&lt;th&gt;Good for&lt;/th&gt;
&lt;th&gt;Blind spot&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Project labels&lt;/td&gt;
&lt;td&gt;The project&lt;/td&gt;
&lt;td&gt;Org-level showback&lt;/td&gt;
&lt;td&gt;Can't split shared projects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resource labels&lt;/td&gt;
&lt;td&gt;VMs, buckets, endpoints&lt;/td&gt;
&lt;td&gt;Infra cost&lt;/td&gt;
&lt;td&gt;Model APIs have no resource&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Request labels&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Each API call&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Per feature, per agent, per step&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Only what your code sends&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Request labels are key-value pairs you attach to each model call. Vertex AI forwards them to Cloud Billing, where you can filter and group costs in billing reports and query them in the BigQuery billing export.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rules, from the docs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Up to &lt;strong&gt;64 labels per call for Google models&lt;/strong&gt;, up to &lt;strong&gt;32 for partner models&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Keys: 1 to 63 characters, starting with a lowercase letter&lt;/li&gt;
&lt;li&gt;Keys and values: lowercase letters, numbers, underscores, and dashes only&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google models:&lt;/strong&gt; labels go in the request body on &lt;code&gt;generateContent&lt;/code&gt; and &lt;code&gt;streamGenerateContent&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partner models:&lt;/strong&gt; labels go in an &lt;code&gt;X-Vertex-AI-Labels&lt;/code&gt; header (base64-encoded JSON) on &lt;code&gt;rawPredict&lt;/code&gt; and &lt;code&gt;streamRawPredict&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Labels only reach Cloud Billing on the PayGo consumption option&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;The direct Gemini API (AI Studio keys) does not support this field&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the simplest possible Gemini call with labels:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.genai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vertexai&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;your-project-id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;global&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_GEMINI_MODEL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize this support ticket in two lines.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GenerateContentConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;team&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;support&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;env&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prod&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;use_case&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ticket_summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Three labels would have turned our two-hour investigation into one query.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Action items
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Owner&lt;/th&gt;
&lt;th&gt;Priority&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AI-1&lt;/td&gt;
&lt;td&gt;Define and publish a label taxonomy&lt;/td&gt;
&lt;td&gt;Platform + FinOps&lt;/td&gt;
&lt;td&gt;P1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-2&lt;/td&gt;
&lt;td&gt;Ship a labeled client wrapper&lt;/td&gt;
&lt;td&gt;Platform&lt;/td&gt;
&lt;td&gt;P1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-3&lt;/td&gt;
&lt;td&gt;Propagate labels through multi-agent workflows&lt;/td&gt;
&lt;td&gt;App teams&lt;/td&gt;
&lt;td&gt;P1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-4&lt;/td&gt;
&lt;td&gt;Cover partner models via header&lt;/td&gt;
&lt;td&gt;Platform&lt;/td&gt;
&lt;td&gt;P2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-5&lt;/td&gt;
&lt;td&gt;Enforce labels in CI&lt;/td&gt;
&lt;td&gt;Platform&lt;/td&gt;
&lt;td&gt;P1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-6&lt;/td&gt;
&lt;td&gt;Build label coverage and cost queries&lt;/td&gt;
&lt;td&gt;FinOps&lt;/td&gt;
&lt;td&gt;P1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-7&lt;/td&gt;
&lt;td&gt;Add real-time token metrics and alerts&lt;/td&gt;
&lt;td&gt;SRE&lt;/td&gt;
&lt;td&gt;P1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-8&lt;/td&gt;
&lt;td&gt;Cap retries in agent review loops&lt;/td&gt;
&lt;td&gt;App teams&lt;/td&gt;
&lt;td&gt;P1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each one is below, with the actual implementation.&lt;/p&gt;




&lt;h3&gt;
  
  
  AI-1: Define and publish a label taxonomy
&lt;/h3&gt;

&lt;p&gt;The first temptation is to let every team pick their own labels. Don't. Six months later you'll have &lt;code&gt;team=Support&lt;/code&gt;, &lt;code&gt;team=support&lt;/code&gt;, &lt;code&gt;team=support-team&lt;/code&gt;, and &lt;code&gt;team=cx&lt;/code&gt; all meaning the same thing.&lt;/p&gt;

&lt;p&gt;We settled on four groups:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ownership (who pays)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;team&lt;/code&gt;: the owning team&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cost_center&lt;/code&gt;: the finance code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Lifecycle (where it runs)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;env&lt;/code&gt;: &lt;code&gt;dev&lt;/code&gt;, &lt;code&gt;staging&lt;/code&gt;, &lt;code&gt;prod&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Product (what it's for)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;app&lt;/code&gt;: the service&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;use_case&lt;/code&gt;: the specific feature, like &lt;code&gt;ticket_summary&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Technical (how it ran)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;agent&lt;/code&gt;: which agent made the call&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;step&lt;/code&gt;: which workflow step, like &lt;code&gt;plan&lt;/code&gt;, &lt;code&gt;retrieve&lt;/code&gt;, &lt;code&gt;draft&lt;/code&gt;, &lt;code&gt;review&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prompt_version&lt;/code&gt;: like &lt;code&gt;v3&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;route&lt;/code&gt;: which routing rule picked the model, like &lt;code&gt;default&lt;/code&gt; or &lt;code&gt;fallback&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice that &lt;code&gt;step&lt;/code&gt; and &lt;code&gt;prompt_version&lt;/code&gt; alone would have pointed straight at our root cause: &lt;code&gt;step=review&lt;/code&gt;, &lt;code&gt;prompt_version=v4&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What never goes in a label:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User IDs, emails, session IDs, request IDs&lt;/li&gt;
&lt;li&gt;Anything sensitive&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two reasons. &lt;strong&gt;Cardinality:&lt;/strong&gt; billing data is aggregated, and a label with a million unique values makes every report useless and your queries expensive. &lt;strong&gt;Visibility:&lt;/strong&gt; label values land in billing data, and anyone with billing viewer access can read them.&lt;/p&gt;

&lt;p&gt;Our rule: &lt;strong&gt;if a label can have more than about 100 values, it belongs in logs, not billing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And we treat the taxonomy like an API contract. It's written down, versioned, and changes go through review. Renaming a key later breaks every historical query.&lt;/p&gt;




&lt;h3&gt;
  
  
  AI-2: Ship a labeled client wrapper
&lt;/h3&gt;

&lt;p&gt;Application code no longer calls the model directly. Every call goes through one wrapper that merges default labels, validates required keys, sanitizes values, and logs token usage.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# llm_client.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;contextvars&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;contextlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;contextmanager&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.genai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;

&lt;span class="n"&gt;REQUIRED_KEYS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;team&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;env&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;use_case&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_bad_chars&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[^a-z0-9_-]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_ctx_labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;contextvars&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ContextVar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llm_labels&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{})&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;_bad_chars&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;_&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;())[:&lt;/span&gt;&lt;span class="mi"&gt;63&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_clean_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;isalpha&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;k_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;63&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="nd"&gt;@contextmanager&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;llm_labels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Attach labels to every model call made inside this block.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_ctx_labels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;_ctx_labels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt;
    &lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;_ctx_labels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LabeledClient&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vertexai&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_defaults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                 &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GenerateContentConfig&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;merged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_defaults&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;_ctx_labels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{})}&lt;/span&gt;

        &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;REQUIRED_KEYS&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;merged&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Missing required LLM labels: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;merged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;_clean_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;merged&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;

        &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GenerateContentConfig&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{}),&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;merged&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;_log_usage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;merged&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_log_usage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;usage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage_metadata&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llm_usage&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;labels&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prompt_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;getattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prompt_token_count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;output_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;getattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;candidates_token_count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cached_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;getattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cached_content_token_count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;getattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total_token_count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three design decisions worth explaining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fail loud on missing labels.&lt;/strong&gt; A &lt;code&gt;ValueError&lt;/code&gt; in dev is annoying for exactly one afternoon. After that, everyone labels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sanitize instead of reject.&lt;/strong&gt; &lt;code&gt;Team: "Customer Support"&lt;/code&gt; quietly becomes &lt;code&gt;customer_support&lt;/code&gt;. A capital letter should never cause a prod outage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log usage with the same labels.&lt;/strong&gt; This is what makes AI-7 possible. Same dimensions in billing and in monitoring.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;App code stays clean:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LabeledClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;your-project-id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;global&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;defaults&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;team&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;support&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;env&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prod&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;app&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;helpdesk&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_GEMINI_MODEL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize this support ticket in two lines.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;use_case&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ticket_summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prompt_version&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;v3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  AI-3: Propagate labels through multi-agent workflows
&lt;/h3&gt;

&lt;p&gt;Our summarization workflow has four steps across three agents. Passing a &lt;code&gt;labels&lt;/code&gt; dict through every function signature would never survive code review.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;llm_labels&lt;/code&gt; context manager in the wrapper solves this. Set labels once at the top, and every call inside inherits them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;llm_labels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;use_case&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ticket_summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt_version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;v4&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;orchestrator&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;plan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_GEMINI_MODEL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;plan_prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;step&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;plan&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;llm_labels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;writer_agent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;draft&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_GEMINI_MODEL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;draft_prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                             &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;step&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;draft&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;llm_labels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;reviewer_agent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;review&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_GEMINI_MODEL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;review_prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;step&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;contextvars&lt;/code&gt; works correctly with &lt;code&gt;asyncio&lt;/code&gt;, so this holds up when agents run concurrently.&lt;/p&gt;

&lt;p&gt;If this had been in place on Monday night, the billing breakdown would have shown one line towering over the rest: &lt;code&gt;agent=reviewer_agent&lt;/code&gt;, &lt;code&gt;step=review&lt;/code&gt;, &lt;code&gt;prompt_version=v4&lt;/code&gt;. Investigation over.&lt;/p&gt;




&lt;h3&gt;
  
  
  AI-4: Cover partner models via header
&lt;/h3&gt;

&lt;p&gt;Some of our teams also call partner models through Vertex AI. For those, labels travel as a base64-encoded JSON header. Here's a Claude call as the example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;base64&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;google.auth&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;google.auth.transport.requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;PROJECT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;your-project-id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;MODEL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_CLAUDE_MODEL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scopes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.googleapis.com/auth/cloud-platform&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;team&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;support&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;env&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prod&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;use_case&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ticket_summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;labels_header&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;b64encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://aiplatform.googleapis.com/v1/projects/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;PROJECT&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/locations/global/publishers/anthropic/models/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;MODEL&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;:rawPredict&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Content-Type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;application/json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;X-Vertex-AI-Labels&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;labels_header&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;anthropic_version&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vertex-2023-10-16&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;max_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;512&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;messages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize this support ticket in two lines.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}],&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things to watch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The 32-label limit&lt;/strong&gt; for partner models. If your wrapper adds a lot of defaults, trim them for partner calls.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the supported model list&lt;/strong&gt; in the docs before assuming labels work for a newly added partner model.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We folded this into the same wrapper so app code never needs to know which path it's on.&lt;/p&gt;




&lt;h3&gt;
  
  
  AI-5: Enforce labels in CI
&lt;/h3&gt;

&lt;p&gt;A wrapper only helps if people use it. Five lines of bash close the gap:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# Fail the build if anyone calls the model directly instead of through LabeledClient.&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; &lt;span class="s2"&gt;"models.generate_content("&lt;/span&gt; &lt;span class="nt"&gt;--include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"*.py"&lt;/span&gt; src/ | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"llm_client.py"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Direct model calls found. Use LabeledClient from llm_client.py so labels are attached."&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's crude. It works. If you want something smarter later, swap it for an AST-based lint rule. Ship the crude one first.&lt;/p&gt;




&lt;h3&gt;
  
  
  AI-6: Build label coverage and cost queries
&lt;/h3&gt;

&lt;p&gt;The billing console is fine for a quick look. For real analysis, we use the BigQuery billing export. The standard export table is named &lt;code&gt;gcp_billing_export_v1_&amp;lt;BILLING_ACCOUNT_ID&amp;gt;&lt;/code&gt;, and labels live in an array of key-value structs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query 1: Label coverage.&lt;/strong&gt; This is the first number we put on a dashboard. What percentage of AI spend actually carries labels?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="nb"&gt;DATE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usage_start_time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;ROUND&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;total_cost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;ROUND&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;EXISTS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;UNNEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'team'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;labeled_cost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;ROUND&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;SAFE_DIVIDE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;EXISTS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;UNNEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'team'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;coverage_pct&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nv"&gt;`your_billing_project.billing_dataset.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;usage_start_time&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;TIMESTAMP_SUB&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;CURRENT_TIMESTAMP&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;INTERVAL&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="k"&gt;DAY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="k"&gt;LIKE&lt;/span&gt; &lt;span class="s1"&gt;'%Vertex AI%'&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;day&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;day&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the day of the incident, ours was effectively 0%. Our target is 95% in prod.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query 2: Net cost by team, use case, and step.&lt;/strong&gt; The query we wish we'd had at 07:52.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;ai&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="nb"&gt;DATE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usage_start_time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;UNNEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'team'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;team&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;UNNEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'use_case'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;use_case&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;UNNEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'step'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;UNNEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'env'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;cost&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;IFNULL&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;UNNEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;credits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;net_cost&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nv"&gt;`your_billing_project.billing_dataset.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`&lt;/span&gt;
  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;usage_start_time&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;TIMESTAMP_SUB&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;CURRENT_TIMESTAMP&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;INTERVAL&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="k"&gt;DAY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;-- Check how AI usage appears in your export first:&lt;/span&gt;
    &lt;span class="c1"&gt;-- SELECT DISTINCT service.description FROM ... and adjust this filter.&lt;/span&gt;
    &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="k"&gt;LIKE&lt;/span&gt; &lt;span class="s1"&gt;'%Vertex AI%'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;team&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;use_case&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ROUND&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;net_cost&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;net_cost&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;ai&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;team&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;use_case&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;day&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;net_cost&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the credits line. The &lt;code&gt;cost&lt;/code&gt; column doesn't include credits, so skip that and your numbers won't match the invoice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query 3: Unit economics.&lt;/strong&gt; Join labeled cost with your own business metrics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;ROUND&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;net_cost&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;ai_cost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tickets_closed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;ROUND&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SAFE_DIVIDE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;net_cost&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tickets_closed&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;cost_per_ticket&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;ai&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;  &lt;span class="c1"&gt;-- the CTE from Query 2&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="nv"&gt;`your_project.app_metrics.daily_tickets`&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;USING&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;use_case&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ticket_summary'&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'prod'&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tickets_closed&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;daily_tickets&lt;/code&gt; is your own table. This is the query that turns an AI bill into a business conversation. "AI is expensive" gets projects cancelled. "This feature costs us a fraction of a cent per ticket" gets budgets approved.&lt;/p&gt;




&lt;h3&gt;
  
  
  AI-7: Add real-time token metrics and alerts
&lt;/h3&gt;

&lt;p&gt;This is the action item that would have caught the loop at 23:30 instead of 07:40.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Billing data is not real-time.&lt;/strong&gt; Usage reaches Cloud Billing at varying intervals, and the BigQuery export updates throughout the day. That's fine for chargeback. It's useless for catching a runaway loop in the middle of the night.&lt;/p&gt;

&lt;p&gt;The fix: &lt;strong&gt;emit your own usage metrics with the same labels, in real time, and reconcile against billing daily.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The wrapper already logs &lt;code&gt;usage_metadata&lt;/code&gt; as structured JSON. On Cloud Run or GKE, JSON on stdout becomes a structured log entry automatically. From there, we created a log-based metric:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# llm_tokens_metric.yaml&lt;/span&gt;
&lt;span class="na"&gt;filter&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;jsonPayload.message="llm_usage"'&lt;/span&gt;
&lt;span class="na"&gt;metricDescriptor&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;metricKind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;DELTA&lt;/span&gt;
  &lt;span class="na"&gt;valueType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;DISTRIBUTION&lt;/span&gt;
  &lt;span class="na"&gt;unit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;use_case&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;team&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;env&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;step&lt;/span&gt;
&lt;span class="na"&gt;valueExtractor&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;EXTRACT(jsonPayload.total_tokens)'&lt;/span&gt;
&lt;span class="na"&gt;labelExtractors&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;use_case&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;EXTRACT(jsonPayload.labels.use_case)'&lt;/span&gt;
  &lt;span class="na"&gt;team&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;EXTRACT(jsonPayload.labels.team)'&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;EXTRACT(jsonPayload.labels.env)'&lt;/span&gt;
  &lt;span class="na"&gt;step&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;EXTRACT(jsonPayload.labels.step)'&lt;/span&gt;
&lt;span class="na"&gt;bucketOptions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;exponentialBuckets&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;numFiniteBuckets&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;32&lt;/span&gt;
    &lt;span class="na"&gt;growthFactor&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
    &lt;span class="na"&gt;scale&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud logging metrics create llm_total_tokens &lt;span class="nt"&gt;--config-from-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;llm_tokens_metric.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have a token metric we can chart and alert on, sliced by the exact same dimensions as the bill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alerts we added:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tokens per minute&lt;/strong&gt; for any &lt;code&gt;use_case&lt;/code&gt; above its normal ceiling. This catches loops within minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Average tokens per call&lt;/strong&gt; jumping for any &lt;code&gt;step&lt;/code&gt;. This catches prompt bloat right after a deploy. It would have flagged &lt;code&gt;prompt_version=v4&lt;/code&gt; on Monday evening.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prod calls from an unexpected &lt;code&gt;team&lt;/code&gt;.&lt;/strong&gt; This catches misconfiguration and shadow usage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you already run OpenTelemetry, do the same with a counter and put the labels on as attributes. Same idea, different pipe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Daily reconciliation.&lt;/strong&gt; Compare logged token totals against the billing export for the same labels. If they drift more than a few percent, something is calling the model outside the wrapper. That drift check is our second line of defense after CI.&lt;/p&gt;




&lt;h3&gt;
  
  
  AI-8: Cap retries in agent review loops
&lt;/h3&gt;

&lt;p&gt;Not a labels fix, but it would have limited the blast radius. Every review loop now has a hard ceiling on rewrites, and the reviewer gets a trimmed context on retries instead of the full growing history. When the cap is hit, the job flags the ticket for a human instead of trying forever.&lt;/p&gt;

&lt;p&gt;Labels tell you where the fire is. Retry caps keep the fire small.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Rollout plan
&lt;/h2&gt;

&lt;p&gt;We didn't flip a switch. Here's how we rolled it out without breaking prod:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Week 1: Audit.&lt;/strong&gt; Turn on the billing export if it isn't on. Run the coverage query. Get the baseline. (Ours was near zero.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Week 2: Wrapper with defaults.&lt;/strong&gt; Ship &lt;code&gt;LabeledClient&lt;/code&gt; with project-level defaults for &lt;code&gt;team&lt;/code&gt; and &lt;code&gt;env&lt;/code&gt;, and &lt;strong&gt;warnings, not errors&lt;/strong&gt;, for missing &lt;code&gt;use_case&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Week 3: Migrate callers.&lt;/strong&gt; Move services over one at a time. Watch coverage climb.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Week 4: Enforce.&lt;/strong&gt; Flip warnings to errors in non-prod. Turn on the CI check.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Week 5: Monitoring.&lt;/strong&gt; Log-based metrics, dashboards, alerts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;After that: Chargeback.&lt;/strong&gt; Only once coverage is stable above target. Charging teams on partial data destroys trust fast.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  10. Residual risks and known limitations
&lt;/h2&gt;

&lt;p&gt;Labels aren't magic. Here's what's still true after all of the above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PayGo only.&lt;/strong&gt; Provisioned Throughput traffic won't carry your labels into billing. Your labeled spend won't add up to total AI spend if you use PT. Plan dashboards for that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Labels are not a security control.&lt;/strong&gt; Anyone with model access can send &lt;code&gt;team=someone_else&lt;/code&gt;. If attribution must be trustworthy, pair labels with separate service accounts per team.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Values are visible.&lt;/strong&gt; Anyone with billing data access can read them. No customer data, ever.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partner limits differ.&lt;/strong&gt; 32 labels, header-based, and not every partner model is on the supported list.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Taxonomy changes break history.&lt;/strong&gt; Renaming a key is effectively a data migration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New models may lag.&lt;/strong&gt; When a new model family lands in Model Garden, verify label support before relying on it for chargeback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The direct Gemini API doesn't support this.&lt;/strong&gt; Teams using AI Studio keys won't show up in labeled billing.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  11. Lessons learned
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;We were labeling the wrong layer.&lt;/strong&gt; Our Terraform tagged every VM and bucket perfectly. But our fastest-growing cost line had no resource to tag. When the shape of your spend changes, your attribution has to change with it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost is a reliability signal.&lt;/strong&gt; A loop that burns tokens is a bug, even when the output is eventually correct. It deserves real-time alerting, not a next-morning email.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attribution is a developer job.&lt;/strong&gt; Only code can attach labels. FinOps can define the taxonomy and SRE can build the alerts, but if developers don't own the labels, nothing else works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The best postmortem action items are boring.&lt;/strong&gt; One wrapper. Three required labels. One coverage query. None of it is exciting. All of it would have turned a two-hour investigation into a five-minute one.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Your turn:&lt;/strong&gt; if your AI bill spiked tomorrow morning, how long would it take your team to explain it? Five minutes? Two hours? Never? Tell me in the comments. 👇&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Google Cloud docs: &lt;a href="https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls" rel="noopener noreferrer"&gt;Custom metadata labels (Vertex AI)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud docs: &lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/add-labels-to-api-calls" rel="noopener noreferrer"&gt;Monitor cost using custom metadata labels (Gemini Enterprise Agent Platform)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud docs: &lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/deploy/consumption-options" rel="noopener noreferrer"&gt;Consumption options overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud docs: &lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/provisioned-throughput" rel="noopener noreferrer"&gt;Provisioned Throughput overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud docs: &lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/request-response-logging" rel="noopener noreferrer"&gt;Request-response logging&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloud Billing docs: &lt;a href="https://docs.cloud.google.com/billing/docs/how-to/export-data-bigquery-tables/standard-usage" rel="noopener noreferrer"&gt;Structure of Standard data export&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloud Billing docs: &lt;a href="https://docs.cloud.google.com/billing/docs/how-to/budgets" rel="noopener noreferrer"&gt;Create, edit, or delete budgets and budget alerts&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>vertexai</category>
      <category>sre</category>
      <category>ai</category>
    </item>
    <item>
      <title>GPT-6 Is Coming to Google Cloud. Is Your AI Bill Ready?</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Sat, 24 Oct 2026 16:27:19 +0000</pubDate>
      <link>https://dev.to/gde/gpt-6-is-coming-to-google-cloud-is-your-ai-bill-ready-j7l</link>
      <guid>https://dev.to/gde/gpt-6-is-coming-to-google-cloud-is-your-ai-bill-ready-j7l</guid>
      <description>&lt;p&gt;Picture this.&lt;/p&gt;

&lt;p&gt;It's a few weeks from now. GPT-6 goes GA on Google Cloud. Five teams in your company try it on the same day. Nobody tags anything. At month-end, finance sends you one line from the invoice and one simple question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Who spent this?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's the moment I want to help you avoid.&lt;/p&gt;

&lt;p&gt;On October 21, 2026, Google Cloud announced that OpenAI models are coming to Model Garden. Most posts so far explain &lt;em&gt;what&lt;/em&gt; was announced. This one is about &lt;em&gt;what you should set up before it reaches your teams&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Grab a coffee. This takes about 6 minutes to read.&lt;/p&gt;




&lt;h2&gt;
  
  
  What actually happened (the 60-second version)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Three OpenAI models&lt;/strong&gt; are coming to Model Garden:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GPT-6 Astra&lt;/strong&gt;: for demanding work like coding, computer use, and research&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GPT-6.1 Sol&lt;/strong&gt;: close to Astra, but at a lower cost&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GPT-6 Luna&lt;/strong&gt;: fast and cheap, built for everyday work at scale&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Status:&lt;/strong&gt; private preview for select enterprise customers. General availability is planned "in the coming weeks."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Billing:&lt;/strong&gt; you buy them through Google Cloud Marketplace. Usage shows up on your normal Google Cloud invoice and draws down your existing cloud commitment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Codex:&lt;/strong&gt; you can already connect Codex CLI and Desktop to the Gemini platform for inference.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Coming later:&lt;/strong&gt; OpenAI models inside Gemini for business and Google Antigravity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Google says this makes it the only hyperscale cloud offering Gemini, Claude, and GPT on one platform.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why "one invoice" is the real news
&lt;/h2&gt;

&lt;p&gt;Before this, using OpenAI models in a Google Cloud shop usually meant a separate contract, a separate vendor review, and a separate bill.&lt;/p&gt;

&lt;p&gt;Now? Anyone with the right access in your project can try GPT-6 next to Gemini, and it all lands on the same invoice.&lt;/p&gt;

&lt;p&gt;That's great for developers. It's also how surprise bills are born.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Easy to start means easy to overspend.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The good news: you already have the tools to stay in control. You just need to set them up &lt;em&gt;before&lt;/em&gt; the excitement starts.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Match the model to the job
&lt;/h2&gt;

&lt;p&gt;Don't let every team default to the biggest model. Here's a simple starting point based on how Google describes each one:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What the team is doing&lt;/th&gt;
&lt;th&gt;Start with&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;High-volume, simple tasks (summaries, tagging, routing)&lt;/td&gt;
&lt;td&gt;GPT-6 Luna or your current Gemini setup&lt;/td&gt;
&lt;td&gt;Fast and cheap at scale&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agentic coding, multi-step work&lt;/td&gt;
&lt;td&gt;GPT-6.1 Sol&lt;/td&gt;
&lt;td&gt;Near top-tier quality at a lower price&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hardest problems (complex code, research, computer use)&lt;/td&gt;
&lt;td&gt;GPT-6 Astra&lt;/td&gt;
&lt;td&gt;Most capable, likely most expensive&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;My rule of thumb:&lt;/strong&gt; start with the cheapest model. Move up only when it fails &lt;em&gt;your own&lt;/em&gt; test prompts. Not a benchmark chart. Your prompts.&lt;/p&gt;

&lt;p&gt;And keep your existing Gemini workloads as the baseline. Compare against it, don't just replace it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Label every single call
&lt;/h2&gt;

&lt;p&gt;Vertex AI lets you attach labels to API calls. Those labels flow into Cloud Billing, so you can filter and group costs by team, environment, or use case.&lt;/p&gt;

&lt;p&gt;Here's what that looks like for a Gemini call in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.genai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vertexai&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;your-project-id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;global&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_GEMINI_MODEL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize this support ticket in two lines.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GenerateContentConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;team&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;support&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;env&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prod&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;use_case&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ticket_summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For partner models, the docs show labels passed through an &lt;code&gt;X-Vertex-AI-Labels&lt;/code&gt; header instead, and labels only reach billing on the PayGo option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Heads up:&lt;/strong&gt; at the time of writing, GPT-6 isn't in the public docs yet. So check whether labels work for OpenAI models once they go GA. If they don't, fall back to separate projects per team. Old trick, still works.&lt;/p&gt;

&lt;p&gt;A simple label scheme I like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;team&lt;/code&gt;: who owns it&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;env&lt;/code&gt;: dev, staging, prod&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;use_case&lt;/code&gt;: what it's for&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Three labels. That's enough to answer "who spent this?" in seconds.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Set budgets before GA, not after
&lt;/h2&gt;

&lt;p&gt;Create a budget with alerts so nobody finds out at month end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud billing budgets create &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--billing-account&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;YOUR_BILLING_ACCOUNT_ID &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--display-name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ai-models-monthly"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--budget-amount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1000USD &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--threshold-rule&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;percent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.50 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--threshold-rule&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;percent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.90 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--threshold-rule&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;percent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1.0,basis&lt;span class="o"&gt;=&lt;/span&gt;forecasted-spend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; budgets &lt;em&gt;alert&lt;/em&gt; you. They don't &lt;em&gt;stop&lt;/em&gt; spending. If you need a hard stop, you'll need to wire up automation yourself, or use quotas.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Ask finance three questions
&lt;/h2&gt;

&lt;p&gt;Before your teams go wild, sit down with finance and your Google account team:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Does OpenAI usage draw down our cloud commit?&lt;/strong&gt; Google says yes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do we get our savings plan discount on it?&lt;/strong&gt; Read this one carefully. Google says usage &lt;em&gt;counts toward&lt;/em&gt; Flexible Savings Plans. "Counts toward" and "gets discounted" are not always the same thing. Get the answer in writing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who approves Marketplace purchases in our org?&lt;/strong&gt; If the answer is "nobody," fix that first.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Step 5: Check the governance boxes
&lt;/h2&gt;

&lt;p&gt;If you work in a regulated industry, read the fine print:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Your prompts and outputs are not used to train foundation models&lt;/li&gt;
&lt;li&gt;✅ VPC Service Controls and unified audit logging&lt;/li&gt;
&lt;li&gt;⏳ Zero Data Retention: &lt;strong&gt;coming soon&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;⏳ Confidential Compute: &lt;strong&gt;coming soon&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your security team requires Zero Data Retention, wait for it. Don't run production data through the preview just because it's shiny.&lt;/p&gt;




&lt;h2&gt;
  
  
  What we still don't know
&lt;/h2&gt;

&lt;p&gt;Let's be honest about the gaps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No public per-token pricing on Google Cloud yet&lt;/li&gt;
&lt;li&gt;No exact GA date&lt;/li&gt;
&lt;li&gt;No list of supported regions&lt;/li&gt;
&lt;li&gt;The models aren't in the public Model Garden docs yet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So this is a "get ready" article, not a "here are the benchmarks" article. I'll write a follow-up once pricing and GA land.&lt;/p&gt;




&lt;h2&gt;
  
  
  Your 5-minute checklist
&lt;/h2&gt;

&lt;p&gt;Copy this into your team's channel:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Decide which teams get access first&lt;/li&gt;
&lt;li&gt;Agree on a label scheme (team, env, use_case)&lt;/li&gt;
&lt;li&gt;Create a budget with alerts for AI spend&lt;/li&gt;
&lt;li&gt;Ask finance about commit drawdown and savings plan discounts&lt;/li&gt;
&lt;li&gt;Confirm your data rules (wait for ZDR if you need it)&lt;/li&gt;
&lt;li&gt;Fill the interest form if you want preview access&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final thought
&lt;/h2&gt;

&lt;p&gt;Having Gemini, Claude, and GPT on one platform is a big deal. More choice usually means better results.&lt;/p&gt;

&lt;p&gt;But choice without guardrails is just a bigger bill.&lt;/p&gt;

&lt;p&gt;Set up the boring stuff now. Thank yourself later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your turn:&lt;/strong&gt; would you run GPT-6 and Gemini side by side, or stick with one model family? Tell me in the comments. 👇&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Google Cloud announcement: &lt;a href="https://cloud.google.com/blog/products/ai-machine-learning/google-cloud-brings-openai-models-to-customers" rel="noopener noreferrer"&gt;Google Cloud expands model choice and flexibility, bringing OpenAI models to customers&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenAI announcement: &lt;a href="https://openai.com/index/openai-models-google-cloud" rel="noopener noreferrer"&gt;OpenAI models are coming to Google Cloud&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud interest form: &lt;a href="https://cloud.google.com/resources/interest/openai-models" rel="noopener noreferrer"&gt;OpenAI models on Google Cloud&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenAI interest form: &lt;a href="https://openai.com/form/openai-on-google-cloud/" rel="noopener noreferrer"&gt;Get access to OpenAI frontier models on Google Cloud&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud blog: &lt;a href="https://cloud.google.com/blog/products/ai-machine-learning/flexible-billing-and-cost-controls-for-agents-on-google-cloud" rel="noopener noreferrer"&gt;Flexible billing and cost controls for agents on Google Cloud&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Vertex AI docs: &lt;a href="https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls" rel="noopener noreferrer"&gt;Custom metadata labels&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloud Billing docs: &lt;a href="https://docs.cloud.google.com/billing/docs/how-to/budgets" rel="noopener noreferrer"&gt;Create, edit, or delete budgets and budget alerts&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;gcloud reference: &lt;a href="https://docs.cloud.google.com/sdk/gcloud/reference/billing/budgets/create" rel="noopener noreferrer"&gt;gcloud billing budgets create&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>googlecloud</category>
      <category>ai</category>
      <category>finops</category>
      <category>openai</category>
    </item>
    <item>
      <title>Your AI Agent Just Got a Passport: Agent Identity on Google Cloud and the Redeploy Trap Nobody Talks About</title>
      <dc:creator>Karthigayan Devan</dc:creator>
      <pubDate>Thu, 15 Oct 2026 11:45:55 +0000</pubDate>
      <link>https://dev.to/gde/your-ai-agent-just-got-a-passport-agent-identity-on-google-cloud-and-the-redeploy-trap-nobody-52ip</link>
      <guid>https://dev.to/gde/your-ai-agent-just-got-a-passport-agent-identity-on-google-cloud-and-the-redeploy-trap-nobody-52ip</guid>
      <description>&lt;h2&gt;
  
  
  Why your agents need their own identity
&lt;/h2&gt;

&lt;p&gt;Most teams run every AI agent under one shared service account. That works until an agent does something it should not, and the audit log only says "the service account did it." You cannot tell which agent acted, and you cannot cut off one agent without breaking the rest.&lt;/p&gt;

&lt;p&gt;Google Cloud now has a fix for this called Agent Identity, part of the Gemini Enterprise Agent Platform (the new name for Vertex AI). Each agent gets its own verifiable identity, so you can grant, deny and audit access per agent, just like you do for people.&lt;/p&gt;

&lt;p&gt;In this post I walk through how it works, how to deploy an ADK agent with it, and one production trap I think every SRE should know about before they wire this into a CI/CD pipeline: &lt;strong&gt;every redeploy gives your agent a brand new identity, and its old permissions do not follow it.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Agent Identity actually is
&lt;/h2&gt;

&lt;p&gt;Think of it as a passport for each agent. When you deploy an agent to Agent Runtime with this feature turned on, Google Cloud gives it a unique identity based on the open SPIFFE standard, plus an X.509 certificate that Google creates and manages for you.&lt;/p&gt;

&lt;p&gt;In IAM, that identity shows up as a principal you can bind roles to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;principal://agents.global.org-ORGANIZATION_ID.system.id.goog/resources/aiplatform/projects/PROJECT_NUMBER/locations/LOCATION/reasoningEngines/AGENT_ENGINE_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few details worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The trust domain is created for you when you enable the Agent Platform API. With an organization it lives at the org level (&lt;code&gt;agents.global.org-...&lt;/code&gt;). Without one it lives at the project level (&lt;code&gt;agents.global.proj-...&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;The identity is tied to the agent's resource ID, not to the framework you built it with. ADK, LangGraph and others all work the same way.&lt;/li&gt;
&lt;li&gt;Out of the box the agent gets two default roles, &lt;code&gt;roles/aiplatform.agentContextEditor&lt;/code&gt; and &lt;code&gt;roles/aiplatform.agentDefaultAccess&lt;/code&gt;, so it can reach its own logs, metrics, model access, sessions and memory.&lt;/li&gt;
&lt;li&gt;The part I like most as an SRE: tokens are locked to the runtime by a Google-managed Context-Aware Access policy using mTLS certificate binding. If someone steals the token and tries to use it from outside the agent's runtime, it fails with a 401. Stolen credentials cannot be replayed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One gotcha: in IAM bindings you must use the &lt;code&gt;principal://&lt;/code&gt; format, not the raw &lt;code&gt;spiffe://&lt;/code&gt; string. Using the SPIFFE string returns an INVALID_ARGUMENT error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hands-on: deploy an ADK agent with its own identity
&lt;/h2&gt;

&lt;p&gt;You have three ways to turn it on. Pick the one that fits how you work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 1: Python SDK.&lt;/strong&gt; Define a normal ADK agent, wrap it, and pass &lt;code&gt;identity_type&lt;/code&gt; when you deploy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.adk.agents&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Agent&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;agentplatform&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;agentplatform&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;agentplatform.frameworks&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;AdkApp&lt;/span&gt;

&lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gemini-2.5-flash&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;minimal_agent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;instruction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You are a helpful assistant.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agentplatform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;http_options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;v1beta1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;remote_app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;runtimes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;AdkApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;display_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;running-agent-with-identity&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;identity_type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IdentityType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AGENT_IDENTITY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;requirements&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;google-cloud-agentplatform[adk,runtimes]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;staging_bucket&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gs://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;BUCKET_NAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;remote_app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api_resource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;effective_identity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the &lt;code&gt;v1beta1&lt;/code&gt; API version. Agent Identity needs it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 2: &lt;code&gt;adk deploy&lt;/code&gt;.&lt;/strong&gt; Drop a small config file in your agent folder before deploying:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'{ "identity_type": "AGENT_IDENTITY" }'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .agent_engine_config.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 3: Agents CLI.&lt;/strong&gt; Good for quick tests and prototypes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;agents-cli deploy &lt;span class="nt"&gt;--agent-identity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A tip I recommend: you can create the Agent Runtime instance with only &lt;code&gt;identity_type&lt;/code&gt; and no code. That gives you the identity first, so you can set up IAM before the agent ever runs. Then add the code later with &lt;code&gt;client.runtimes.update(...)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you skip the identity flag, the agent keeps using service accounts as before, so existing pipelines do not break.&lt;/p&gt;

&lt;h2&gt;
  
  
  Least privilege in two layers
&lt;/h2&gt;

&lt;p&gt;The pattern that works best is to split permissions into a shared floor and a narrow ceiling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 1: a baseline for every agent in the project.&lt;/strong&gt; Use a &lt;code&gt;principalSet&lt;/code&gt; so one binding covers all agents, now and in the future. Put only boring, low-risk roles here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;AGENTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"principalSet://agents.global.org-ORGANIZATION_ID.system.id.goog/attribute.platformContainer/aiplatform/projects/PROJECT_NUMBER"&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;ROLE &lt;span class="k"&gt;in &lt;/span&gt;roles/serviceusage.serviceUsageConsumer roles/browser &lt;span class="se"&gt;\&lt;/span&gt;
            roles/aiplatform.expressUser roles/logging.logWriter &lt;span class="se"&gt;\&lt;/span&gt;
            roles/monitoring.metricWriter&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;gcloud projects add-iam-policy-binding PROJECT_ID &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--member&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$AGENTS&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;--role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$ROLE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Layer 2: narrow grants per agent.&lt;/strong&gt; Anything sensitive, like a BigQuery dataset or a Cloud Storage bucket with customer data, goes to one specific agent's &lt;code&gt;principal://&lt;/code&gt; only:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud storage buckets add-iam-policy-binding gs://orders-data &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--member&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"principal://agents.global.org-ORGANIZATION_ID.system.id.goog/resources/aiplatform/projects/PROJECT_NUMBER/locations/us-central1/reasoningEngines/AGENT_ENGINE_ID"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"roles/storage.objectViewer"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Multi-agent bonus (A2A).&lt;/strong&gt; If a parent agent calls a subagent registered in Agent Registry, the &lt;em&gt;parent agent's identity&lt;/em&gt; needs two roles: &lt;code&gt;roles/agentregistry.viewer&lt;/code&gt; to look the subagent up, and &lt;code&gt;roles/aiplatform.user&lt;/code&gt; on the subagent's reasoning engine to call it. Grant these to the parent agent, not to your own user account. This is an easy mistake that shows up as confusing permission errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  The redeploy trap nobody talks about
&lt;/h2&gt;

&lt;p&gt;This is the part that will bite SRE and platform teams. &lt;strong&gt;Every time a pipeline deletes and recreates an agent, the agent gets a new &lt;code&gt;reasoningEngines&lt;/code&gt; ID, which means a brand new principal.&lt;/strong&gt; Permissions granted to the old principal do not carry over.&lt;/p&gt;

&lt;p&gt;Picture a normal day:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your agent runs fine with read access to &lt;code&gt;gs://orders-data&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A blue-green deploy, an ephemeral test environment or a &lt;code&gt;terraform apply&lt;/code&gt; with a replace recreates the agent.&lt;/li&gt;
&lt;li&gt;The new agent starts, passes its health check, and then quietly gets 403 errors the first time it touches the bucket.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;No deploy failure, no alert, just an agent that suddenly "can't find" data. That is a silent outage.&lt;/p&gt;

&lt;p&gt;It gets worse in the other direction. Deleting an agent does &lt;strong&gt;not&lt;/strong&gt; remove the IAM bindings that point to it. Those dead bindings stay in your policies until someone cleans them up by hand. Over time that is policy clutter and an audit headache.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to fix it
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Fix 1: grant access as a post-deploy step.&lt;/strong&gt; Read the new identity right after deploy and bind roles to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;IDENTITY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;gcloud ai reasoning-engines describe RESOURCE_ID &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;PROJECT_ID &lt;span class="nt"&gt;--location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;LOCATION &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"value(spec.effectiveIdentity)"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

gcloud storage buckets add-iam-policy-binding gs://orders-data &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--member&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"principal://&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;IDENTITY&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"roles/storage.objectViewer"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix 2: let Terraform build the principal for you.&lt;/strong&gt; Derive it from the deployed resource so bindings are always recreated with the agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"google_vertex_ai_reasoning_engine"&lt;/span&gt; &lt;span class="s2"&gt;"agent"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;provider&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;google-beta&lt;/span&gt;
  &lt;span class="nx"&gt;project&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;project_id&lt;/span&gt;
  &lt;span class="nx"&gt;region&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;region&lt;/span&gt;
  &lt;span class="nx"&gt;display_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"orders-agent"&lt;/span&gt;

  &lt;span class="nx"&gt;spec&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;agent_framework&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"google-adk"&lt;/span&gt;
    &lt;span class="nx"&gt;identity_type&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"AGENT_IDENTITY"&lt;/span&gt;
    &lt;span class="c1"&gt;# source_code_spec and deployment_spec here&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;locals&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;agent_id&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;google_vertex_ai_reasoning_engine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;agent_principal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"principal://agents.global.org-${data.google_organization.org.org_id}.system.id.goog/resources/aiplatform/projects/${data.google_project.project.number}/locations/${var.region}/reasoningEngines/${local.agent_id}"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"google_storage_bucket_iam_member"&lt;/span&gt; &lt;span class="s2"&gt;"orders_reader"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"orders-data"&lt;/span&gt;
  &lt;span class="nx"&gt;role&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"roles/storage.objectViewer"&lt;/span&gt;
  &lt;span class="nx"&gt;member&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;local&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;agent_principal&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the binding depends on the agent resource, Terraform replaces both together, and destroying the agent removes its binding too. That also solves the orphaned binding problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix 3: lean on the baseline layer.&lt;/strong&gt; Project-level &lt;code&gt;principalSet&lt;/code&gt; bindings survive delete and recreate, so the agent still has quota, logging and model access right after a redeploy. Keep per-agent bindings only for sensitive data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix 4: add a smoke test.&lt;/strong&gt; After deploy, have the pipeline send one real request that touches each protected resource. A 403 here fails the pipeline instead of failing in front of users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Guardrails: what agents must never do
&lt;/h2&gt;

&lt;p&gt;Allow policies say what an agent can do. For agents that act on their own, you also want hard limits that no allow policy can override. Agent Identity works with two IAM tools for this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IAM deny policies.&lt;/strong&gt; Block specific permissions for all agent identities across the org, no matter what roles someone grants later. Good candidates are destructive actions like deleting buckets or creating IAM roles. The official docs include a ready deny policy example you can adapt (link in Sources).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Principal Access Boundary (PAB).&lt;/strong&gt; This limits &lt;em&gt;where&lt;/em&gt; an agent can operate at all. For example, you can say agents in your org may only touch resources inside one folder. Even if someone accidentally grants an agent a role on a production project outside that folder, PAB blocks it.&lt;/p&gt;

&lt;p&gt;My rule of thumb: allow policies are for daily work, deny policies are for "never, ever", and PAB is the fence around the whole yard. Agent Identity also plugs into VPC Service Controls if you need a network-level perimeter on top.&lt;/p&gt;

&lt;h2&gt;
  
  
  Audit: finally knowing which agent did what
&lt;/h2&gt;

&lt;p&gt;With Cloud Logging turned on, every access shows the agent's own identity instead of a shared service account. Two cases matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the agent acts on its own, the log shows only the agent's identity.&lt;/li&gt;
&lt;li&gt;When the agent acts on behalf of a user, the log shows both the agent and the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That second case is a big deal for compliance reviews. You can answer "which agent read this data, and for whom?" without guessing.&lt;/p&gt;

&lt;p&gt;To see all your agents and their identities in one place, open the Agent Platform &lt;strong&gt;Deployments&lt;/strong&gt; page in the console and look at the &lt;strong&gt;Identity&lt;/strong&gt; column, or read &lt;code&gt;spec.effectiveIdentity&lt;/code&gt; from the API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations and caveats
&lt;/h2&gt;

&lt;p&gt;Be honest with your team about these before you roll it out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It needs the &lt;code&gt;v1beta1&lt;/code&gt; API version, so treat it as a moving target and check the docs before each upgrade.&lt;/li&gt;
&lt;li&gt;Agent identities cannot be granted the legacy Cloud Storage bucket roles (&lt;code&gt;legacyBucketReader&lt;/code&gt;, &lt;code&gt;legacyBucketWriter&lt;/code&gt;, &lt;code&gt;legacyBucketOwner&lt;/code&gt;). If your buckets still depend on those, plan a cleanup.&lt;/li&gt;
&lt;li&gt;The redeploy trap above is by design, not a bug. Your pipeline has to handle it.&lt;/li&gt;
&lt;li&gt;Deleted agents leave orphaned IAM bindings unless your tooling removes them.&lt;/li&gt;
&lt;li&gt;You can turn off the Context-Aware Access token binding for special token-sharing cases, but Google strongly discourages it because it reopens the door to credential theft. I would not.&lt;/li&gt;
&lt;li&gt;Identity controls &lt;em&gt;what an agent can reach&lt;/em&gt;, not &lt;em&gt;what it decides to do&lt;/em&gt;. A prompt injection can still trick an agent into misusing access it legitimately has. Pair this with content safety controls like Model Armor and keep a human in the loop for risky actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrap-up: a production checklist
&lt;/h2&gt;

&lt;p&gt;Agent Identity turns agents into first-class citizens in IAM. The feature is easy to turn on. The real work is in the pipeline around it. Here is the checklist I would use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Deploy every agent with &lt;code&gt;identity_type = AGENT_IDENTITY&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Put low-risk shared roles on a project &lt;code&gt;principalSet&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Grant sensitive data access per agent only&lt;/li&gt;
&lt;li&gt;[ ] Rebind per-agent roles automatically after every redeploy (Terraform or a post-deploy step)&lt;/li&gt;
&lt;li&gt;[ ] Clean up IAM bindings when an agent is deleted&lt;/li&gt;
&lt;li&gt;[ ] Add a post-deploy smoke test that touches each protected resource&lt;/li&gt;
&lt;li&gt;[ ] Add deny policies for destructive permissions&lt;/li&gt;
&lt;li&gt;[ ] Fence agents in with Principal Access Boundary&lt;/li&gt;
&lt;li&gt;[ ] Turn on Cloud Logging so every action is traceable to one agent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are running agents in production on Google Cloud, I would love to hear how you are handling identity today. Shared service accounts, or something better?&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/scale/runtime/agent-identity" rel="noopener noreferrer"&gt;Use Agent Identity with Agent Runtime&lt;/a&gt; (Google Cloud docs)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.cloud.google.com/iam/docs/agent-identity-overview" rel="noopener noreferrer"&gt;Agent Identity overview&lt;/a&gt; (IAM docs)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloud.google.com/agent-registry/identity-and-identifiers" rel="noopener noreferrer"&gt;Agent Registry: identity and identifiers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cloud.google.com/blog/products/ai-machine-learning/introducing-gemini-enterprise-agent-platform" rel="noopener noreferrer"&gt;Introducing Gemini Enterprise Agent Platform&lt;/a&gt; (Google Cloud blog)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>discuss</category>
      <category>agents</category>
      <category>googlecloud</category>
    </item>
  </channel>
</rss>
