Add a run_python tool in three places, all in tools.py:
class Tools:
def run_python(self, code):
import subprocess, sys
out = subprocess.run([sys.executable, "-c", code],
capture_output=True, text=True, timeout=15, cwd=self.root)
return (out.stdout + out.stderr)[:6000] or "(no output)"
TOOL_NAMES = ["read_file","grep","search_files","write_file","edit_file","run_python"]
OPENAI_SCHEMAS.append({"type":"function","function":{
"name":"run_python",
"description":"Run a short Python snippet inside the workspace and return stdout+stderr.",
"parameters":{"type":"object","properties":{"code":{"type":"string"}},"required":["code"]}}})
That's it. Both the CLI agent and the FastAPI Agent Lab pick it up automatically — no other
file touched. The agent's tool kit just grew by one.