from crewai import Agent, Crew, LLM, Process, Task from crewai.tools import tool from crewai_tools import (DirectoryReadTool, FileReadTool, FileWriterTool, E2BExecTool, E2BPythonTool) llm = LLM(model="anthropic/claude-sonnet-4.6") list_dir = DirectoryReadTool(directory="./workspace") filesystem_tools = [FileReadTool(), FileWriterTool(), list_dir] sandbox_tools = [exec_tool, E2BPythonTool()] @tool("run_tests") def run_tests(path: str = "tests/") -> str: """Sync ./workspace into the sandbox, then run pytest there.""" return E2BExecTool().run(command=sync_and_test_command(path)) explorer = Agent(role="Codebase Explorer", goal="Map repo, surface relevant files.", tools=[read_file, list_dir], llm=llm) coder = Agent(role="Software Engineer", goal="Implement requested change.", tools=filesystem_tools, reasoning=True, llm=llm) tester = Agent(role="Test Runner", goal="Run tests in sandbox, report pass/fail.", tools=sandbox_tools + [read_file] + [run_tests], llm=llm) manager = Agent(role="Engineering Lead", goal="Delegate steps, finish once tests pass.", allow_delegation=True, llm=llm) task = Task( description="In ./workspace, {objective}. Explore, edit, test, report.", expected_output="Summary of changes and test output.", human_input=True, ) crew = Crew( agents=[explorer, coder, tester], tasks=[task], manager_agent=manager, process=Process.hierarchical, planning=True, memory=True, checkpoint=True, ) result = crew.kickoff(inputs={"objective": "fix failing tests in account.py"})