Spaces:
Running
Running
File size: 1,248 Bytes
4b445f6 | 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 | """
Performance Agent
==================
Evaluates code for computational efficiency, memory usage, and scalability.
Uses radon for complexity metrics and the LLM for semantic analysis of
query patterns, I/O operations, and algorithmic efficiency.
Same architecture as SecurityAgent — inherits from BaseAgent, overrides
only agent_name, system_prompt, and run_static_analysis().
"""
from __future__ import annotations
from pathlib import Path
import structlog
from app.agents.base_agent import BaseAgent
from app.github.client import PRData
from app.tools.radon_tool import run_radon
logger = structlog.get_logger()
class PerformanceAgent(BaseAgent):
@property
def agent_name(self) -> str:
return "performance"
@property
def system_prompt(self) -> str:
prompt_path = (
Path(__file__).resolve().parent.parent.parent
/ "prompts"
/ "performance_system.md"
)
return prompt_path.read_text(encoding="utf-8")
async def run_static_analysis(self, pr_data: PRData) -> str:
"""Run radon complexity analysis on changed Python files."""
radon_output = await run_radon(pr_data.file_contents)
return radon_output if radon_output else ""
|