<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by honeyn on Medium]]></title>
        <description><![CDATA[Stories by honeyn on Medium]]></description>
        <link>https://medium.com/@honey.narendran3?source=rss-fc9548485413------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IMdus1WesGT379er.jpg</url>
            <title>Stories by honeyn on Medium</title>
            <link>https://medium.com/@honey.narendran3?source=rss-fc9548485413------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 21:29:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@honey.narendran3/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Prototype to Production: Deploying ADK Agents on Cloud Run with Enterprise VPC Governance]]></title>
            <link>https://medium.com/google-cloud/from-prototype-to-production-deploying-adk-agents-on-cloud-run-with-enterprise-vpc-governance-c88a3147b17f?source=rss-fc9548485413------2</link>
            <guid isPermaLink="false">https://medium.com/p/c88a3147b17f</guid>
            <category><![CDATA[gcp-security-operations]]></category>
            <category><![CDATA[google-adk]]></category>
            <category><![CDATA[google-cloud-run]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[agents]]></category>
            <dc:creator><![CDATA[honeyn]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 10:18:54 GMT</pubDate>
            <atom:updated>2026-09-08T10:18:54.587Z</atom:updated>
            <content:encoded><![CDATA[<p>Building an agent with Google’s <a href="https://google.github.io/adk-docs/">Agent Development Kit</a> (ADK) takes an afternoon. Getting that agent in front of real users, inside an enterprise network, without punching a hole in the perimeter, takes a lot more care. This post walks through both halves using one concrete example — an “Inventory Assistant” agent — and the full, runnable code lives alongside it in this <a href="https://github.com/honey303/sample_adk_agent"><strong><em>repository</em></strong></a> under agent/ and infra/.</p><p>The gap between the two halves is usually where agent projects stall: a prototype that works great against a public Gemini endpoint on a laptop, and a security team that (correctly) won’t let an unauthenticated, internet-facing container reach internal systems. Closing that gap is an infrastructure problem as much as an agent-design problem, so this post treats them together.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sFQgYwc-60ZlKEjDpMcwyA.png" /></figure><p>A few things the picture makes explicit that are easy to lose in prose:</p><ul><li>Cloud Run sits outside the VPC boundary. It’s a serverless resource, not a VPC-native one — there’s no way to “put it inside” the network the way you would a VM. The Serverless VPC Access connector (②) is the only bridge in, and it only carries RFC1918 traffic (vpc-egress: private-ranges-only), so it&#39;s useless for reaching the public internet — that&#39;s what Cloud NAT is for, and this deployment never needs it since every real destination is either inside the subnet or reachable over Google&#39;s private path.</li><li>Two separate outbound paths, not one. Calls to the internal inventory API (②) go through the connector into the subnet. Calls to Secret Manager (③) and Vertex AI’s Gemini API (④) go directly over Google’s private network (private.googleapis.com) and never touch the connector at all — conflating these two paths is a common misconfiguration that either breaks the direct-path calls or, worse, quietly routes them somewhere ungoverned.</li><li>The inbound path is the mirror image of the outbound one. --ingress=internal-and-cloud-load-balancing means step ① can only originate from inside the VPC (or through an internal/external HTTPS load balancer fronting the service) — a public caller doesn&#39;t get an authentication error, they get no route to the service at all.</li><li>roles/run.invoker starts empty. Nothing in this diagram can call the Cloud Run service until something is explicitly added to it — that&#39;s AUTHORIZED_INVOKERS in scripts/setup_infra_gcloud.sh, deliberately absent from the default deploy.</li></ul><h3>The agent</h3><blockquote>The Inventory Assistant answers two kinds of questions for an internal team: “is this SKU in stock?” and “can we fulfill this order in this region?”. Both answers come from an internal inventory API — http://inventory-api.internal:8080 — that has no public IP. That detail is the whole reason this post exists: the moment an agent&#39;s tools need to reach something private, &quot;deploy the container somewhere with a public URL&quot; stops being a viable production plan.</blockquote><pre># agent/inventory_assistant/agent.py<br>import os<br><br>from google.adk.agents import Agent<br><br>from .tools import check_order_eligibility, get_inventory_status<br><br>MODEL = os.environ.get(&quot;ADK_MODEL&quot;, &quot;gemini-2.5-flash&quot;)<br><br>root_agent = Agent(<br>    name=&quot;inventory_assistant&quot;,<br>    model=MODEL,<br>    description=(<br>        &quot;Enterprise inventory assistant that answers stock and &quot;<br>        &quot;order-eligibility questions using internal systems reachable &quot;<br>        &quot;only over the corporate VPC.&quot;<br>    ),<br>    instruction=(<br>        &quot;You are an inventory assistant for an internal enterprise team. &quot;<br>        &quot;Use the get_inventory_status tool to check stock for a SKU, and &quot;<br>        &quot;check_order_eligibility to confirm whether an order can be &quot;<br>        &quot;fulfilled in a given region. Always call a tool before answering &quot;<br>        &quot;a question about stock or order eligibility rather than guessing.&quot;<br>    ),<br>    tools=[get_inventory_status, check_order_eligibility],<br>)</pre><p>ADK turns plain Python functions into tools automatically, as long as they have type hints and a docstring the model can read:</p><pre># agent/inventory_assistant/tools.py (excerpt)<br>def get_inventory_status(sku: str) -&gt; dict:<br>    &quot;&quot;&quot;Look up current stock levels for a SKU from the internal inventory service.&quot;&quot;&quot;<br>    resp = requests.get(<br>        f&quot;{INTERNAL_API_BASE_URL}/v1/inventory/{sku}&quot;,<br>        timeout=REQUEST_TIMEOUT_SECONDS,<br>    )<br>    resp.raise_for_status()<br>    return resp.json()</pre><p>INTERNAL_API_BASE_URL is an environment variable, not a hardcoded host — that&#39;s what lets the exact same code run against a stub locally and against the real internal service once it&#39;s on the VPC.</p><h3>Phase 1: Prototype</h3><p>No container, no cloud project, just a loop that exercises the agent through ADK’s Runner and an in-memory session:</p><pre># agent/local_run.py (excerpt)<br>session_service = InMemorySessionService()<br>runner = Runner(agent=root_agent, app_name=APP_NAME, session_service=session_service)<br><br>await session_service.create_session(app_name=APP_NAME, user_id=user_id, session_id=session_id)<br>content = types.Content(role=&quot;user&quot;, parts=[types.Part(text=query)])<br><br>async for event in runner.run_async(user_id=user_id, session_id=session_id, new_message=content):<br>    if event.is_final_response() and event.content and event.content.parts:<br>        print(event.content.parts[0].text)</pre><pre>cd agent<br>pip install -r requirements.txt<br>export GOOGLE_API_KEY=...<br>python local_run.py &quot;Do we have SKU-10293 in stock, and can I ship 50 units to us-east?&quot;</pre><p>Off the corporate network, inventory-api.internal won&#39;t resolve — the tool catches the requests.RequestException and returns {&quot;status&quot;: &quot;unavailable&quot;} instead of crashing the run. That graceful degradation is what makes phase 1 possible at all without VPC access, but it also means you won&#39;t see the agent reason over real data unless something is actually listening on the other end. agent/mock_internal_api.py is exactly that: a few in-memory routes standing in for the real internal service, so INTERNAL_API_BASE_URL=http://localhost:8090 python local_run.py &quot;...&quot; exercises the full tool-calling loop with genuine responses instead of &quot;unavailable&quot; placeholders. This is the whole point of phase 1: validate the agent&#39;s reasoning and tool-calling behavior cheaply, before infrastructure enters the picture at all.</p><h3>Phase 2: Containerize</h3><blockquote>Prototype code and production code should be the same code. The only thing that changes is how it’s invoked: instead of a Python script driving the Runner directly, a small FastAPI app does, so Cloud Run has a standard HTTP surface to route to.</blockquote><pre># agent/server.py (excerpt)<br>@app.post(&quot;/invoke&quot;, response_model=InvokeResponse)<br>async def invoke(req: InvokeRequest, request: Request) -&gt; InvokeResponse:<br> _enforce_internal_auth(request)<br> session_id = req.session_id or str(uuid.uuid4())<br> …<br> content = types.Content(role=&quot;user&quot;, parts=[types.Part(text=req.query)])<br> async for event in runner.run_async(user_id=req.user_id, session_id=session_id, new_message=content):<br> if event.is_final_response() and event.content and event.content.parts:<br> final_text = event.content.parts[0].text or &quot;&quot;</pre><p>_enforce_internal_auth checks a shared-secret header sourced from Secret Manager. It&#39;s not the primary access control — Cloud Run&#39;s own IAM and ingress settings are (more on that below) — it&#39;s a second, independent check so that a misconfigured IAM binding doesn&#39;t silently become the only thing standing between the internet and this agent&#39;s tools.</p><p>The Dockerfile is a standard non-root, slim-Python build; Cloud Run injects PORT at runtime, which uvicorn picks up:</p><pre># agent/Dockerfile<br>FROM python:3.12-slim<br>WORKDIR /app<br>RUN useradd --create-home --uid 1000 appuser<br>COPY requirements.txt .<br>RUN pip install --no-cache-dir -r requirements.txt<br>COPY . .<br>USER appuser<br>ENV PORT=8080<br>EXPOSE 8080<br>CMD [&quot;uvicorn&quot;, &quot;server:app&quot;, &quot;--host&quot;, &quot;0.0.0.0&quot;, &quot;--port&quot;, &quot;8080&quot;]</pre><pre>docker build -t inventory-assistant agent/<br>docker run -p 8080:8080 -e GOOGLE_API_KEY=... inventory-assistant<br>curl -X POST localhost:8080/invoke -d &#39;{&quot;query&quot;: &quot;Is SKU-10293 in stock?&quot;}&#39;</pre><p>This runs and answers exactly like phase 1 — it just does it behind a URL now, which is what makes phase 3 possible.</p><h3>Phase 3: Production, with enterprise VPC governance</h3><blockquote>This is where most of the real engineering happens, and it’s expressed entirely as Terraform in infra/ so it&#39;s reviewable and repeatable rather than a sequence of gcloud commands someone ran once. Four pieces do the work.</blockquote><h3>1. A private VPC and a route in</h3><blockquote>Cloud Run services don’t sit inside a VPC by default — they’re fully managed and, by default, egress straight to the internet. A <a href="https://cloud.google.com/vpc/docs/serverless-vpc-access">Serverless VPC Access connector</a> is what bridges the two, giving the agent’s container a path into the private subnet where inventory-api.internal lives:</blockquote><pre># infra/vpc.tf (excerpt)<br>resource &quot;google_compute_network&quot; &quot;adk_vpc&quot; {<br>  name                    = var.network_name<br>  auto_create_subnetworks = false<br>}<br><br>resource &quot;google_compute_subnetwork&quot; &quot;private_subnet&quot; {<br>  name                     = &quot;${var.network_name}-subnet&quot;<br>  ip_cidr_range            = var.subnet_cidr<br>  network                  = google_compute_network.adk_vpc.id<br>  private_ip_google_access = true<br>}<br><br>resource &quot;google_vpc_access_connector&quot; &quot;connector&quot; {<br>  name          = &quot;${var.network_name}-conn&quot;<br>  network       = google_compute_network.adk_vpc.name<br>  ip_cidr_range = var.vpc_connector_cidr<br>  min_instances = 2<br>  max_instances = 3<br>}</pre><p>Cloud NAT sits alongside it so that any traffic that does need to leave the VPC (nothing in this example does, since Gemini calls take Cloud Run’s normal direct path, not the connector) has a controlled, logged egress point rather than a public IP on the connector itself.</p><h3>2. Deny-by-default egress</h3><blockquote>The firewall posture is inverted from what’s typical: nothing leaves the VPC unless a rule says so.</blockquote><pre># infra/vpc.tf (excerpt)<br>resource &quot;google_compute_firewall&quot; &quot;deny_all_egress&quot; {<br>  name      = &quot;${var.network_name}-deny-all-egress&quot;<br>  network   = google_compute_network.adk_vpc.name<br>  direction = &quot;EGRESS&quot;<br>  priority  = 65534<br>  deny { protocol = &quot;all&quot; }<br>  destination_ranges = [&quot;0.0.0.0/0&quot;]<br>}<br><br>resource &quot;google_compute_firewall&quot; &quot;allow_internal_egress&quot; {<br>  name      = &quot;${var.network_name}-allow-internal-egress&quot;<br>  network   = google_compute_network.adk_vpc.name<br>  direction = &quot;EGRESS&quot;<br>  priority  = 1000<br>  allow {<br>    protocol = &quot;tcp&quot;<br>    ports    = [&quot;443&quot;, &quot;8080&quot;]<br>  }<br>  destination_ranges = [var.subnet_cidr, var.vpc_connector_cidr]<br>}</pre><p>A separate, narrow rule allows HTTPS to 199.36.153.8/30 — the private.googleapis.com VIP — so calls to Vertex AI and Secret Manager stay on Google&#39;s private network path instead of the public internet, even from inside a VPC that otherwise denies everything by default.</p><h3>3. Least-privilege identity, internal-only ingress</h3><blockquote>The Cloud Run service runs as its own service account — never the default compute service account — with exactly two roles: invoke Vertex AI, read secrets.</blockquote><pre># infra/iam.tf (excerpt)<br>resource &quot;google_service_account&quot; &quot;agent_runtime&quot; {<br>  account_id   = &quot;inventory-assistant-run&quot;<br>  display_name = &quot;Runtime identity for the Inventory Assistant ADK agent&quot;<br>}<br><br>resource &quot;google_project_iam_member&quot; &quot;vertex_user&quot; {<br>  role   = &quot;roles/aiplatform.user&quot;<br>  member = &quot;serviceAccount:${google_service_account.agent_runtime.email}&quot;<br>}</pre><p>Nobody can invoke the service by default — authorized_invoker_members is an empty list unless a caller is explicitly added — and ingress is locked to internal traffic only, so even a leaked URL is useless from outside the network:</p><pre># infra/cloud_run.tf (excerpt)<br>resource &quot;google_cloud_run_v2_service&quot; &quot;agent&quot; {<br>  ingress = &quot;INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER&quot;<br><br>  template {<br>    service_account = google_service_account.agent_runtime.email<br><br>    vpc_access {<br>      connector = google_vpc_access_connector.connector.id<br>      egress    = &quot;PRIVATE_RANGES_ONLY&quot;<br>    }<br><br>    containers {<br>      image = var.container_image<br>      env {<br>        name = &quot;INTERNAL_API_KEY&quot;<br>        value_source {<br>          secret_key_ref {<br>            secret  = &quot;inventory-assistant-internal-key&quot;<br>            version = &quot;latest&quot;<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>egress = &quot;PRIVATE_RANGES_ONLY&quot; means only RFC1918 traffic (the internal inventory API) is forced through the connector; the agent&#39;s calls to Gemini still take Cloud Run&#39;s direct, faster path to Google&#39;s APIs rather than being routed through the connector and NAT unnecessarily.</p><h3>4. An optional org-wide backstop: VPC Service Controls</h3><blockquote>Everything above governs <em>this project’s</em> network path. VPC Service Controls governs data exfiltration risk at the org level: even a caller with valid IAM credentials for Vertex AI or Secret Manager can’t use them from outside an approved perimeter — for example, if a service account key were copied out and used from an unauthorized project. This is genuinely optional (it requires an org-level Access Context Manager policy that’s usually managed by a platform team, not per-project), so it’s gated behind a variable:</blockquote><pre># infra/vpc_sc.tf (excerpt)<br>resource &quot;google_access_context_manager_service_perimeter&quot; &quot;agent_perimeter&quot; {<br>  count  = var.enable_vpc_sc ? 1 : 0<br>  parent = &quot;accessPolicies/${var.access_policy_id}&quot;<br>  status {<br>    resources            = [&quot;projects/${data.google_project.current[0].number}&quot;]<br>    restricted_services   = [&quot;aiplatform.googleapis.com&quot;, &quot;run.googleapis.com&quot;, &quot;secretmanager.googleapis.com&quot;]<br>    vpc_accessible_services {<br>      enable_restriction = true<br>      allowed_services    = [&quot;aiplatform.googleapis.com&quot;, &quot;run.googleapis.com&quot;, &quot;secretmanager.googleapis.com&quot;]<br>    }<br>  }<br>}</pre><h3>Shipping it</h3><blockquote>scripts/deploy.sh chains the two halves: build and push the image, then provision everything above and deploy.</blockquote><pre>export PROJECT_ID=your-gcp-project<br>./scripts/deploy.sh</pre><p>Under the hood it enables the required APIs, builds agent/ with Cloud Build, pushes to Artifact Registry, and hands off to scripts/setup_infra_gcloud.sh, which recreates every resource shown in the Terraform snippets above with plain gcloud commands instead — same VPC, same connector, same firewall rules, same IAM roles, same gcloud run deploy flags. It&#39;s idempotent (each resource is created only if a gcloud ... describe doesn&#39;t already find it), so re-running it after a code change just pushes a new image and updates the Cloud Run revision. The only tool this needs beyond the gcloud CLI itself is a GCP project to point it at — no Terraform install required. If you&#39;d rather manage this as Terraform state instead of imperative gcloud calls, infra/*.tf is the same infrastructure as HCL; it&#39;s just not what deploy.sh uses by default.</p><p>Either way, the result is a Cloud Run revision that:</p><ul><li>is unreachable from the public internet (--ingress=internal-and-cloud-load-balancing),</li><li>has nobody authorized to invoke it until you set AUTHORIZED_INVOKERS,</li><li>can reach the internal inventory API through the VPC connector and nothing else outbound by default,</li><li>runs as a service account with two IAM roles, not the project-wide default,</li><li>and reads its shared secret from Secret Manager rather than a baked-in env var.</li></ul><blockquote>The full source for all three phases — agent, Dockerfile, gcloud and Terraform infra, test scripts — is in this repository under agent/, infra/, and scripts/. Clone it, swap in your own tools and internal API, and adapt the VPC governance layer to your org&#39;s actual policies. Happy tinkering!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c88a3147b17f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/from-prototype-to-production-deploying-adk-agents-on-cloud-run-with-enterprise-vpc-governance-c88a3147b17f">From Prototype to Production: Deploying ADK Agents on Cloud Run with Enterprise VPC Governance</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Visual Quality Assurance: Building a Multimodal Scoring Agent with Google ADK]]></title>
            <link>https://medium.com/@honey.narendran3/automating-visual-quality-assurance-building-a-multimodal-scoring-agent-with-google-adk-2ec79a62aa06?source=rss-fc9548485413------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ec79a62aa06</guid>
            <category><![CDATA[multimodality]]></category>
            <category><![CDATA[google-adk]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[honeyn]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 05:43:40 GMT</pubDate>
            <atom:updated>2026-09-08T05:43:40.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6VGGKM3_z4ytmACFYqYowg.png" /></figure><p>Enterprises today are inundated with visual data, yet fully automating subjective visual tasks remains one of the hardest challenges in AI. Whether it’s grading a manufacturing defect on an assembly line, evaluating the layout of a submitted document, or assessing vehicle damage for an insurance claim, traditional computer vision solutions often fall short. They typically require massive, meticulously labeled datasets and expensive, custom-trained models for every specific use case.</p><p>But what if you could just tell an AI your grading rubric and show it an image?</p><p>With the release of Gemini 2.5 Pro and the <strong>Google Agent Development Kit (ADK)</strong>, you can do exactly that. We recently contributed a new template to the <a href="https://github.com/google/adk-samples">ADK samples repository</a> called the <strong>Multimodal Scoring Agent</strong>. This template demonstrates how to leverage Gemini’s advanced multimodal reasoning alongside structured outputs to apply strict, JSON-defined scoring rubrics to images — reliably and deterministically.</p><h3>The Challenge of Subjective Visual Quality Assurance</h3><blockquote>Consider a quality assurance inspector at a circuit board manufacturing plant. They don’t just look for “anomalies”; they follow a strict, codified set of rules (a rubric) to determine if a board passes, needs rework, or is a critical failure.</blockquote><blockquote>Replicating this with standard generative AI often leads to inconsistent results — chatty responses, fluctuating grading scales, and unpredictable formatting. To integrate an AI inspector into an enterprise pipeline, we need <strong>deterministic outputs</strong> (a consistent data structure) and <strong>traceable reasoning</strong> (an explanation of <em>why</em> a grade was given based on the rubric).</blockquote><h3>Enter the Multimodal Scoring Agent</h3><p>Our newly merged ADK sample solves this by combining three powerful features:</p><ol><li><strong>Gemini’s Multimodal Understanding:</strong> The ability to natively process and analyze high-resolution images.</li><li><strong>JSON-Defined Rubrics:</strong> A dynamic way to inject domain-specific rules into the prompt.</li><li><strong>Structured Outputs:</strong> Forcing the agent to reply strictly in a predefined schema (using Pydantic).</li></ol><p>Let’s walk through the code to see how easy it is to build this with the Google ADK.</p><h3>Step 1: Defining the Output Schema</h3><p>First, we define exactly what we want the agent to return using Pydantic. By passing this schema to the ADK, we guarantee that the output will always contain a grade, reasoning, and confidence score—no more parsing messy text responses!</p><pre>from pydantic import BaseModel, Field<br><br>class ScoringResult(BaseModel):<br>    grade: str = Field(<br>        description=&quot;The deterministic grade assigned based on the rubric.&quot;<br>    )<br>    reasoning: str = Field(<br>        description=&quot;Detailed reasoning for why the grade was given, referencing specific criteria from the rubric.&quot;<br>    )<br>    confidence: float = Field(<br>        description=&quot;Confidence score in the assessment, from 0.0 to 1.0.&quot;<br>    )</pre><h3>Step 2: Defining the Rubric</h3><p>Instead of hardcoding rules into the prompt, we keep them in a clean JSON file (rubric.json). This separates the logic from the agent definition, allowing non-technical domain experts to easily update the grading criteria (e.g., changing from a &quot;Pass/Fail&quot; system to a Mensa-style scoring scale).</p><pre>{<br>  &quot;rubric_name&quot;: &quot;Circuit Board Quality Assurance&quot;,<br>  &quot;criteria&quot;: [<br>    {<br>      &quot;grade&quot;: &quot;Pass&quot;,<br>      &quot;conditions&quot;: [&quot;All soldering joints are clean and shiny.&quot;, &quot;No scorch marks.&quot;]<br>    },<br>    {<br>      &quot;grade&quot;: &quot;Fail - Critical&quot;,<br>      &quot;conditions&quot;: [&quot;Visible scorch marks or burning.&quot;, &quot;Missing components.&quot;]<br>    }<br>  ],<br>  &quot;instructions&quot;: &quot;Evaluate the highest severity defect found.&quot;<br>}</pre><h3>Step 3: Initializing the ADK Agent</h3><p>Now, we wire it all together using the Agent class from Google ADK. Notice how we pass ScoringResult directly to the response_schema parameter</p><pre>from google.adk.agents import Agent<br>import json<br><br># Initialize the Agent<br>scoring_agent = Agent(<br>    name=&quot;multimodal_scoring_agent&quot;,<br>    model=&quot;gemini-2.5-pro&quot;, # Using Pro for advanced visual reasoning<br>    description=&quot;Evaluates images against a strict scoring rubric.&quot;,<br>    instruction=&quot;&quot;&quot;You are an expert visual quality assurance inspector. <br>You will be provided with an image and a JSON-defined scoring rubric. <br>Analyze the image against the criteria. Apply the rules strictly and objectively. <br>Return your final evaluation using the required structured output format.&quot;&quot;&quot;,<br>    output_schema=ScoringResult<br>)<br><br>def evaluate_image(image_path: str, rubric_path: str):<br>    import asyncio<br>    import uuid<br>    from google.genai import types<br>    from google.adk.runners import InMemoryRunner<br>    <br>    with open(rubric_path, &#39;r&#39;) as f:<br>        rubric_data = json.load(f)<br>        <br>    prompt = f&quot;Evaluate the attached image using this rubric:\n{json.dumps(rubric_data)}&quot;<br>    <br>    with open(image_path, &quot;rb&quot;) as f:<br>        img_data = f.read()<br>        <br>    content = types.Content(<br>        role=&quot;user&quot;,<br>        parts=[<br>            types.Part.from_bytes(data=img_data, mime_type=&quot;image/jpeg&quot;),<br>            types.Part.from_text(text=prompt)<br>        ]<br>    )<br>    <br>    async def run_agent():<br>        runner = InMemoryRunner(agent=scoring_agent)<br>        runner.auto_create_session = True<br>        <br>        events = runner.run_async(<br>            user_id=&quot;local_user&quot;,<br>            session_id=str(uuid.uuid4()),<br>            new_message=content<br>        )<br>        <br>        result = None<br>        async for event in events:<br>            if hasattr(event, &#39;message&#39;) and event.message and event.message.parts:<br>                text = event.message.parts[0].text<br>                try:<br>                    result = ScoringResult.model_validate_json(text)<br>                except Exception:<br>                    pass<br>        return result<br>                <br>    return asyncio.run(run_agent())</pre><h3>The Result</h3><p>When you pass an image of a defective circuit board to this agent, it doesn’t give you a conversational summary. It gives you an actionable, enterprise-ready data object:</p><pre>=== Scoring Result ===<br>Grade: Fail - Critical<br>Confidence: 0.95<br>Reasoning:<br>Based on the Circuit Board Quality Assurance rubric, the image contains visible scorch marks near the main processor chip. This meets the criteria for a &quot;Fail - Critical&quot; grade as outlined in the conditions.</pre><h3>Get Started Today</h3><p>Automating subjective visual tasks no longer requires a six-month machine learning project. By combining the multimodal reasoning of Gemini with the structured, deterministic capabilities of the Google ADK, you can build reliable visual inspection agents in an afternoon.</p><p>Check out the full code in the <a href="https://github.com/google/adk-samples">google/adk-samples repository</a> and try swapping out our manufacturing rubric with your own document layout rules, medical image assessments, or retail auditing guidelines!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ec79a62aa06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GKE Binary Authorization]]></title>
            <link>https://medium.com/google-cloud/gke-binary-authorization-e856cbdca880?source=rss-fc9548485413------2</link>
            <guid isPermaLink="false">https://medium.com/p/e856cbdca880</guid>
            <category><![CDATA[gcp-security-operations]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[gke]]></category>
            <dc:creator><![CDATA[honeyn]]></dc:creator>
            <pubDate>Wed, 11 Dec 2024 06:36:54 GMT</pubDate>
            <atom:updated>2024-12-12T11:08:45.649Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the key security concerns for running Kubernetes clusters is knowing what container images are running inside each pod and being able to account for their origin. Establishing “container provenance” means having the ability to trace the source of a container to a trusted point of origin and ensuring your organization follows the desired processes during artifact (container) creation.</p><p>Some of the key concerns are:</p><ul><li><strong>Safe Origin</strong> — How do you ensure that all container images running in the cluster come from an approved source?</li><li><strong>Consistency and Validation</strong> — How do you ensure that all desired validation steps were completed successfully for every container build and every deployment?</li><li><strong>Integrity</strong> — How do you ensure that containers were not modified before running after their provenance was proven?</li></ul><p><a href="https://cloud.google.com/binary-authorization/">Binary Authorization (BinAuthz)</a> is a service that aims to reduce some of these concerns by adding deploy-time policy enforcement to your Kubernetes Engine cluster. Policies can be written to require one or more trusted parties (called “attestors”) to approve of an image before it can be deployed. For a multi-stage deployment pipeline where images progress from development to testing to production clusters, attestors can be used to ensure that all required processes have completed before software moves to the next stage.</p><h3>Architecture</h3><p>The Binary Authorization and Container Analysis APIs are based upon the open-source projects Grafeas and Kritis.</p><ul><li>Grafeas defines an API spec for managing metadata about software resources, such as container images, Virtual Machine (VM) images, JAR files, and scripts. You can use Grafeas to define and aggregate information about your project’s components.</li><li>Kritis defines an API for ensuring a deployment is prevented unless the artifact (container image) is conformant to central policy and optionally has the necessary attestations present.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*3CETqA22gH_wfP93Crx-gw.png" /><figcaption>Container Deployment Pipeline</figcaption></figure><p>The container goes through at least 4 steps:</p><ol><li>The source code for creating the container is stored in source control.</li><li>Upon committing a change to source control, the container is built and tested.</li><li>If the build and test steps are completed, the container image artifact is then placed in a central container registry, ready for deployment.</li><li>When a deployment of that container version is submitted to the Kubernetes API, the container runtime will pull that container image from the container registry and run it as a pod.</li></ol><p>In a container build pipeline, there are opportunities to inject additional processes to signify or “attest” that each step was completed successfully. An “attestation authority” is a human or system with the correct PGP key and the ability to register that “attestation” with the Container Analysis API.</p><p>By using separate PGP keys for each step, each attestation step could be performed by different humans, systems, or build steps in the pipeline (a). Each PGP key is associated with an “attestation note” which is stored in the Container Analysis API. When a build step “signs” an image, a snippet of JSON metadata about that image is signed via PGP and that signed snippet is submitted to the API as a “note occurrence”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*iRec3JEvcc_HVlnY_T8Tnw.png" /></figure><p>(b).Once the container image has been built and the necessary attestations have been stored centrally, they are available for being queried as a part of a policy decision process. In this case, a <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/">Kubernetes Admission Controller</a>, upon receiving an API request to create or update a Pod:</p><ol><li>Send a WebHook to the Binary Authorization API for a policy decision.</li><li>The Binary Authorization policy is then consulted.</li><li>If necessary, the Container Analysis API is also queried for the necessary attestation occurrences.</li><li>If the container image conforms to the policy, it is allowed to run.</li><li>If the container image fails to meet the policy, an error is presented to the API client with a message describing why it was prevented.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*LfaEYE4xRB_bUXbiF-6c0Q.png" /></figure><p><strong>Copy Resources</strong></p><pre>gsutil -m cp -r gs://spls/gke-binary-auth/* .</pre><pre>cd gke-binary-auth-demo</pre><p>Run the following to set a region and zone for your lab (you can use the region/zone that’s best for you):</p><pre>gcloud config set compute/region us-central1<br>gcloud config set compute/zone us-central1-a</pre><h4>Updating files permissions</h4><pre>chmod +x create.sh<br>chmod +x delete.sh<br>chmod 777 validate.sh</pre><h4>Set default cluster version</h4><pre>sed -i &#39;s/validMasterVersions\[0\]/defaultClusterVersion/g&#39; ./create.sh</pre><h4>Deployment steps</h4><pre>./create.sh -c my-cluster-1</pre><p>The script will:</p><ol><li>Enable the necessary APIs in your project. Specifically, container, containerregistry, containeranalysis, and binaryauthorization.</li><li>Create a new Kubernetes Engine cluster in your default ZONE, VPC and network.</li><li>Retrieve your cluster credentials to enable kubectl usage.</li></ol><h4>Using Binary Authorization</h4><ol><li>In the Google Cloud console, navigate to the <strong>Security</strong> &gt; <strong>Binary Authorization</strong>.</li><li>Click <strong>Edit Policy</strong>.</li><li>After clicking <strong>Edit Policy</strong>, the following will appear. Click the down arrow next to <strong>Custom Exemption Rules</strong> to display them:</li><li>Change your <strong>Default rule</strong> to Disallow all images</li><li>Click <strong>Create Specific Rules</strong>.</li><li>Select <strong>GKE Cluster</strong> from the dropdown. Click <strong>Change</strong>.</li><li>Under <strong>GKE Cluster-specific rules</strong>, Click <strong>Add Specific Rule</strong>.</li><li>In the <strong>Add GKE Cluster-specific rule</strong> field, enter your location and cluster name in the form location.clustername. e.g. us-central1-a.my-cluster-1 which corresponds to the zone us-central1-a and the cluster name my-cluster-1.</li><li>Select the default rule of Allow all images for your cluster.</li><li>Click <strong>ADD</strong></li><li>Click <strong>Save Policy</strong>.</li></ol><h4>Creating a private GCR image</h4><ol><li>In Cloud Shell, pull down the latest nginx container:</li></ol><pre>docker pull gcr.io/google-containers/nginx:latest</pre><p>2. Authenticate docker to the project:</p><pre>gcloud auth configure-docker</pre><p>3. Set the PROJECT_ID shell variable:</p><pre>PROJECT_ID=&quot;$(gcloud config get-value project)&quot;</pre><p>4. Tag and push it to the current project’s GCR:</p><pre>docker tag gcr.io/google-containers/nginx &quot;gcr.io/${PROJECT_ID}/nginx:latest&quot;<br>docker push &quot;gcr.io/${PROJECT_ID}/nginx:latest&quot;</pre><p>5. List the “private” nginx image in your own GCR repository:</p><pre>gcloud container images list-tags &quot;gcr.io/${PROJECT_ID}/nginx&quot;</pre><h3>Denying all images</h3><ol><li>To do this, launch a single nginx pod:</li></ol><pre>cat &lt;&lt; EOF | kubectl create -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>  - name: nginx<br>    image: &quot;gcr.io/${PROJECT_ID}/nginx:latest&quot;<br>    ports:<br>    - containerPort: 80<br>EOF</pre><p>2. List the pods:</p><pre>kubectl get pods</pre><p>3. Now, delete this pod:</p><pre>kubectl delete pod nginx</pre><p>4. Next, prove that the Binary Authorization policy can block undesired images from running in the cluster.</p><p>On the Binary Authorization page, click <strong>Edit Policy</strong>,</p><p>5. Expand the <strong>Rules</strong> dropdown, click on the three vertical dots to the right of your GKE Cluster specific rule, and click <strong>edit</strong>.</p><p>6. Then, select Disallow all images, click <strong>Submit</strong>.</p><p>7. Finally, click <strong>Save Policy</strong> to apply those changes.</p><p>8. Now, run the same command as before to create the static nginx pod:</p><pre>cat &lt;&lt; EOF | kubectl create -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>  - name: nginx<br>    image: &quot;gcr.io/${PROJECT_ID}/nginx:latest&quot;<br>    ports:<br>    - containerPort: 80<br>EOF</pre><p>This time, though, you should receive a message from the API server indicating that the policy prevented this pod from being successfully run:</p><h3>Denying images except from allowlisted container registries</h3><ol><li>Let’s say that you actually want to allow <em>just</em> that nginx container to run. The quickest step to enable this is to <em>allowlist</em> the registry that it comes from.</li><li>You will use the output of the following command as your image path:</li></ol><pre>echo &quot;gcr.io/${PROJECT_ID}/nginx*&quot;</pre><p>3. Copy the image path output to your buffer.</p><p>4. Navigate to the <strong>Navigation menu</strong> &gt; <strong>Security</strong> &gt; <strong>Binary Authorization</strong>.</p><p>5. Edit the Binary Authorization Policy, display the image paths, then click <strong>Add Image Pattern</strong>.</p><p>6. Paste in the image path you copied earlier and click <strong>Done</strong>. The image below shows an example path.</p><p>7. Click <strong>Save Policy</strong>, then run:</p><pre>cat &lt;&lt; EOF | kubectl create -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>  - name: nginx<br>    image: &quot;gcr.io/${PROJECT_ID}/nginx:latest&quot;<br>    ports:<br>    - containerPort: 80<br>EOF</pre><p>You should now be able to launch this pod and prove that registry allowlisting is working correctly.</p><h3>Tear down</h3><p>The following script will destroy the Kubernetes Engine cluster:</p><pre>./delete.sh -c my-cluster-1</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e856cbdca880" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/gke-binary-authorization-e856cbdca880">GKE Binary Authorization</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Questionnaire Creation from PDF Documents with Vertex AI]]></title>
            <link>https://medium.com/google-cloud/automating-questionnaire-creation-from-pdf-documents-with-vertex-ai-cccda0b1c067?source=rss-fc9548485413------2</link>
            <guid isPermaLink="false">https://medium.com/p/cccda0b1c067</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[vertex-ai]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[honeyn]]></dc:creator>
            <pubDate>Tue, 10 Dec 2024 11:35:12 GMT</pubDate>
            <atom:updated>2024-12-12T11:08:31.918Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Y1qeJ_WXo-GpQtYsAZppVQ.jpeg" /></figure><p>In today’s tech-driven world, AI is revolutionizing how we approach various tasks. One such application is automating the generation of questionnaires from documents, which can be a huge time-saver, especially for educators and researchers. In this blog, I will show you how to leverage <strong>Vertex AI</strong> to automatically generate a list of questions from any given PDF document using Google’s generative AI capabilities.</p><h4>What is Vertex AI?</h4><p><strong>Vertex AI</strong> is a platform provided by Google Cloud that allows developers and data scientists to build and deploy machine learning models. Among its many features, one of the most powerful is its ability to generate content using advanced models like <strong>Gemini-1.5 Flash</strong>, which is a multimodal large language model capable of processing various forms of input, such as text, audio, images etc.</p><p>In this example, we’ll walk through the process of using Vertex AI to generate a questionnaire from a provided PDF document.</p><h4>Prerequisites</h4><p>Before diving into the code, make sure you have the following:</p><ol><li>A <strong>Google Cloud account</strong> and a <strong>Vertex AI project</strong> set up.</li><li><strong>Python</strong> installed with the required libraries.</li><li>A <strong>Google Cloud Storage bucket</strong> to store your PDF files.</li></ol><h3>Step-by-Step Guide to Generating a Questionnaire</h3><p><strong>Step 1: Install Required Libraries</strong><br>Before you begin, make sure you have the necessary libraries installed. You’ll need the <strong><em>vertexai</em></strong> library to interact with Google Cloud’s Vertex AI SDK.</p><p>To install the library, use the following command:</p><pre>pip install vertexai</pre><h4>Step 2: Initialize the Vertex AI Project</h4><p>The first step in your code is to initialize <strong>Vertex AI</strong> by specifying your <strong>Google Cloud Project ID</strong>.</p><pre>PROJECT_ID = &quot;YOUR_PROJECT_ID&quot;<br>vertexai.init(project=PROJECT_ID, location=&quot;us-central1&quot;)</pre><h4>Step 3: Load the LLM Model</h4><p>Next, we load the specific generative AI model that will generate the questionnaire based on the content of the PDF document. In this case, we use <strong>Gemini-1.5 Flash</strong> model.</p><pre>model = GenerativeModel(&quot;gemini-1.5-flash-002&quot;)</pre><h4>Step 4: Define the Prompt for the Model</h4><p>In this step, we define the <strong>prompt</strong> that we will send to the model. The prompt provides instructions to the model, guiding it on how to generate the questions.</p><pre>prompt = &quot;&quot;&quot;<br>  # Please create a list of questions for the given document.<br>  # Do not make up any question that is not part of the provided document.<br>&quot;&quot;&quot;</pre><h4>Step 5: Provide the URI of the PDF File</h4><pre>pdf_file = Part.from_uri(<br>    uri=&quot;gs://your-bucket-name/your-document.pdf&quot;,  # Replace with your actual file URI<br>    mime_type=&quot;application/pdf&quot;,<br>)</pre><p>What does this do?</p><ul><li>Part.from_uri(): This function is used to load the PDF file into the AI model. The uri points to the location of your document in Google Cloud Storage.</li><li>You need to replace &quot;gs://your-bucket-name/your-document.pdf&quot; with the actual path where your PDF is stored. Make sure the file is accessible.</li></ul><h4>Step 6: Prepare the Content for the Model</h4><p>Once the PDF and the prompt are ready, we prepare the content that we’ll send to the model. This involves creating a list with the PDF and prompt as its elements.</p><pre>contents = [pdf_file, prompt]</pre><h4>Step 7: Generate the Questionnaire</h4><p>We now send the contents (PDF and prompt) to the AI model for processing. The model will read the PDF, interpret the prompt, and generate a set of questions based on the content of the document.</p><pre>response = model.generate_content(contents)<br>print(response.text)</pre><h4>Final Code:</h4><pre>import vertexai<br>from vertexai.generative_models import GenerativeModel, Part<br><br>PROJECT_ID = &quot;YOUR_PROJECT_ID&quot;<br><br>vertexai.init(project=PROJECT_ID, location=&quot;us-central1&quot;)<br>model = GenerativeModel(&quot;gemini-1.5-flash-002&quot;)<br><br>prompt = &quot;&quot;&quot;<br>  # Please create a list of questions for the given document.<br>  # Do not make up any question that is not part of the provided document.<br>&quot;&quot;&quot;<br><br>pdf_file = Part.from_uri(<br>    uri=&quot;gs://your-bucket-name/your-document.pdf&quot;,  # Replace with your actual file URI<br>    mime_type=&quot;application/pdf&quot;,<br>)<br>contents = [pdf_file, prompt]<br><br>response = model.generate_content(contents)<br>print(response.text)</pre><h4>Example Response</h4><p>Here’s an example of how the generated questions might look like</p><pre>**I. Foundational Understanding:**<br><br>1.  What is the main contribution of the Transformer model as presented in this paper? How does it differ from previous sequence transduction models?<br><br>2.  Explain the concept of &quot;self-attention.&quot;  What are its advantages over recurrent and convolutional approaches?  Illustrate with examples from the paper.<br><br>3.  Describe the architecture of the Transformer. Detail the encoder and decoder stacks, including the components within each layer (self-attention, feed-forward networks, residual connections, layer normalization).<br><br>4.  Explain the &quot;Scaled Dot-Product Attention&quot; mechanism. How does multi-head attention enhance the model&#39;s performance?</pre><h4>Benefits of Using Vertex AI for Questionnaire Creation</h4><ul><li><strong>Efficiency</strong>: Automatically generating a set of questions saves time compared to manually going through the document and creating questions.</li><li><strong>Consistency</strong>: The AI ensures that questions are relevant and coherent, based on the document’s content.</li><li><strong>Customization</strong>: You can tailor the prompt to adjust the difficulty or depth of the questions based on your needs.</li></ul><h3>Conclusion</h3><p>By following these steps, you’ve just automated the process of creating a questionnaire from any PDF document using <a href="https://cloud.google.com/vertex-ai"><strong>Google Cloud’s Vertex AI</strong></a>. This powerful AI model can help educators, researchers, or content creators quickly generate meaningful questions from documents, saving time and effort.</p><blockquote>Feel free to adjust the prompt or use a different llm model and fine-tune the code to suit your specific use cases — whether it’s for quizzes, exams, or even generating discussion points from academic papers.</blockquote><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cccda0b1c067" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/automating-questionnaire-creation-from-pdf-documents-with-vertex-ai-cccda0b1c067">Automating Questionnaire Creation from PDF Documents with Vertex AI</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>