Skip to content

Commit 33db5c1

Browse files
authored
-added databases subagents,-improved master agent prompt to invoke the correct subagent (#23)
1 parent 292f600 commit 33db5c1

18 files changed

Lines changed: 772 additions & 12 deletions

devops_agent/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from rich.panel import Panel
77
from rich.prompt import Prompt
88
from devops_agent.core.master_agent import execute_master_agent
9-
from devops_agent.core.log_analysis_agent import execute_log_analysis_agent
9+
from devops_agent.loganalytics.log_analysis_agent import execute_log_analysis_agent
1010

1111
console = Console()
1212

devops_agent/core/master_agent.py

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
from agno.vectordb.chroma import ChromaDb
1212
from agno.knowledge.embedder.fastembed import FastEmbedEmbedder
1313
from qdrant_client import QdrantClient
14-
from qdrant_client.http.models import VectorParams, Distance, models
15-
16-
from devops_agent.core.devops_agent import execute_devops_agent
17-
from devops_agent.core.kubernetes_agent import execute_k8s_agent
18-
from devops_agent.core.terraform_agent import execute_terraform_agent
14+
from qdrant_client.http.models import VectorParams, Distance
15+
16+
from devops_agent.devops.devops_agent import execute_devops_agent
17+
from devops_agent.k8s.kubernetes_agent import execute_k8s_agent
18+
from devops_agent.terraform.terraform_agent import execute_terraform_agent
19+
from devops_agent.database.db_architect import execute_db_architect_agent
20+
from devops_agent.database.db_optimizer import execute_db_optimization_agent
21+
from devops_agent.database.sql_pro import execute_db_sql_pro_agent
1922
from rich.console import Console
2023
from dotenv import load_dotenv, find_dotenv
2124
from devops_agent.utils.stream_handler import StreamingResponseHandler
@@ -68,13 +71,60 @@ def execute_master_agent(provider: str, model_str: str, user_query: str = None,
6871
execute_devops_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
6972
execute_k8s_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
7073
execute_terraform_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
74+
execute_db_architect_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
75+
execute_db_optimization_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
76+
execute_db_sql_pro_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
7177
],
7278
instructions=[
73-
"You are a intelligent router that directs questions to the appropriate agent.",
74-
"If the user asks in a non devops or k8s question whose agent is not a team member, respond in English with:",
75-
"'I can only answer in the following technologies: Devops, terraform & Kubernetes Architecture on Multiple clouds. Please ask your question in one of these technologies.'",
76-
"Always check the technology or domain of the user's input before routing to an agent.",
77-
"For unsupported technologies like coding, flowcharts, analytics etc respond in English with the above message.",
79+
"You are an intelligent router that analyzes user questions and directs them to the most appropriate specialist "
80+
"agent based on their expertise domain.",
81+
82+
"AGENT SPECIALIZATIONS:",
83+
"- DevOps Agent: CI/CD pipelines, cloud infrastructure automation, deployment strategies, monitoring, container orchestration workflows, multi-cloud DevOps practices",
84+
"- Kubernetes Agent: K8s architecture, cluster management, workload deployment, service mesh, helm charts, operators, scaling strategies, troubleshooting",
85+
"- Terraform Agent: Infrastructure as Code, Terraform/OpenTofu modules, state management, multi-cloud provisioning, resource automation, IaC best practices",
86+
"- Database Architect Agent: Database technology selection, schema design from scratch, data modeling, migration planning, scalability architecture, greenfield/re-architecture projects",
87+
"- Database Optimization Agent: Query performance tuning, indexing strategies, N+1 resolution, caching architectures, existing database optimization, bottleneck elimination",
88+
"- SQL Pro Agent: Advanced SQL queries, analytical techniques, OLTP/OLAP optimization, cloud-native database queries, complex data analysis, reporting",
89+
90+
"ROUTING DECISION PROCESS:",
91+
"1. Analyze the user's question to identify the primary technology domain and specific task",
92+
"2. Determine if the question involves design/architecture vs optimization vs implementation",
93+
"3. For database questions, distinguish between:",
94+
" - Architecture/Design (new systems, technology selection, schema design) → Database Architect",
95+
" - Performance/Optimization (slow queries, indexing, caching, tuning existing systems) → Database Optimization",
96+
" - Query Writing/Analysis (SQL development, complex queries, analytics) → SQL Pro",
97+
"4. For infrastructure questions, distinguish between:",
98+
" - IaC/Provisioning (Terraform, resource creation, state management) → Terraform Agent",
99+
" - Container Orchestration (K8s workloads, pods, services, deployments) → Kubernetes Agent",
100+
" - General DevOps (CI/CD, automation, monitoring, deployments) → DevOps Agent",
101+
"5. Route to the single most relevant agent - avoid over-routing to multiple agents unless truly necessary",
102+
103+
"DATABASE ROUTING EXAMPLES:",
104+
"✓ 'Design a database for e-commerce platform' → Database Architect (greenfield design)",
105+
"✓ 'My query is slow, how do I optimize it?' → Database Optimization (performance tuning)",
106+
"✓ 'Write a SQL query for cohort analysis' → SQL Pro (query development)",
107+
"✓ 'Should I use PostgreSQL or MongoDB?' → Database Architect (technology selection)",
108+
"✓ 'Create indexes for better performance' → Database Optimization (optimization)",
109+
"✓ 'Complex window function for analytics' → SQL Pro (advanced SQL)",
110+
111+
"INFRASTRUCTURE ROUTING EXAMPLES:",
112+
"✓ 'Create Terraform module for AWS VPC' → Terraform Agent",
113+
"✓ 'Deploy microservices on Kubernetes' → Kubernetes Agent",
114+
"✓ 'Setup CI/CD pipeline for multi-cloud deployment' → DevOps Agent",
115+
"✓ 'Troubleshoot pod crash loops' → Kubernetes Agent",
116+
"✓ 'Implement blue-green deployment strategy' → DevOps Agent",
117+
118+
"UNSUPPORTED REQUESTS:",
119+
"If the question is outside these domains (e.g., frontend development, mobile apps, data science, machine learning, general coding unrelated to infrastructure), respond with:",
120+
"'I specialize in DevOps, Cloud Infrastructure, Kubernetes, Terraform/IaC, and Database Architecture/Optimization. Your question appears to be about [detected topic]. Please ask questions related to: cloud infrastructure automation, container orchestration, infrastructure as code, database design, query optimization, or SQL development.'",
121+
122+
"MULTI-AGENT SCENARIOS:",
123+
"Only involve multiple agents when the question genuinely spans domains:",
124+
"- 'Deploy database on Kubernetes with Terraform' → Terraform (infrastructure) + Kubernetes (deployment) + Database Architect (DB setup)",
125+
"- 'Optimize database in containerized environment' → Database Optimization (tuning) + Kubernetes (container config)",
126+
127+
"Always prioritize the PRIMARY expertise needed and route to that agent first. Think step-by-step about which agent's core competency best matches the user's need."
78128
],
79129
tools=[ReasoningTools()], # Enable reasoning capabilities
80130
knowledge=knowledge,

devops_agent/database/__init__.py

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from textwrap import dedent
2+
3+
from agno.agent import Agent
4+
from rich.console import Console
5+
from rich.panel import Panel
6+
from devops_agent.utils.model_provider import get_model
7+
8+
from devops_agent.utils.prompt_generator_from_poml import prompt_from_poml
9+
10+
db_architect_prompt = prompt_from_poml('db_architect.poml')
11+
12+
console = Console()
13+
14+
15+
def execute_db_architect_agent(provider: str, model: str, debug_mode: bool = False, reasoning: bool = False) -> Agent:
16+
console.print(Panel.fit(
17+
"[bold cyan]DB Architect Agent Invoking...[/bold cyan]",
18+
border_style="cyan"
19+
))
20+
21+
model = get_model(provider=provider, model_str=model)
22+
23+
db_optmization_assist = Agent(
24+
name="DB Architect Agent",
25+
model=model,
26+
description=dedent("""\
27+
You are Expert database architect specializing in data layer design from scratch, technology selection, schema modeling,
28+
and scalable database architectures. Masters SQL/NoSQL/TimeSeries database selection, normalization strategies,
29+
migration planning, and performance-first design. Handles both greenfield architectures and re-architecture of
30+
existing systems. Use PROACTIVELY for database architecture, technology selection, or data modeling decisions.\
31+
"""),
32+
instructions=db_architect_prompt,
33+
stream_intermediate_steps=True,
34+
markdown=True,
35+
debug_mode=debug_mode,
36+
reasoning=reasoning
37+
)
38+
39+
return db_optmization_assist
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from textwrap import dedent
2+
3+
from agno.agent import Agent
4+
from rich.console import Console
5+
from rich.panel import Panel
6+
from devops_agent.utils.model_provider import get_model
7+
8+
from devops_agent.utils.prompt_generator_from_poml import prompt_from_poml
9+
10+
db_optimization_prompt = prompt_from_poml('db_optimizer.poml')
11+
12+
console = Console()
13+
14+
15+
def execute_db_optimization_agent(provider: str, model: str, debug_mode: bool = False, reasoning: bool = False) -> Agent:
16+
console.print(Panel.fit(
17+
"[bold cyan]DB Optimization Agent Invoking...[/bold cyan]",
18+
border_style="cyan"
19+
))
20+
21+
model = get_model(provider=provider, model_str=model)
22+
23+
db_optmization_assist = Agent(
24+
name="DB Optimization Agent",
25+
model=model,
26+
description=dedent("""\
27+
You are Expert database optimizer with comprehensive knowledge of modern database performance tuning, query optimization
28+
, and scalable architecture design. Masters multi-database platforms, advanced indexing strategies, caching
29+
architectures, and performance monitoring. Specializes in eliminating bottlenecks, optimizing complex queries,
30+
and designing high-performance database systems.\
31+
"""),
32+
instructions=db_optimization_prompt,
33+
stream_intermediate_steps=True,
34+
markdown=True,
35+
debug_mode=debug_mode,
36+
reasoning=reasoning
37+
)
38+
39+
return db_optmization_assist

devops_agent/database/sql_pro.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from textwrap import dedent
2+
3+
from agno.agent import Agent
4+
from rich.console import Console
5+
from rich.panel import Panel
6+
from devops_agent.utils.model_provider import get_model
7+
8+
from devops_agent.utils.prompt_generator_from_poml import prompt_from_poml
9+
10+
db_sql_pro_prompt = prompt_from_poml('db_sql_pro.poml')
11+
12+
console = Console()
13+
14+
15+
def execute_db_sql_pro_agent(provider: str, model: str, debug_mode: bool = False, reasoning: bool = False) -> Agent:
16+
console.print(Panel.fit(
17+
"[bold cyan]Sql Pro Agent Invoking...[/bold cyan]",
18+
border_style="cyan"
19+
))
20+
21+
model = get_model(provider=provider, model_str=model)
22+
23+
db_optmization_assist = Agent(
24+
name="Sql Pro Agent",
25+
model=model,
26+
description=dedent("""\
27+
You are Master modern SQL with cloud-native databases, OLTP/OLAP optimization, and advanced query techniques.
28+
Expert in performance tuning, data modeling, and hybrid analytical systems. Use PROACTIVELY for database
29+
optimization or complex analysis.\
30+
"""),
31+
instructions=db_sql_pro_prompt,
32+
stream_intermediate_steps=True,
33+
markdown=True,
34+
debug_mode=debug_mode,
35+
reasoning=reasoning
36+
)
37+
38+
return db_optmization_assist

devops_agent/devops/__init__.py

Whitespace-only changes.

devops_agent/k8s/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)