Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion devops_agent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from rich.panel import Panel
from rich.prompt import Prompt
from devops_agent.core.master_agent import execute_master_agent
from devops_agent.core.log_analysis_agent import execute_log_analysis_agent
from devops_agent.loganalytics.log_analysis_agent import execute_log_analysis_agent

console = Console()

Expand Down
70 changes: 60 additions & 10 deletions devops_agent/core/master_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
from agno.vectordb.chroma import ChromaDb
from agno.knowledge.embedder.fastembed import FastEmbedEmbedder
from qdrant_client import QdrantClient
from qdrant_client.http.models import VectorParams, Distance, models

from devops_agent.core.devops_agent import execute_devops_agent
from devops_agent.core.kubernetes_agent import execute_k8s_agent
from devops_agent.core.terraform_agent import execute_terraform_agent
from qdrant_client.http.models import VectorParams, Distance

from devops_agent.devops.devops_agent import execute_devops_agent
from devops_agent.k8s.kubernetes_agent import execute_k8s_agent
from devops_agent.terraform.terraform_agent import execute_terraform_agent
from devops_agent.database.db_architect import execute_db_architect_agent
from devops_agent.database.db_optimizer import execute_db_optimization_agent
from devops_agent.database.sql_pro import execute_db_sql_pro_agent
from rich.console import Console
from dotenv import load_dotenv, find_dotenv
from devops_agent.utils.stream_handler import StreamingResponseHandler
Expand Down Expand Up @@ -68,13 +71,60 @@ def execute_master_agent(provider: str, model_str: str, user_query: str = None,
execute_devops_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
execute_k8s_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
execute_terraform_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
execute_db_architect_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
execute_db_optimization_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
execute_db_sql_pro_agent(provider=provider, model=model_str, debug_mode=debug_mode, reasoning=reasoning),
],
instructions=[
"You are a intelligent router that directs questions to the appropriate agent.",
"If the user asks in a non devops or k8s question whose agent is not a team member, respond in English with:",
"'I can only answer in the following technologies: Devops, terraform & Kubernetes Architecture on Multiple clouds. Please ask your question in one of these technologies.'",
"Always check the technology or domain of the user's input before routing to an agent.",
"For unsupported technologies like coding, flowcharts, analytics etc respond in English with the above message.",
"You are an intelligent router that analyzes user questions and directs them to the most appropriate specialist "
"agent based on their expertise domain.",

"AGENT SPECIALIZATIONS:",
"- DevOps Agent: CI/CD pipelines, cloud infrastructure automation, deployment strategies, monitoring, container orchestration workflows, multi-cloud DevOps practices",
"- Kubernetes Agent: K8s architecture, cluster management, workload deployment, service mesh, helm charts, operators, scaling strategies, troubleshooting",
"- Terraform Agent: Infrastructure as Code, Terraform/OpenTofu modules, state management, multi-cloud provisioning, resource automation, IaC best practices",
"- Database Architect Agent: Database technology selection, schema design from scratch, data modeling, migration planning, scalability architecture, greenfield/re-architecture projects",
"- Database Optimization Agent: Query performance tuning, indexing strategies, N+1 resolution, caching architectures, existing database optimization, bottleneck elimination",
"- SQL Pro Agent: Advanced SQL queries, analytical techniques, OLTP/OLAP optimization, cloud-native database queries, complex data analysis, reporting",

"ROUTING DECISION PROCESS:",
"1. Analyze the user's question to identify the primary technology domain and specific task",
"2. Determine if the question involves design/architecture vs optimization vs implementation",
"3. For database questions, distinguish between:",
" - Architecture/Design (new systems, technology selection, schema design) → Database Architect",
" - Performance/Optimization (slow queries, indexing, caching, tuning existing systems) → Database Optimization",
" - Query Writing/Analysis (SQL development, complex queries, analytics) → SQL Pro",
"4. For infrastructure questions, distinguish between:",
" - IaC/Provisioning (Terraform, resource creation, state management) → Terraform Agent",
" - Container Orchestration (K8s workloads, pods, services, deployments) → Kubernetes Agent",
" - General DevOps (CI/CD, automation, monitoring, deployments) → DevOps Agent",
"5. Route to the single most relevant agent - avoid over-routing to multiple agents unless truly necessary",

"DATABASE ROUTING EXAMPLES:",
"✓ 'Design a database for e-commerce platform' → Database Architect (greenfield design)",
"✓ 'My query is slow, how do I optimize it?' → Database Optimization (performance tuning)",
"✓ 'Write a SQL query for cohort analysis' → SQL Pro (query development)",
"✓ 'Should I use PostgreSQL or MongoDB?' → Database Architect (technology selection)",
"✓ 'Create indexes for better performance' → Database Optimization (optimization)",
"✓ 'Complex window function for analytics' → SQL Pro (advanced SQL)",

"INFRASTRUCTURE ROUTING EXAMPLES:",
"✓ 'Create Terraform module for AWS VPC' → Terraform Agent",
"✓ 'Deploy microservices on Kubernetes' → Kubernetes Agent",
"✓ 'Setup CI/CD pipeline for multi-cloud deployment' → DevOps Agent",
"✓ 'Troubleshoot pod crash loops' → Kubernetes Agent",
"✓ 'Implement blue-green deployment strategy' → DevOps Agent",

"UNSUPPORTED REQUESTS:",
"If the question is outside these domains (e.g., frontend development, mobile apps, data science, machine learning, general coding unrelated to infrastructure), respond with:",
"'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.'",

"MULTI-AGENT SCENARIOS:",
"Only involve multiple agents when the question genuinely spans domains:",
"- 'Deploy database on Kubernetes with Terraform' → Terraform (infrastructure) + Kubernetes (deployment) + Database Architect (DB setup)",
"- 'Optimize database in containerized environment' → Database Optimization (tuning) + Kubernetes (container config)",

"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."
],
tools=[ReasoningTools()], # Enable reasoning capabilities
knowledge=knowledge,
Expand Down
Empty file.
39 changes: 39 additions & 0 deletions devops_agent/database/db_architect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from textwrap import dedent

from agno.agent import Agent
from rich.console import Console
from rich.panel import Panel
from devops_agent.utils.model_provider import get_model

from devops_agent.utils.prompt_generator_from_poml import prompt_from_poml

db_architect_prompt = prompt_from_poml('db_architect.poml')

console = Console()


def execute_db_architect_agent(provider: str, model: str, debug_mode: bool = False, reasoning: bool = False) -> Agent:
console.print(Panel.fit(
"[bold cyan]DB Architect Agent Invoking...[/bold cyan]",
border_style="cyan"
))

model = get_model(provider=provider, model_str=model)

db_optmization_assist = Agent(
name="DB Architect Agent",
model=model,
description=dedent("""\
You are Expert database architect specializing in data layer design from scratch, technology selection, schema modeling,
and scalable database architectures. Masters SQL/NoSQL/TimeSeries database selection, normalization strategies,
migration planning, and performance-first design. Handles both greenfield architectures and re-architecture of
existing systems. Use PROACTIVELY for database architecture, technology selection, or data modeling decisions.\
"""),
instructions=db_architect_prompt,
stream_intermediate_steps=True,
markdown=True,
debug_mode=debug_mode,
reasoning=reasoning
)

return db_optmization_assist
39 changes: 39 additions & 0 deletions devops_agent/database/db_optimizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from textwrap import dedent

from agno.agent import Agent
from rich.console import Console
from rich.panel import Panel
from devops_agent.utils.model_provider import get_model

from devops_agent.utils.prompt_generator_from_poml import prompt_from_poml

db_optimization_prompt = prompt_from_poml('db_optimizer.poml')

console = Console()


def execute_db_optimization_agent(provider: str, model: str, debug_mode: bool = False, reasoning: bool = False) -> Agent:
console.print(Panel.fit(
"[bold cyan]DB Optimization Agent Invoking...[/bold cyan]",
border_style="cyan"
))

model = get_model(provider=provider, model_str=model)

db_optmization_assist = Agent(
name="DB Optimization Agent",
model=model,
description=dedent("""\
You are Expert database optimizer with comprehensive knowledge of modern database performance tuning, query optimization
, and scalable architecture design. Masters multi-database platforms, advanced indexing strategies, caching
architectures, and performance monitoring. Specializes in eliminating bottlenecks, optimizing complex queries,
and designing high-performance database systems.\
"""),
instructions=db_optimization_prompt,
stream_intermediate_steps=True,
markdown=True,
debug_mode=debug_mode,
reasoning=reasoning
)

return db_optmization_assist
38 changes: 38 additions & 0 deletions devops_agent/database/sql_pro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from textwrap import dedent

from agno.agent import Agent
from rich.console import Console
from rich.panel import Panel
from devops_agent.utils.model_provider import get_model

from devops_agent.utils.prompt_generator_from_poml import prompt_from_poml

db_sql_pro_prompt = prompt_from_poml('db_sql_pro.poml')

console = Console()


def execute_db_sql_pro_agent(provider: str, model: str, debug_mode: bool = False, reasoning: bool = False) -> Agent:
console.print(Panel.fit(
"[bold cyan]Sql Pro Agent Invoking...[/bold cyan]",
border_style="cyan"
))

model = get_model(provider=provider, model_str=model)

db_optmization_assist = Agent(
name="Sql Pro Agent",
model=model,
description=dedent("""\
You are Master modern SQL with cloud-native databases, OLTP/OLAP optimization, and advanced query techniques.
Expert in performance tuning, data modeling, and hybrid analytical systems. Use PROACTIVELY for database
optimization or complex analysis.\
"""),
instructions=db_sql_pro_prompt,
stream_intermediate_steps=True,
markdown=True,
debug_mode=debug_mode,
reasoning=reasoning
)

return db_optmization_assist
Empty file added devops_agent/devops/__init__.py
Empty file.
File renamed without changes.
Empty file added devops_agent/k8s/__init__.py
Empty file.
Empty file.
Loading