Build intelligent Agno agents with computing autonomy through several file-system and execution functions that allow:
Run Python code
Save to file and run
pip install packages
List files, read files
Unlike custom Python Functions as Tools, PythonTools is a pre-built toolkit imported when building Agno agents.
Copy
Ask AI
from pathlib import Pathfrom agno.agent import Agentfrom agno.tools.python import PythonTools# ---------------------------------------------------------------------------# Create Agent# ---------------------------------------------------------------------------# Example 1: All functions available (default behavior)agent_all = Agent( name="Python Agent - All Functions", tools=[PythonTools(base_dir=Path("tmp/python"))], instructions=["You have access to all Python execution capabilities."], markdown=True,)# Example 2: Include specific functions onlyagent_specific = Agent( name="Python Agent - Specific Functions", tools=[ PythonTools( base_dir=Path("tmp/python"), include_tools=["save_to_file_and_run", "run_python_code"], ) ], instructions=["You can only save and run Python code, no package installation."], markdown=True,)# Example 3: Exclude dangerous functionsagent_safe = Agent( name="Python Agent - Safe Mode", tools=[ PythonTools( base_dir=Path("tmp/python"), exclude_tools=["pip_install_package", "uv_pip_install_package"], ) ], instructions=["You can run Python code but cannot install packages."], markdown=True,)# Use the default agent for examplesagent = agent_all# ---------------------------------------------------------------------------# Run Agent# ---------------------------------------------------------------------------if __name__ == "__main__": agent.print_response( "Write a python script for fibonacci series and display the result till the 10th number" )