from crewai.tools import tool import subprocess @tool("run_tests") def run_tests(path: str = "tests/") -> str: """Run the pytest suite at the given path and return the result.""" result = subprocess.run( ["pytest", path, "-q"], capture_output=True, text=True, timeout=120 ) output = result.stdout + result.stderr return output[-4000:] if len(output) > 4000 else output