Skip to content

Latest commit

 

History

History
431 lines (319 loc) · 10.3 KB

File metadata and controls

431 lines (319 loc) · 10.3 KB

🚀 Vertex AI Agent Engine Deployment Guide

Complete guide to deploy ActualCode multi-agent system to Google Cloud's Vertex AI Agent Engine for production use.


🎯 Why Deploy to Agent Engine?

According to Vertex AI Agent Engine documentation, Agent Engine provides:

Production Runtime: Scalable, managed infrastructure for AI agents
A2A Protocol Support: Native support for Agent-to-Agent communication
Enterprise Security: CMEK, VPC Service Controls, HIPAA compliance
Sessions & Memory: Built-in session management and Memory Bank
Monitoring: Integrated logging, tracing, and monitoring
Multi-Region: Available in 13+ regions globally

For Hackathon: This demonstrates production-ready, enterprise-grade deployment!


📋 Prerequisites

1. Google Cloud Setup

# Set project
export GOOGLE_CLOUD_PROJECT="true-ability-473715-b4"
export REGION="us-central1"

# Verify project
gcloud config set project $GOOGLE_CLOUD_PROJECT
gcloud config set compute/region $REGION

2. Enable Required APIs

# Enable Vertex AI Agent Engine API
gcloud services enable aiplatform.googleapis.com
gcloud services enable agent-engine.googleapis.com
gcloud services enable storage.googleapis.com
gcloud services enable artifactregistry.googleapis.com

3. Create Storage Bucket

# Create staging bucket for Agent Engine
gsutil mb -p $GOOGLE_CLOUD_PROJECT -l $REGION \
  gs://${GOOGLE_CLOUD_PROJECT}-agent-engine

# Verify
gsutil ls gs://${GOOGLE_CLOUD_PROJECT}-agent-engine

4. Install Agent Engine SDK

# Activate virtual environment
source venv/bin/activate

# Install Vertex AI with Agent Engine support
pip install google-cloud-aiplatform[agent-engine]>=1.112.0
pip install google-cloud-agent-engine

🔧 Deployment Steps

Step 1: Prepare Deployment Configuration

# Run deployment preparation script
python3 deploy_agent_engine.py

This generates:

  • agent_engine_config_TIMESTAMP.json - Complete agent configuration
  • Deployment instructions
  • Agent specifications

Step 2: Package Your Application

Create deployment/ directory:

mkdir -p deployment

deployment/main.py:

"""
ActualCode Agent Engine Entry Point
"""

from orchestrator import AssessmentOrchestrator
import asyncio

# Agent Engine will call this
async def run_assessment(request):
    """
    Entry point for Vertex AI Agent Engine
    
    Args:
        request: Agent Engine request with:
            - repo_url: GitHub repository URL
            - difficulty: easy/medium/hard/expert
            - problem_type: feature/bug-fix/refactor/optimization
            
    Returns:
        Complete assessment with problem and validation
    """
    
    orchestrator = AssessmentOrchestrator()
    
    result = await orchestrator.generate_assessment(
        github_repo_url=request.get('repo_url'),
        difficulty=request.get('difficulty', 'medium'),
        problem_type=request.get('problem_type', 'feature'),
        time_limit=request.get('time_limit', 180)
    )
    
    return result


# For local testing
if __name__ == "__main__":
    test_request = {
        'repo_url': 'https://github.com/google-gemini/example-chat-app',
        'difficulty': 'medium',
        'problem_type': 'feature'
    }
    
    result = asyncio.run(run_assessment(test_request))
    print(result)

deployment/requirements.txt:

# Core dependencies
google-cloud-aiplatform[agent-engine]>=1.112.0
google-generativeai>=0.3.0
vertexai>=1.0.0
aiohttp>=3.12.0
python-dotenv>=1.0.0
structlog>=23.1.0

Step 3: Deploy to Agent Engine

Option A: Using gcloud CLI

# Deploy the agent
gcloud ai agent-engine deploy \
  --display-name="ActualCode Multi-Agent System" \
  --source="./deployment" \
  --entry-point="main.run_assessment" \
  --config="agent_engine_config_TIMESTAMP.json" \
  --region=$REGION \
  --project=$GOOGLE_CLOUD_PROJECT

Option B: Using Python SDK

Create deploy.py:

from google.cloud import aiplatform
from google.cloud.aiplatform import agent_engine
import os

PROJECT_ID = os.getenv('GOOGLE_CLOUD_PROJECT')
REGION = os.getenv('REGION', 'us-central1')

# Initialize
aiplatform.init(project=PROJECT_ID, location=REGION)

# Deploy agent
agent = agent_engine.Agent.create(
    display_name="ActualCode Multi-Agent System",
    description="7-agent collaborative system for code assessment generation",
    source="./deployment",
    requirements="deployment/requirements.txt",
    entry_point="main.run_assessment",
    environment_variables={
        "GITHUB_TOKEN": os.getenv("GITHUB_TOKEN"),
        "GOOGLE_CLOUD_PROJECT": PROJECT_ID
    }
)

print(f"✅ Agent deployed successfully!")
print(f"   Agent ID: {agent.resource_name}")
print(f"   Region: {REGION}")

Run:

python deploy.py

Step 4: Test Deployed Agent

Create test_deployed_agent.py:

from google.cloud import aiplatform
from google.cloud.aiplatform import agent_engine
import os

PROJECT_ID = os.getenv('GOOGLE_CLOUD_PROJECT')
REGION = os.getenv('REGION', 'us-central1')

# Initialize
aiplatform.init(project=PROJECT_ID, location=REGION)

# Get deployed agent
agents = agent_engine.Agent.list()
agent = agents[0]  # Get the first agent

print(f"Testing agent: {agent.display_name}")

# Send query
response = agent.query(
    request={
        'repo_url': 'https://github.com/google-gemini/example-chat-app',
        'difficulty': 'medium',
        'problem_type': 'feature'
    }
)

print("\n✅ Assessment Generated!")
print(f"Title: {response['assessment']['problem']['title']}")
print(f"Quality Score: {response['assessment']['validation']['overall_score']}/100")

📊 Monitoring & Management

View Deployed Agents

# List all agents
gcloud ai agent-engine list \
  --region=$REGION \
  --project=$GOOGLE_CLOUD_PROJECT

# Get agent details
gcloud ai agent-engine describe AGENT_ID \
  --region=$REGION \
  --project=$GOOGLE_CLOUD_PROJECT

View Logs

# View agent logs
gcloud logging read \
  "resource.type=aiplatform.googleapis.com/Agent" \
  --limit=50 \
  --project=$GOOGLE_CLOUD_PROJECT

Monitor Performance

Access Cloud Console:

https://console.cloud.google.com/ai/platform/agents?project=YOUR_PROJECT

🎯 For Hackathon Judges

Deployment Highlights

Production Features:

  • ✅ Deployed on Vertex AI Agent Engine (Google Cloud)
  • ✅ 7 specialized agents with A2A protocol
  • ✅ Gemini 2.5 Pro & Flash models
  • ✅ Enterprise security (CMEK, VPC-SC)
  • ✅ Auto-scaling runtime
  • ✅ Built-in monitoring & logging

Regions: Supports 13+ regions globally (us-central1, europe-west1, asia-southeast1, etc.)

Compliance: HIPAA-ready, CMEK-enabled, VPC Service Controls

Demo Script

# Show deployed agent
from google.cloud.aiplatform import agent_engine

agents = agent_engine.Agent.list()
print(f"Deployed: {agents[0].display_name}")
print(f"A2A Protocol: Enabled")
print(f"Agents: 7 collaborative agents")

# Run live demo
response = agents[0].query({
    'repo_url': 'https://github.com/vercel/next.js',
    'difficulty': 'hard'
})

print(f"Generated in: {response['metadata']['processing_time']:.2f}s")
print(f"Quality: {response['assessment']['validation']['overall_score']}/100")

🔒 Security Features

1. Customer-Managed Encryption Keys (CMEK)

# Create encryption key
gcloud kms keyrings create agent-engine-keyring \
  --location=$REGION

gcloud kms keys create agent-engine-key \
  --keyring=agent-engine-keyring \
  --location=$REGION \
  --purpose=encryption

# Deploy with CMEK
gcloud ai agent-engine deploy \
  --kms-key-name="projects/$GOOGLE_CLOUD_PROJECT/locations/$REGION/keyRings/agent-engine-keyring/cryptoKeys/agent-engine-key" \
  ...

2. VPC Service Controls

Enable VPC-SC for data exfiltration protection:

# Create service perimeter
gcloud access-context-manager perimeters create agent-engine-perimeter \
  --title="Agent Engine Perimeter" \
  --resources=projects/$PROJECT_NUMBER \
  --restricted-services=aiplatform.googleapis.com,storage.googleapis.com

3. Private Service Connect

# Create PSC interface
gcloud ai agent-engine deploy \
  --private-service-connect-config=ENABLED \
  ...

💰 Pricing

Vertex AI Agent Engine pricing (as of documentation):

  • Agent Runtime: $0.00X per agent hour
  • Gemini 2.5 Pro: Input $X/1M tokens, Output $Y/1M tokens
  • Gemini 2.5 Flash: Input $X/1M tokens, Output $Y/1M tokens
  • Storage: Standard Cloud Storage pricing

See: https://cloud.google.com/vertex-ai/pricing


🆘 Troubleshooting

Issue: "Permission Denied"

# Grant necessary permissions
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT \
  --member="serviceAccount:YOUR_SERVICE_ACCOUNT" \
  --role="roles/aiplatform.admin"

Issue: "Region Not Supported"

Supported regions:

  • us-central1, us-east4, us-west1
  • europe-west1, europe-west2, europe-west3, europe-west4
  • asia-east1, asia-northeast1, asia-south1, asia-southeast1

Issue: "Quota Exceeded"

# Check quotas
gcloud compute project-info describe --project=$GOOGLE_CLOUD_PROJECT

# Request increase
gcloud alpha services quota update \
  --service=aiplatform.googleapis.com \
  --consumer=projects/$GOOGLE_CLOUD_PROJECT \
  --metric=aiplatform.googleapis.com/agent_engine_requests \
  --value=1000

📚 Additional Resources


✅ Deployment Checklist

  • Google Cloud project configured
  • APIs enabled (aiplatform, agent-engine, storage)
  • Staging bucket created
  • Agent Engine SDK installed
  • Configuration generated (deploy_agent_engine.py)
  • Application packaged (deployment/)
  • Agent deployed (gcloud or Python SDK)
  • Deployment tested (test_deployed_agent.py)
  • Monitoring configured
  • Security features enabled (CMEK, VPC-SC)
  • Demo prepared for judges

Ready for Production! 🚀

Your multi-agent system is now deployed on Google Cloud's Vertex AI Agent Engine!