Challenge 4: Bouncer at the Gate

Previous Challenge Next Challenge

Introduction

Agents connected to business systems introduce new security vectors, such as prompt injections, jailbreaks, leakage of sensitive data etc. Hardcoding defenses into every individual agent can be brittle and error-prone.

Agent Gateway serves as the centralized network ingress/egress control plane for Gemini Platform. Integrating Model Armor with Agent Gateway provides real-time, inline content inspection and filtering. Model Armor can sanitize prompts on ingress (before they reach the agent) and filters responses on egress (before they reach the client), enforcing security policies across your entire agent fleet without touching a single line of agent code.

In this challenge we’ll start protecting our agent against the mentioned attack vectors.

Description

Create a Model Armor Template, call it retail-agent-security-template and configure it with the following filters:

  • Prompt Injection & Jailbreak Filter: Set to BLOCK on high confidence.
  • PII / Sensitive Data Filter: Enable Basic sensitive data protection.
  • Responsible AI Filter: Block Hate Speech, Dangerous, Sexually Explicit, and Harassment Content on high confidence.

Create and configure an Agent Gateway resource for ingress mode and attach the Model Armor security template to the Agent Gateway.

Route traffic to your Agent Runtime instance through the governed Agent Gateway.

 Note
You need to export a few environment variables before running the sanitization tests, otherwise the tests will be skipped with warnings.

Success Criteria

  • Model Armor template is created with prompt injection, jailbreak, and PII protection rules.
  • Agent Gateway is deployed with the Model Armor template attached.
  • Verify that the setup is working by running the sanitization tests, they should all pass successfully.
  • No code was modified.

Learning Resources

Tips

  • Use Google Cloud Console for configuring the Model Armor template and the Agent Gateway; the CLI route is not trivial. Once those resources are created, you can use agents-cli to update the agent’s configuration to start using the newly configured Agent Gateway.
  • Model Armor and Agent Gateway must be in the same Google Cloud region.

Previous Challenge Next Challenge