Repository navigation
Expand file tree
/
Copy pathagent.py
More file actions
854 lines (767 loc) · 40.9 KB
/
Copy pathagent.py
File metadata and controls
854 lines (767 loc) · 40.9 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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Cache Analysis Research Assistant Agent.
This agent is designed to test ADK context caching features with a large prompt
that exceeds 2048 tokens to meet both implicit and explicit cache requirements.
"""
import random
import time
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from dotenv import load_dotenv
from google.adk import Agent
from google.adk.agents.context_cache_config import ContextCacheConfig
from google.adk.apps.app import App
# Load environment variables from .env file
load_dotenv()
def analyze_data_patterns(
data: str, analysis_type: str = "comprehensive"
) -> Dict[str, Any]:
"""Analyze data patterns and provide insights.
This tool performs comprehensive data analysis including statistical analysis,
trend identification, anomaly detection, correlation analysis, and predictive
modeling. It can handle various data formats including CSV, JSON, XML, and
plain text data structures.
Args:
data: The input data to analyze. Can be structured (JSON, CSV) or
unstructured text data. For structured data, include column headers
and ensure proper formatting. For time series data, include
timestamps in ISO format.
analysis_type: Type of analysis to perform. Options include:
- "comprehensive": Full statistical and trend analysis
- "statistical": Basic statistical measures only
- "trends": Time series and trend analysis
- "anomalies": Outlier and anomaly detection
- "correlations": Correlation and relationship analysis
- "predictive": Forecasting and prediction models
Returns:
Dictionary containing analysis results with the following structure:
{
"summary": "High-level summary of findings",
"statistics": {...}, # Statistical measures
"trends": {...}, # Trend analysis results
"anomalies": [...], # List of detected anomalies
"correlations": {...}, # Correlation matrix and relationships
"predictions": {...}, # Forecasting results if applicable
"recommendations": [...] # Actionable insights and recommendations
}
"""
# Simulate analysis processing time
time.sleep(0.1)
return {
"summary": f"Analyzed {len(data)} characters of {analysis_type} data",
"statistics": {
"data_points": len(data.split()),
"analysis_type": analysis_type,
"processing_time": "0.1 seconds",
},
"recommendations": [
"Continue monitoring data trends",
"Consider additional data sources for correlation analysis",
],
}
def research_literature(
topic: str,
sources: Optional[List[str]] = None,
depth: str = "comprehensive",
time_range: str = "recent",
) -> Dict[str, Any]:
"""Research academic and professional literature on specified topics.
This tool performs comprehensive literature research across multiple academic
databases, professional journals, conference proceedings, and industry reports.
It can analyze research trends, identify key authors and institutions, extract
methodological approaches, and synthesize findings across multiple sources.
The tool supports various research methodologies including systematic reviews,
meta-analyses, bibliometric analysis, and citation network analysis. It can
identify research gaps, emerging trends, and future research directions in
the specified field of study.
Args:
topic: The research topic or query. Can be specific (e.g., "context caching
in large language models") or broad (e.g., "machine learning optimization").
Use specific keywords and phrases for better results. Boolean operators
(AND, OR, NOT) are supported for complex queries.
sources: List of preferred sources to search. Options include:
- "academic": Peer-reviewed academic journals and papers
- "conference": Conference proceedings and presentations
- "industry": Industry reports and white papers
- "patents": Patent databases and intellectual property
- "preprints": ArXiv, bioRxiv and other preprint servers
- "books": Academic and professional books
depth: Research depth level:
- "comprehensive": Full literature review with detailed analysis
- "focused": Targeted search on specific aspects
- "overview": High-level survey of the field
- "technical": Deep technical implementation details
time_range: Time range for literature search:
- "recent": Last 2 years
- "current": Last 5 years
- "historical": All available time periods
- "decade": Last 10 years
Returns:
Dictionary containing research results:
{
"summary": "Executive summary of findings",
"key_papers": [...], # Most relevant papers found
"authors": [...], # Key researchers in the field
"institutions": [...], # Leading research institutions
"trends": {...}, # Research trends and evolution
"methodologies": [...], # Common research approaches
"gaps": [...], # Identified research gaps
"citations": {...}, # Citation network analysis
"recommendations": [...] # Future research directions
}
"""
if sources is None:
sources = ["academic", "conference", "industry"]
# Simulate research processing
time.sleep(0.2)
return {
"summary": f"Conducted {depth} literature research on '{topic}'",
"key_papers": [
f"Recent advances in {topic.lower()}: A systematic review",
f"Methodological approaches to {topic.lower()} optimization",
f"Future directions in {topic.lower()} research",
],
"trends": {
"emerging_topics": [f"{topic} optimization", f"{topic} scalability"],
"methodology_trends": [
"experimental validation",
"theoretical analysis",
],
},
"recommendations": [
f"Focus on practical applications of {topic}",
"Consider interdisciplinary approaches",
"Investigate scalability challenges",
],
}
def generate_test_scenarios(
system_type: str,
complexity: str = "medium",
coverage: Optional[List[str]] = None,
constraints: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]:
"""Generate comprehensive test scenarios for system validation.
This tool creates detailed test scenarios, test cases, and validation protocols
for various types of systems including software applications, AI models,
distributed systems, and hardware components. It supports multiple testing
methodologies including unit testing, integration testing, performance testing,
security testing, and user acceptance testing.
The tool can generate both positive and negative test cases, edge cases,
boundary conditions, stress tests, and failure scenarios. It incorporates
industry best practices and testing frameworks to ensure comprehensive
coverage and reliable validation results.
Args:
system_type: Type of system to test. Supported types include:
- "software": Software applications and services
- "ai_model": Machine learning and AI model testing
- "distributed": Distributed systems and microservices
- "database": Database systems and data integrity
- "api": API endpoints and web services
- "hardware": Hardware components and embedded systems
- "security": Security systems and protocols
complexity: Test complexity level:
- "basic": Essential functionality tests only
- "medium": Standard test suite with common scenarios
- "advanced": Comprehensive testing with edge cases
- "expert": Exhaustive testing with stress and chaos scenarios
coverage: List of testing areas to cover:
- "functionality": Core feature testing
- "performance": Speed, throughput, and scalability
- "security": Authentication, authorization, data protection
- "usability": User experience and interface testing
- "compatibility": Cross-platform and integration testing
- "reliability": Fault tolerance and recovery testing
constraints: Testing constraints and requirements:
{
"time_limit": "Maximum testing duration",
"resources": "Available testing resources",
"environment": "Testing environment specifications",
"compliance": "Regulatory or standard requirements"
}
Returns:
Dictionary containing generated test scenarios:
{
"overview": "Test plan summary and objectives",
"scenarios": [...], # Detailed test scenarios
"test_cases": [...], # Individual test cases
"edge_cases": [...], # Boundary and edge conditions
"performance_tests": [...], # Performance validation tests
"security_tests": [...], # Security and vulnerability tests
"automation": {...}, # Test automation recommendations
"metrics": {...}, # Success criteria and metrics
"schedule": {...} # Recommended testing timeline
}
"""
if coverage is None:
coverage = ["functionality", "performance", "security"]
if constraints is None:
constraints = {"time_limit": "standard", "resources": "adequate"}
# Simulate test generation
time.sleep(0.15)
num_scenarios = {"basic": 5, "medium": 10, "advanced": 20, "expert": 35}.get(
complexity, 10
)
return {
"overview": (
f"Generated {num_scenarios} test scenarios for {system_type} system"
),
"scenarios": [
f"Test scenario {i+1}:"
f" {system_type} {coverage[i % len(coverage)]} validation"
for i in range(num_scenarios)
],
"test_cases": [
f"Verify {system_type} handles normal operations",
f"Test {system_type} error handling and recovery",
f"Validate {system_type} performance under load",
],
"metrics": {
"coverage_target": f"{75 + complexity.index(complexity) * 5}%",
"success_criteria": "All critical tests pass",
"performance_benchmark": f"{system_type} specific benchmarks",
},
}
def optimize_system_performance(
system_type: str,
current_metrics: Dict[str, Any],
target_improvements: Dict[str, Any],
constraints: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]:
"""Analyze system performance and provide detailed optimization recommendations.
This tool performs comprehensive system performance analysis including bottleneck
identification, resource utilization assessment, scalability planning, and provides
specific optimization strategies tailored to the system type and constraints.
Args:
system_type: Type of system to optimize:
- "web_application": Frontend and backend web services
- "database": Relational, NoSQL, or distributed databases
- "ml_pipeline": Machine learning training and inference systems
- "distributed_cache": Caching layers and distributed memory systems
- "microservices": Service-oriented architectures
- "data_processing": ETL, stream processing, batch systems
- "api_gateway": Request routing and API management systems
current_metrics: Current performance metrics including:
{
"response_time_p95": "95th percentile response time in ms",
"throughput_rps": "Requests per second",
"cpu_utilization": "Average CPU usage percentage",
"memory_usage": "Memory consumption in GB",
"error_rate": "Error percentage",
"availability": "System uptime percentage"
}
target_improvements: Desired performance targets:
{
"response_time_improvement": "Target reduction in response time",
"throughput_increase": "Desired increase in throughput",
"cost_reduction": "Target cost optimization percentage",
"availability_target": "Desired uptime percentage"
}
constraints: Operational constraints:
{
"budget_limit": "Maximum budget for improvements",
"timeline": "Implementation timeline constraints",
"technology_restrictions": "Required or forbidden technologies",
"compliance_requirements": "Security/regulatory constraints"
}
Returns:
Comprehensive optimization analysis:
{
"performance_analysis": {
"bottlenecks_identified": ["Critical performance bottlenecks"],
"root_cause_analysis": "Detailed analysis of performance issues",
"current_vs_target": "Gap analysis between current and target metrics"
},
"optimization_recommendations": {
"infrastructure_changes": ["Hardware/cloud resource recommendations"],
"architecture_improvements": ["System design optimizations"],
"code_optimizations": ["Software-level improvements"],
"configuration_tuning": ["Parameter and setting adjustments"]
},
"implementation_roadmap": {
"phase_1_quick_wins": ["Immediate improvements (0-2 weeks)"],
"phase_2_medium_term": ["Medium-term optimizations (1-3 months)"],
"phase_3_strategic": ["Long-term architectural changes (3-12 months)"]
},
"expected_outcomes": {
"performance_improvements": "Projected performance gains",
"cost_implications": "Expected costs and savings",
"risk_assessment": "Implementation risks and mitigation strategies"
}
}
"""
# Simulate comprehensive performance optimization analysis
optimization_areas = [
"Database query optimization",
"Caching layer enhancement",
"Load balancing improvements",
"Resource scaling strategies",
"Code-level optimizations",
"Infrastructure upgrades",
]
return {
"system_analyzed": system_type,
"optimization_areas": random.sample(
optimization_areas, k=min(4, len(optimization_areas))
),
"performance_score": random.randint(65, 95),
"implementation_complexity": random.choice(["Low", "Medium", "High"]),
"estimated_improvement": f"{random.randint(15, 45)}%",
"recommendations": [
"Implement distributed caching for frequently accessed data",
"Optimize database queries and add strategic indexes",
"Configure auto-scaling based on traffic patterns",
"Implement asynchronous processing for heavy operations",
],
}
def analyze_security_vulnerabilities(
system_components: List[str],
security_scope: str = "comprehensive",
compliance_frameworks: Optional[List[str]] = None,
threat_model: str = "enterprise",
) -> Dict[str, Any]:
"""Perform comprehensive security vulnerability analysis and risk assessment.
This tool conducts detailed security analysis including vulnerability identification,
threat modeling, compliance gap analysis, and provides prioritized remediation
strategies based on risk levels and business impact.
Args:
system_components: List of system components to analyze:
- "web_frontend": User interfaces, SPAs, mobile apps
- "api_endpoints": REST/GraphQL APIs, microservices
- "database_layer": Data storage and access systems
- "authentication": User auth, SSO, identity management
- "data_processing": ETL, analytics, ML pipelines
- "infrastructure": Servers, containers, cloud services
- "network_layer": Load balancers, firewalls, CDNs
security_scope: Analysis depth:
- "basic": Standard vulnerability scanning
- "comprehensive": Full security assessment
- "compliance_focused": Regulatory compliance analysis
- "threat_modeling": Advanced threat analysis
compliance_frameworks: Required compliance standards:
["SOC2", "GDPR", "HIPAA", "PCI-DSS", "ISO27001"]
threat_model: Threat landscape consideration:
- "startup": Basic threat model for early-stage companies
- "enterprise": Corporate threat landscape
- "high_security": Government/financial sector threats
- "public_facing": Internet-exposed systems
Returns:
Security analysis results:
{
"vulnerability_assessment": {
"critical_vulnerabilities": ["High-priority security issues"],
"moderate_risks": ["Medium-priority concerns"],
"informational": ["Low-priority observations"],
"risk_score": "Overall security risk rating (1-10)"
},
"threat_analysis": {
"attack_vectors": ["Potential attack methods"],
"threat_actors": ["Relevant threat actor profiles"],
"attack_likelihood": "Probability assessment",
"potential_impact": "Business impact analysis"
},
"compliance_status": {
"framework_compliance": "Compliance percentage per framework",
"gaps_identified": ["Non-compliant areas"],
"certification_readiness": "Readiness for compliance audits"
},
"remediation_plan": {
"immediate_actions": ["Critical fixes (0-2 weeks)"],
"short_term_improvements": ["Important fixes (1-2 months)"],
"strategic_initiatives": ["Long-term security enhancements"],
"resource_requirements": "Personnel and budget needs"
}
}
"""
# Simulate security vulnerability analysis
vulnerability_types = [
"SQL Injection",
"Cross-Site Scripting (XSS)",
"Authentication Bypass",
"Insecure Direct Object References",
"Security Misconfiguration",
"Sensitive Data Exposure",
"Insufficient Logging",
"CSRF",
]
return {
"components_analyzed": len(system_components),
"critical_vulnerabilities": random.randint(0, 3),
"moderate_risks": random.randint(2, 8),
"overall_security_score": random.randint(6, 9),
"compliance_percentage": random.randint(75, 95),
"top_recommendations": [
"Implement input validation and parameterized queries",
"Enable comprehensive security logging and monitoring",
"Review and update authentication and authorization controls",
"Conduct regular security training for development team",
],
}
def design_scalability_architecture(
current_architecture: str,
expected_growth: Dict[str, Any],
scalability_requirements: Dict[str, Any],
technology_preferences: Optional[List[str]] = None,
) -> Dict[str, Any]:
"""Design comprehensive scalability architecture for anticipated growth.
This tool analyzes current system architecture and designs scalable solutions
to handle projected growth in users, data, traffic, and complexity while
maintaining performance, reliability, and cost-effectiveness.
Args:
current_architecture: Current system architecture type:
- "monolith": Single-tier monolithic application
- "service_oriented": SOA with multiple services
- "microservices": Containerized microservice architecture
- "serverless": Function-as-a-Service architecture
- "hybrid": Mixed architecture patterns
expected_growth: Projected growth metrics:
{
"user_growth_multiplier": "Expected increase in users",
"data_volume_growth": "Projected data storage needs",
"traffic_increase": "Expected traffic growth percentage",
"geographic_expansion": "New regions/markets",
"feature_complexity": "Additional functionality scope"
}
scalability_requirements: Scalability constraints and targets:
{
"performance_sla": "Response time requirements",
"availability_target": "Uptime requirements",
"consistency_model": "Data consistency needs",
"budget_constraints": "Cost limitations",
"deployment_model": "On-premise/cloud preferences"
}
technology_preferences: Preferred or required technologies:
["kubernetes", "aws", "microservices", "nosql", etc.]
Returns:
Scalability architecture design:
{
"architecture_recommendation": {
"target_architecture": "Recommended architecture pattern",
"migration_strategy": "Path from current to target architecture",
"technology_stack": "Recommended technologies and frameworks"
},
"scalability_patterns": {
"horizontal_scaling": "Auto-scaling and load distribution strategies",
"data_partitioning": "Database sharding and data distribution",
"caching_strategy": "Multi-level caching implementation",
"async_processing": "Background job and queue systems"
},
"infrastructure_design": {
"compute_resources": "Server/container resource planning",
"data_storage": "Database and storage architecture",
"network_topology": "CDN, load balancing, and routing",
"monitoring_observability": "Logging, metrics, and alerting"
},
"implementation_phases": {
"foundation_setup": "Core infrastructure preparation",
"service_decomposition": "Breaking down monolithic components",
"data_migration": "Database and storage transitions",
"traffic_migration": "Gradual user traffic transition"
}
}
"""
# Simulate scalability architecture design
architecture_patterns = [
"Event-driven microservices",
"CQRS with Event Sourcing",
"Federated GraphQL architecture",
"Serverless-first design",
"Hybrid cloud architecture",
"Edge-computing integration",
]
return {
"recommended_pattern": random.choice(architecture_patterns),
"scalability_factor": f"{random.randint(5, 50)}x current capacity",
"implementation_timeline": f"{random.randint(6, 18)} months",
"estimated_cost_increase": f"{random.randint(20, 80)}%",
"key_technologies": random.sample(
[
"Kubernetes",
"Docker",
"Redis",
"PostgreSQL",
"MongoDB",
"Apache Kafka",
"Elasticsearch",
"AWS Lambda",
"CloudFront",
],
k=4,
),
"success_metrics": [
"Response time under load",
"Auto-scaling effectiveness",
"Cost per transaction",
"System availability",
],
}
def benchmark_performance(
system_name: str,
metrics: Optional[List[str]] = None,
duration: str = "standard",
load_profile: str = "realistic",
) -> Dict[str, Any]:
"""Perform comprehensive performance benchmarking and analysis.
This tool conducts detailed performance benchmarking across multiple dimensions
including response time, throughput, resource utilization, scalability limits,
and system stability under various load conditions. It supports both synthetic
and realistic workload testing with configurable parameters and monitoring.
The benchmarking process includes baseline establishment, performance profiling,
bottleneck identification, capacity planning, and optimization recommendations.
It can simulate various user patterns, network conditions, and system configurations
to provide comprehensive performance insights.
Args:
system_name: Name or identifier of the system to benchmark. Should be
specific enough to identify the exact system configuration
being tested.
metrics: List of performance metrics to measure:
- "latency": Response time and request processing delays
- "throughput": Requests per second and data processing rates
- "cpu": CPU utilization and processing efficiency
- "memory": Memory usage and allocation patterns
- "disk": Disk I/O performance and storage operations
- "network": Network bandwidth and communication overhead
- "scalability": System behavior under increasing load
- "stability": Long-term performance and reliability
duration: Benchmarking duration:
- "quick": 5-10 minutes for rapid assessment
- "standard": 30-60 minutes for comprehensive testing
- "extended": 2-4 hours for stability and endurance testing
- "continuous": Ongoing monitoring and measurement
load_profile: Type of load pattern to simulate:
- "constant": Steady, consistent load throughout test
- "realistic": Variable load mimicking real usage patterns
- "peak": High-intensity load testing for capacity limits
- "stress": Beyond-capacity testing for failure analysis
- "spike": Sudden load increases to test elasticity
Returns:
Dictionary containing comprehensive benchmark results:
{
"summary": "Performance benchmark executive summary",
"baseline": {...}, # Baseline performance measurements
"results": {...}, # Detailed performance metrics
"bottlenecks": [...], # Identified performance bottlenecks
"scalability": {...}, # Scalability analysis results
"recommendations": [...], # Performance optimization suggestions
"capacity": {...}, # Capacity planning insights
"monitoring": {...} # Ongoing monitoring recommendations
}
"""
if metrics is None:
metrics = ["latency", "throughput", "cpu", "memory"]
# Simulate benchmarking
time.sleep(0.3)
return {
"summary": f"Completed {duration} performance benchmark of {system_name}",
"baseline": {
"avg_latency": f"{random.uniform(50, 200):.2f}ms",
"throughput": f"{random.randint(100, 1000)} requests/sec",
"cpu_usage": f"{random.uniform(20, 80):.1f}%",
},
"results": {
metric: f"Measured {metric} performance within expected ranges"
for metric in metrics
},
"recommendations": [
f"Optimize {system_name} for better {metrics[0]} performance",
f"Consider scaling {system_name} for higher throughput",
"Monitor performance trends over time",
],
}
# Create the cache analysis research assistant agent
cache_analysis_agent = Agent(
name="cache_analysis_assistant",
model="gemini-2.0-flash-001",
description="""
Advanced Research and Analysis Assistant specializing in comprehensive system analysis,
performance benchmarking, literature research, and test scenario generation for
technical systems and AI applications.
""",
instruction="""
You are an expert Research and Analysis Assistant with deep expertise across multiple
technical domains, specializing in comprehensive system analysis, performance optimization,
security assessment, and architectural design. Your role encompasses both strategic planning
and tactical implementation guidance for complex technical systems.
**Core Competencies and Expertise Areas:**
**Data Analysis & Pattern Recognition:**
- Advanced statistical analysis including multivariate analysis, time series forecasting,
regression modeling, and machine learning applications for pattern discovery
- Trend identification across large datasets using statistical process control, anomaly
detection algorithms, and predictive modeling techniques
- Root cause analysis methodologies for complex system behaviors and performance issues
- Data quality assessment and validation frameworks for ensuring analytical integrity
- Visualization design principles for effective communication of analytical findings
- Business intelligence and reporting strategies for different stakeholder audiences
**Academic & Professional Research:**
- Systematic literature reviews following PRISMA guidelines and meta-analysis techniques
- Citation network analysis and research impact assessment using bibliometric methods
- Research gap identification through comprehensive domain mapping and trend analysis
- Synthesis methodologies for integrating findings from diverse research sources
- Research methodology design including experimental design, survey methods, and case studies
- Peer review processes and academic publication strategies for research dissemination
- Industry research integration including white papers, technical reports, and conference proceedings
- Patent landscape analysis and intellectual property research for innovation assessment
**Test Design & Validation:**
- Comprehensive test strategy development following industry frameworks (ISTQB, TMMI, TPI)
- Test automation architecture design including framework selection and implementation strategies
- Quality assurance methodologies encompassing functional, non-functional, and security testing
- Risk-based testing approaches for optimizing test coverage within resource constraints
- Continuous integration and deployment testing strategies for DevOps environments
- Performance testing including load, stress, volume, and endurance testing protocols
- Usability testing methodologies and user experience validation frameworks
- Compliance testing for regulatory requirements across different industries
**Performance Engineering & Optimization:**
- System performance analysis using APM tools, profiling techniques, and monitoring strategies
- Capacity planning methodologies for both current needs and future growth projections
- Scalability assessment including horizontal and vertical scaling strategies
- Resource optimization techniques for compute, memory, storage, and network resources
- Database performance tuning including query optimization, indexing strategies, and partitioning
- Caching strategies implementation across multiple layers (application, database, CDN)
- Load balancing and traffic distribution optimization for high-availability systems
- Performance budgeting and SLA definition for service-level agreements
**Security & Compliance Analysis:**
- Comprehensive security risk assessment including threat modeling and vulnerability analysis
- Security architecture review and design for both defensive and offensive security perspectives
- Compliance framework analysis for standards including SOC2, GDPR, HIPAA, PCI-DSS, ISO27001
- Incident response planning and security monitoring strategy development
- Security testing methodologies including penetration testing and security code review
- Privacy impact assessment and data protection strategy development
- Security training program design for technical and non-technical audiences
- Cybersecurity governance and policy development for organizational security posture
**System Architecture & Design:**
- Distributed systems design including microservices, service mesh, and event-driven architectures
- Cloud architecture design for AWS, Azure, GCP with multi-cloud and hybrid strategies
- Scalability patterns implementation including CQRS, Event Sourcing, and saga patterns
- Database design and data modeling for both relational and NoSQL systems
- API design following REST, GraphQL, and event-driven communication patterns
- Infrastructure as Code (IaC) implementation using Terraform, CloudFormation, and Ansible
- Container orchestration with Kubernetes including service mesh and observability
- DevOps pipeline design encompassing CI/CD, monitoring, logging, and alerting strategies
**Research Methodology Framework:**
**Systematic Approach:**
- Begin every analysis with clear problem definition, success criteria, and scope boundaries
- Establish baseline measurements and define key performance indicators before analysis
- Use structured analytical frameworks appropriate to the domain and problem type
- Apply scientific methods including hypothesis formation, controlled experimentation, and validation
- Implement peer review processes and cross-validation techniques when possible
- Document methodology transparently to enable reproducibility and peer verification
**Information Synthesis:**
- Integrate quantitative data with qualitative insights for comprehensive understanding
- Cross-reference multiple authoritative sources to validate findings and reduce bias
- Identify conflicting information and analyze reasons for discrepancies
- Synthesize complex technical concepts into actionable business recommendations
- Maintain awareness of information currency and source reliability
- Apply critical thinking to distinguish correlation from causation in analytical findings
**Quality Assurance Standards:**
- Implement multi-stage review processes for all analytical outputs
- Use statistical significance testing and confidence intervals where appropriate
- Clearly distinguish between established facts, supported inferences, and speculative conclusions
- Provide uncertainty estimates and risk assessments for all recommendations
- Include limitations analysis and recommendations for additional research or data collection
- Ensure all analysis follows industry best practices and professional standards
**Communication and Reporting Excellence:**
**Audience Adaptation:**
- Tailor communication style to technical level and role of the intended audience
- Provide executive summaries for strategic decision-makers alongside detailed technical analysis
- Use progressive disclosure to present information at appropriate levels of detail
- Include visual elements and structured formats to enhance comprehension
- Anticipate questions and provide preemptive clarification on complex topics
**Documentation Standards:**
- Follow structured reporting templates appropriate to the analysis type
- Include methodology sections that enable reproduction of analytical work
- Provide clear action items with priority levels and implementation timelines
- Include risk assessments and mitigation strategies for all recommendations
- Maintain version control and change tracking for iterative analytical processes
**Tool Utilization Guidelines:**
When users request analysis or research, strategically leverage the available tools:
**For Data Analysis Requests:**
- Use analyze_data_patterns for statistical analysis, trend identification, and pattern discovery
- Apply appropriate statistical methods based on data type, sample size, and research questions
- Provide confidence intervals and statistical significance testing where applicable
- Include data visualization recommendations and interpretation guidance
**For Literature Research:**
- Use research_literature for comprehensive academic and professional literature reviews
- Focus on peer-reviewed sources while including relevant industry reports and white papers
- Provide synthesis of findings with identification of research gaps and conflicting viewpoints
- Include citation analysis and research impact assessment when relevant
**For Testing Strategy:**
- Use generate_test_scenarios for comprehensive test planning and validation protocol design
- Balance test coverage with practical constraints including time, budget, and resource limitations
- Include both functional and non-functional testing considerations
- Provide automation recommendations and implementation guidance
**For Performance Analysis:**
- Use benchmark_performance for detailed performance assessment and optimization analysis
- Include both current performance evaluation and future scalability considerations
- Provide specific, measurable recommendations with expected impact quantification
- Consider cost implications and return on investment for optimization recommendations
**For System Optimization:**
- Use optimize_system_performance for comprehensive system improvement strategies
- Include both technical optimizations and operational process improvements
- Provide phased implementation approaches with quick wins and long-term strategic initiatives
- Consider interdependencies between system components and potential unintended consequences
**For Security Assessment:**
- Use analyze_security_vulnerabilities for comprehensive security risk evaluation
- Include both technical vulnerabilities and procedural/operational security gaps
- Provide risk-prioritized remediation plans with business impact consideration
- Include compliance requirements and regulatory considerations
**For Architecture Design:**
- Use design_scalability_architecture for strategic technical architecture planning
- Consider both current requirements and future growth projections
- Include technology stack recommendations with rationale and trade-off analysis
- Provide migration strategies and implementation roadmaps for architecture transitions
**Professional Standards and Ethics:**
**Analytical Integrity:**
- Maintain objectivity and avoid confirmation bias in all analytical work
- Acknowledge limitations in data, methodology, or analytical scope
- Provide balanced perspectives that consider alternative explanations and interpretations
- Use peer review and validation processes to ensure analytical quality
- Stay current with best practices and methodological advances in relevant domains
**Stakeholder Communication:**
- Provide clear, actionable recommendations that align with organizational capabilities
- Include risk assessments and uncertainty estimates for all strategic recommendations
- Consider implementation feasibility including technical, financial, and organizational constraints
- Offer both immediate tactical improvements and long-term strategic initiatives
- Maintain transparency about analytical processes and potential sources of error
Your ultimate goal is to provide insights that are technically rigorous, strategically sound,
and practically implementable. Every analysis should contribute to improved decision-making
and measurable business outcomes while maintaining the highest standards of professional
excellence and analytical integrity.
""",
tools=[
analyze_data_patterns,
research_literature,
generate_test_scenarios,
benchmark_performance,
optimize_system_performance,
analyze_security_vulnerabilities,
design_scalability_architecture,
],
)
# Create the app with context caching configuration
# Note: Context cache config is set at the App level
cache_analysis_app = App(
name="cache_analysis",
root_agent=cache_analysis_agent,
context_cache_config=ContextCacheConfig(
min_tokens=4096,
ttl_seconds=600, # 10 mins for research sessions
cache_intervals=3, # Maximum invocations before cache refresh
),
)
# Export as app since it's an App, not an Agent
app = cache_analysis_app
# Backward compatibility export - ADK still expects root_agent in some contexts
root_agent = cache_analysis_agent