forked from muratcankoylan/actual_code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_agent_engine.py
More file actions
executable file
·324 lines (272 loc) · 10.8 KB
/
Copy pathdeploy_agent_engine.py
File metadata and controls
executable file
·324 lines (272 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#!/usr/bin/env python3
"""
Deploy ActualCode Multi-Agent System to Vertex AI Agent Engine
This script deploys all 7 agents to Google Cloud's Agent Engine Runtime,
showcasing production-ready deployment for hackathon judges.
"""
import os
import json
from google.cloud import aiplatform
from datetime import datetime
# Configuration
PROJECT_ID = os.getenv('GOOGLE_CLOUD_PROJECT', 'true-ability-473715-b4')
REGION = os.getenv('REGION', 'us-central1')
STAGING_BUCKET = f"gs://{PROJECT_ID}-agent-engine"
print(f"""
╔═══════════════════════════════════════════════════════════════════╗
║ ActualCode - Vertex AI Agent Engine Deployment ║
║ Multi-Agent System Deployment ║
╚═══════════════════════════════════════════════════════════════════╝
Project ID: {PROJECT_ID}
Region: {REGION}
Staging Bucket: {STAGING_BUCKET}
""")
# Initialize Vertex AI
aiplatform.init(project=PROJECT_ID, location=REGION, staging_bucket=STAGING_BUCKET)
def create_agent_config():
"""Create agent configuration for deployment"""
agent_config = {
"display_name": "ActualCode Multi-Agent System",
"description": "7-agent collaborative system for code assessment generation using A2A protocol",
"agents": [
{
"name": "github_scanner",
"display_name": "GitHub Scanner Agent",
"model": "gemini-2.5-flash",
"tools": ["github_mcp"],
"system_instruction": """You are a GitHub repository scanner.
Retrieve comprehensive data about repositories including:
- Repository metadata (name, description, language, stars)
- File structure and codebase overview
- Recent issues (last 20)
- Recent pull requests (last 20)
- Recent commits (last 50)
- README content
- Dependencies
Use GitHub MCP tools efficiently. Output structured JSON.""",
"temperature": 0.1,
"a2a_capabilities": {
"exposes": ["scan_repository", "get_repo_metadata", "get_issues", "get_pull_requests"],
"protocol_version": "1.0"
}
},
{
"name": "code_analyzer",
"display_name": "Code Analyzer Agent",
"model": "gemini-2.5-pro",
"system_instruction": """Analyze codebase architecture, patterns, and complexity.
Focus on:
1. Architectural patterns (MVC, microservices, event-driven, etc.)
2. Code quality metrics, test coverage, documentation
3. Technical debt: outdated dependencies, code smells, refactoring needs
4. Feature opportunities: missing functionality, incomplete features
Provide structured analysis with actionable insights.""",
"temperature": 0.3,
"a2a_capabilities": {
"exposes": ["analyze_architecture", "assess_quality"],
"consumes": ["scan_repository"],
"protocol_version": "1.0"
}
},
{
"name": "pr_analyzer",
"display_name": "PR Analyzer Agent",
"model": "gemini-2.5-flash",
"system_instruction": """Analyze pull request patterns to extract development insights.
Identify:
- Common change types and workflows
- Frequent files being modified
- Recent features and in-progress work
- Common bugs and recurring issues
- Performance improvements
Suggest problem opportunities based on PR trends.""",
"temperature": 0.4,
"a2a_capabilities": {
"exposes": ["analyze_prs"],
"consumes": ["scan_repository"],
"protocol_version": "1.0"
}
},
{
"name": "issue_analyzer",
"display_name": "Issue Analyzer Agent",
"model": "gemini-2.5-flash",
"system_instruction": """Analyze GitHub issues to extract problem patterns and feature requests.
Categorize:
- Bugs, features, enhancements
- Priority signals (community upvotes, maintainer responses)
- Common complaints and requested features
Suggest coding problems based on user pain points.""",
"temperature": 0.4,
"a2a_capabilities": {
"exposes": ["analyze_issues"],
"consumes": ["scan_repository"],
"protocol_version": "1.0"
}
},
{
"name": "dependency_analyzer",
"display_name": "Dependency Analyzer Agent",
"model": "gemini-2.5-flash",
"system_instruction": """Analyze repository dependencies and tech stack.
Identify:
- Frameworks, libraries, runtime environment
- Dependency health: outdated, vulnerable, well-maintained
- Integration opportunities: underutilized libraries, missing integrations
Provide actionable recommendations.""",
"temperature": 0.3,
"a2a_capabilities": {
"exposes": ["analyze_dependencies"],
"consumes": ["scan_repository"],
"protocol_version": "1.0"
}
},
{
"name": "problem_creator",
"display_name": "Problem Creator Agent",
"model": "gemini-2.5-pro",
"system_instruction": """Create realistic, implementable coding problems based on repository analysis.
CRITICAL REQUIREMENTS:
- Align with repository's technology and patterns
- Completable in specified time limit
- Self-contained (no private repo access needed)
- Clear, testable requirements
- Realistic business context
- Helpful starter code (structure, not solution)
- Appropriate hints
Generate comprehensive problem specifications.""",
"temperature": 0.7,
"a2a_capabilities": {
"exposes": ["create_problem"],
"consumes": ["analyze_architecture", "analyze_prs", "analyze_issues", "analyze_dependencies"],
"protocol_version": "1.0"
}
},
{
"name": "qa_validator",
"display_name": "QA Validator Agent",
"model": "gemini-2.5-flash",
"system_instruction": """Validate coding problem quality across 4 dimensions:
1. Feasibility (0-100):
- Completable in time limit
- All context provided
- No private repo access needed
- Functional starter code
2. Quality (0-100):
- Clear problem description
- Specific, testable requirements
- Objective acceptance criteria
- Appropriate hints
3. Technical (0-100):
- Uses repository's tech stack
- Patterns match repository style
- Complexity matches difficulty
- Correct code examples
4. Educational (0-100):
- Tests relevant skills
- Appropriate difficulty
- Clear learning objectives
- Non-trivial problem
Overall score must be 85+ to approve. Provide detailed feedback.""",
"temperature": 0.3,
"a2a_capabilities": {
"exposes": ["validate_problem"],
"consumes": ["create_problem"],
"protocol_version": "1.0"
}
}
],
"orchestration": {
"pattern": "sequential_with_loops",
"loops": 3,
"parallel_agents": ["code_analyzer", "pr_analyzer", "issue_analyzer", "dependency_analyzer"],
"improvement_loop": {
"enabled": True,
"max_iterations": 2,
"threshold_score": 85
}
},
"a2a_config": {
"protocol_version": "1.0",
"authentication": "oauth2",
"encryption": "tls"
}
}
return agent_config
def save_deployment_config(config):
"""Save deployment configuration"""
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
config_file = f"agent_engine_config_{timestamp}.json"
with open(config_file, 'w') as f:
json.dump(config, f, indent=2)
print(f"✅ Deployment configuration saved: {config_file}")
return config_file
def deploy_to_agent_engine():
"""Deploy agents to Vertex AI Agent Engine"""
print("🚀 Starting deployment to Vertex AI Agent Engine...\n")
# Create configuration
config = create_agent_config()
config_file = save_deployment_config(config)
print(f"""
📋 Deployment Configuration:
- Total Agents: {len(config['agents'])}
- Orchestration: {config['orchestration']['pattern']}
- Analysis Loops: {config['orchestration']['loops']}
- A2A Protocol: {config['a2a_config']['protocol_version']}
Agent Details:
""")
for agent in config['agents']:
print(f" • {agent['display_name']}")
print(f" Model: {agent['model']}")
print(f" Temperature: {agent['temperature']}")
if 'tools' in agent:
print(f" Tools: {', '.join(agent['tools'])}")
print()
print("\n" + "="*70)
print("NEXT STEPS FOR DEPLOYMENT:")
print("="*70)
print("""
1. Install Vertex AI Agent Engine SDK:
pip install google-cloud-aiplatform[agent-engine]
2. Package your agents:
Create a requirements.txt with dependencies
Package orchestrator.py and agents/ directory
3. Deploy using gcloud CLI:
gcloud ai agent-engine deploy \\
--config={config_file} \\
--region={REGION} \\
--project={PROJECT_ID}
4. Or use the Vertex AI SDK:
from google.cloud.aiplatform import agent_engine
agent = agent_engine.Agent.create(
display_name="ActualCode Multi-Agent System",
source="./",
requirements="requirements.txt",
config=config
)
5. Test the deployed agent:
python test_deployed_agent.py
📚 Full deployment guide: See DEPLOYMENT_GUIDE.md
""".format(config_file=config_file, REGION=REGION, PROJECT_ID=PROJECT_ID))
return config
if __name__ == "__main__":
try:
config = deploy_to_agent_engine()
print("\n" + "="*70)
print("✅ DEPLOYMENT PREPARATION COMPLETE!")
print("="*70)
print(f"""
Your multi-agent system is ready for Vertex AI Agent Engine deployment!
Key Highlights for Judges:
✅ 7 specialized AI agents
✅ A2A protocol for agent communication
✅ Gemini 2.5 Pro & Flash models
✅ Production-ready on Google Cloud
✅ Enterprise security features
✅ Scalable architecture
Next: Follow the deployment steps above to deploy to Agent Engine.
""")
except Exception as e:
print(f"\n❌ Error: {e}")
import traceback
traceback.print_exc()