Vertex AI Agent Builder Getting Started — Build Gemini Agents with No Code
Vertex AI Agent Builder enables construction and deployment of Gemini-based custom agents without code. This guide covers setup through production operations.
Agent Builder Overview
Key Features
- No-Code UI: Build agents without writing code
- Multi-Datasource Support: Integrate Cloud Storage, BigQuery, and websites
- Custom Tools: Integrate REST APIs and serverless functions
- Conversation Management: Automatic multi-turn conversation handling
- Built-in Testing: Real-time testing in Playground
- API Deployment: Export as standard REST API
Setup and Initial Configuration
Prerequisites
# Create Google Cloud project
gcloud projects create my-agent-project
gcloud config set project my-agent-project
# Enable required APIs
gcloud services enable \
aiplatform.googleapis.com \
cloudfunctions.googleapis.com \
run.googleapis.com \
storage-api.googleapis.com \
bigquery.googleapis.comCreating an Agent
- Visit Google Cloud Console
- Navigate to Vertex AI → Agent Builder
- Click Create Agent
- Enter configuration:
- Agent Name: e.g.,
customer-support-agent - Description: Describe agent purpose
- Model: Select
Gemini 2.5 ProorGemini 3 Pro - Region:
asia-northeast1(Japan) recommended
- Agent Name: e.g.,
Setting Agent Instructions (System Prompt)
Basic Prompt Configuration
In Console UI, enter the following sections:
Agent Role:
You are a customer support agent. Based on the knowledge base,
provide answers to user questions.
Behavior Guidelines:
1. First, understand user intent
2. Search for relevant documents
3. Provide only reliable information
4. Suggest escalation to human agent when unable to answer
Language: English
Tone: Professional and helpful
Dynamic Prompt Setup with Python
from google.cloud import aiplatform
def create_agent_with_custom_prompt(project_id, region, agent_name, prompt_text):
"""Create agent with custom system prompt"""
client = aiplatform.gapic.v1.AgentsClient(
client_options={"api_endpoint": f"{region}-aiplatform.googleapis.com"}
)
location = client.common_location_path(project_id, region)
# Agent configuration
agent = {
"display_name": agent_name,
"description": "Custom Gemini Agent",
"system_instruction": {
"parts": [{"text": prompt_text}]
},
"model": "gemini-2.5-pro"
}
request = {
"parent": location,
"agent": agent
}
response = client.create_agent(request)
return response
# Usage example
prompt = """You are a technical support agent.
Diagnose user technical issues and provide step-by-step solutions."""
agent = create_agent_with_custom_prompt(
project_id="my-project",
region="us-central1",
agent_name="technical-support",
prompt_text=prompt
)Datastore Integration
Cloud Storage Integration
-
Create Knowledge Base:
- In Agent Builder → Datastores
- Click Create Datastore → Cloud Storage
- Specify GCS bucket path (e.g.,
gs://my-knowledge-base/docs)
-
Prepare Documents:
# Upload documents
gsutil cp -r ./documents/* gs://my-knowledge-base/docs/- Configure Search:
- Search Type: Hybrid (keyword + semantic)
- Chunk Size: 1000 tokens
- Overlap: 200 tokens
BigQuery Integration
-- Example BigQuery table
CREATE TABLE `my-project.agent_data.products` (
product_id STRING,
product_name STRING,
description STRING,
price FLOAT64,
stock_quantity INT64,
created_at TIMESTAMP
);
-- Insert sample data
INSERT INTO `my-project.agent_data.products` VALUES
('PROD001', 'Python Basics Book', 'Python beginner guide', 28.00, 150, CURRENT_TIMESTAMP()),
('PROD002', 'API Design Guide', 'REST API best practices', 35.00, 80, CURRENT_TIMESTAMP());In Agent Builder, specify BigQuery datasource:
- Path:
projects/my-project/datasets/agent_data/tables/products - Query Type: Auto-generated (LLM dynamically generates queries)
Website Crawling
-
Datastore Settings:
- Select Website
- Enter crawl target URL (e.g.,
https://docs.example.com) - Crawl depth: 3 levels
-
Update Schedule:
- Auto-update: Daily at 2 AM
Defining Custom Tools
Cloud Functions Integration
# Cloud Functions: product_lookup.py
import functions_framework
import json
from google.cloud import bigquery
client = bigquery.Client()
@functions_framework.http
def lookup_product(request):
"""Look up product information"""
request_json = request.get_json()
product_id = request_json.get('product_id')
if not product_id:
return json.dumps({
"status": "error",
"message": "product_id is required"
}), 400
# BigQuery query
query = f"""
SELECT
product_id,
product_name,
description,
price,
stock_quantity
FROM `my-project.agent_data.products`
WHERE product_id = '{product_id}'
LIMIT 1
"""
results = list(client.query(query).result())
if results:
product = results[0]
return json.dumps({
"status": "success",
"product": {
"id": product['product_id'],
"name": product['product_name'],
"description": product['description'],
"price": float(product['price']),
"stock": int(product['stock_quantity'])
}
}), 200
else:
return json.dumps({
"status": "not_found",
"message": f"Product {product_id} not found"
}), 404
# Deploy
# gcloud functions deploy lookup_product \
# --runtime python311 \
# --trigger-http \
# --allow-unauthenticatedTool Definition in Agent Builder UI
- Click Add Tool
- Select REST API
- Enter configuration:
{
"name": "product_lookup",
"description": "Get product information by product ID",
"endpoint": "https://REGION-my-project.cloudfunctions.net/lookup_product",
"method": "POST",
"parameters": [
{
"name": "product_id",
"type": "string",
"description": "Product ID (e.g., PROD001)",
"required": true
}
],
"response_schema": {
"type": "object",
"properties": {
"status": {"type": "string"},
"product": {
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"},
"price": {"type": "number"},
"stock": {"type": "integer"}
}
}
}
}
}Testing in Playground
Basic Testing
- Open "Playground" panel on the right side of Agent Builder UI
- Enter test message:
Tell me about PROD001 - Click Send
- Review agent response
Test Cases
Query: Show me products under $30
Expected:
- Query BigQuery
- Search matching products
- Display in table format
Query: Which products have stock > 100?
Expected:
- Search multiple products
- Comparative analysis
- Display as list
Deployment to API Endpoint
Manual Deployment
- Click Deploy in Agent Builder UI
- Select deployment method:
- API Endpoint: Publish as REST API
- Chat Application: Vertex AI chat widget
- Slack: Integrate with Slack workspace
Deploy to Cloud Run
# Get agent ID
AGENT_ID="projects/my-project/locations/us-central1/agents/abc123"
# Deploy to Cloud Run
gcloud run deploy my-agent \
--image gcr.io/cloud-ai-solutions/agent-runtime:latest \
--environment-variables AGENT_ID=$AGENT_ID \
--region us-central1 \
--allow-unauthenticatedCalling API from Python
REST API Client
import requests
class AgentAPIClient:
"""Vertex AI Agent API client"""
def __init__(self, endpoint_url, api_key):
self.endpoint = endpoint_url
self.api_key = api_key
def send_message(self, user_message, session_id=None):
"""Send message to agent"""
headers = {
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json"
}
payload = {
"user_input": user_message,
"session_id": session_id or "default-session"
}
response = requests.post(
f"{self.endpoint}/chat",
headers=headers,
json=payload
)
if response.status_code == 200:
return response.json()
else:
raise Exception(f"API Error: {response.status_code}")
def get_session_history(self, session_id):
"""Get session conversation history"""
headers = {
"Authorization": f"Bearer {self.api_key}"
}
response = requests.get(
f"{self.endpoint}/sessions/{session_id}/history",
headers=headers
)
return response.json() if response.status_code == 200 else []
# Usage example
client = AgentAPIClient(
endpoint_url="https://REGION-my-project.run.app",
api_key="your-api-key"
)
# Send message
response = client.send_message(
user_message="Compare prices of PROD001 and PROD002",
session_id="user-123"
)
print("Agent response:", response.get("response"))
print("Tools used:", response.get("tools_used", []))
# Check session history
history = client.get_session_history("user-123")
for msg in history:
print(f"{msg['role']}: {msg['content']}")Monitoring and Analytics
Cloud Logging
# View logs
gcloud logging read \
"resource.type=cloud_run_revision AND \
resource.labels.service_name=my-agent" \
--limit 50
# Filter for errors only
gcloud logging read \
"severity=ERROR AND resource.type=cloud_run_revision" \
--limit 20Python Log Analysis
from google.cloud import logging as cloud_logging
from datetime import datetime, timedelta
def analyze_agent_usage(project_id, hours=24):
"""Analyze agent usage statistics"""
logging_client = cloud_logging.Client(project=project_id)
# Get logs from last 24 hours
start_time = datetime.utcnow() - timedelta(hours=hours)
filter_str = f"""
timestamp >= "{start_time.isoformat()}Z" AND
resource.type="cloud_run_revision" AND
jsonPayload.agent_id="{project_id}"
"""
entries = logging_client.list_entries(filter_=filter_str)
stats = {
"total_messages": 0,
"successful_queries": 0,
"failed_queries": 0,
"average_response_time": 0,
"tools_used": {}
}
response_times = []
for entry in entries:
payload = entry.payload
stats["total_messages"] += 1
if payload.get("status") == "success":
stats["successful_queries"] += 1
else:
stats["failed_queries"] += 1
if "response_time_ms" in payload:
response_times.append(payload["response_time_ms"])
for tool in payload.get("tools_used", []):
stats["tools_used"][tool] = stats["tools_used"].get(tool, 0) + 1
if response_times:
stats["average_response_time"] = sum(response_times) / len(response_times)
return stats
# Usage example
usage = analyze_agent_usage("my-project")
print(f"Total messages: {usage['total_messages']}")
print(f"Success: {usage['successful_queries']}, Failed: {usage['failed_queries']}")
print(f"Avg response time: {usage['average_response_time']:.2f}ms")
print(f"Tools used: {usage['tools_used']}")Best Practices
1. Phased Implementation
Phase 1: Minimal Setup
- Simple system prompt
- Single datasource
- Basic testing
Phase 2: Feature Expansion
- Multiple datasources
- Custom tools
- Comprehensive testing
Phase 3: Production
- Monitoring/logging
- Performance optimization
- Security hardening
2. Security Configuration
# Minimize service account permissions
gcloud iam roles create agent-runtime-role \
--permissions=bigquery.dataEditor,storage.objectViewer,run.invoker
# Encrypt conversation history with CMEK
gcloud firestore databases create \
--database-type=firestore-native \
--cmek-config=projects/my-project/locations/global/keyRings/my-keyring/cryptoKeys/my-keyLooking back
Vertex AI Agent Builder enables construction of:
- Customer Support: FAQ-based automated responses
- Sales Support: CRM data integration
- Technical Support: Knowledge base search
- Data Analysis: Automated BigQuery analysis
The no-code UI dramatically improves development efficiency while delivering enterprise-grade functionality.