The Brand Aligner Agent provides an end-to-end workflow for evaluating visual assets (images and videos) against a company's brand guidelines. It operates as a self-contained application where orchestration, brand guidelines extraction, asset evaluation and processing run within a single process.
The evaluation methodology relies on a state-of-the-art implementation that utilises Gecko on the Vertex AI Evaluation Service for prompt adherence, along with additional custom rubrics that cover brand alignment and generation quality.
Refer to the defensive publication on this topic titled Rubric-Based Evaluation for On-Brand Generative Media for more details.
The agent utilizes the Google Agent Developer Kit (ADK) and follows a sequential chain of specialized agents:
-
brand_aligner_agent(Root/Planner):- Role: Entry point for the user. It handles file uploads, searches for existing files in Google Cloud Storage (GCS), and formulates the execution plan.
- Tools:
save_artifacts_to_gcs_tool,search_user_files_tool,save_plan_to_state_tool. - Next Step: Transitions to the
guideline_processor_agent.
-
guideline_processor_agent:- Role: Iterates through the selected guideline files one by one. It extracts structured criteria from documents (PDF, Markdown, Text).
- Tools:
guideline_processor_tool(callsGuidelineService). - Next Step: Transitions to the
asset_evaluator_agent.
-
asset_evaluator_agent:- Role: Iterates through the selected asset files (images/videos) one by one. It evaluates each asset against the processed guidelines using a multimodal model.
- Tools:
asset_evaluator_tool(callsEvalService). - Next Step: Transitions to the
summarizer_agent.
-
summarizer_agent:- Role: Aggregates the results from all evaluations and presents a final summary to the user.
- In-Process Services: The agent logic relies on
services.py(GuidelineServiceandEvalService), which handle the interactions with Google's generative models (Gemini and Vertex AI Eval SDK). - Tools: Defined in
tools.py, these bridge the agents to the services and handle state management (reading/writing to GCS).
The agent implements a hybrid authentication strategy in auth.py:
- Gemini Enterprise Mode: When running within the Gemini Enterprise ecosystem, it utilizes the user's existing session token for seamless authentication.
- Standalone/ADK Mode: When running independently, it implements a standard OAuth2 flow, prompting the user to authenticate via Google to access GCS resources.
- Session State: Used to pass the plan (file lists), processed guidelines, and evaluation reports between agents.
- Google Cloud Storage (GCS): Acts as the persistent storage layer.
- User uploads are saved as artifacts.
- Processed guideline JSONs and Evaluation Report JSONs are stored for audit and retrieval.
Before running or deploying the agent, you must configure the environment.
-
Copy the environment template:
cp .env.template .env
-
Configure
.env: Open the newly created.envfile and fill in the required values (Project ID, Region, GCS Bucket, Model Name, etc.).
Use the Agent Starter Pack to create a production-ready version of this agent with additional deployment options.
uvx agent-starter-pack create my-brand-aligner -a adk@brand-alignerAlternative: Using pip and a virtual environment
# Create and activate a virtual environment
python -m venv .venv
# Linux/macOS
source .venv/bin/activate
# Windows PowerShell
.venv\Scripts\Activate.ps1
# Install starter pack and create your project
pip install --upgrade agent-starter-pack
agent-starter-pack create my-brand-aligner -a adk@brand-alignerThe starter pack guides you through setup options and generates a production-ready project structure.
Alternative: Local development from this sample repo (manual clone)
-
Clone and move into the sample:
git clone https://github.com/google/adk-samples.git cd adk-samples/python/agents/brand-aligner -
Install dependencies:
uv sync
-
Run tests:
uv run pytest -v
-
Run the ADK web UI:
uv run adk web --log_level DEBUG
Access the UI at
http://localhost:8000.
To deploy the agent to Agent Engine then register it with Gemini Enterprise:
-
Deploy the Agent:
uv run deployment/deploy.py
-
Register with Gemini Enterprise:
The deployment/ directory contains essential scripts for managing the agent's registration and configuration with Gemini Enterprise.
config.sh: CRITICAL. This file contains all the variables required for Gemini Enterprise registration and deployment (for example, Agent Engine ID and service account details). It relies on your local.envfile for values. Ensure this is configured correctly before running the registration script.ge_register.sh: Registers the deployed agent with Gemini Enterprise.ge_unregister.sh: Unregisters the agent from Gemini Enterprise.
The agent relies on the following key environment variables (defined in .env):
MODEL_NAME: The name of the generative model to use for agent reasoning and evaluation (for example,gemini-2.5-flash).GCS_BUCKET_NAME: The GCS bucket for storing artifacts and processed files.PROJECT_ID: The Google Cloud Project ID.LOCATION: The Google Cloud region (for example,us-central1).AUTH_ID,OAUTH_CLIENT_ID,OAUTH_CLIENT_SECRET: Authentication credentials for the OAuth2 flow (if running in standalone mode).