Many advanced use-cases will require writing custom Toolkits. Here’s the general flow:

  1. Create a class inheriting the class.
  2. Add your functions to the class.
  3. Important: Register the functions using self.register(function_name)

Now your Toolkit is ready to use with an Assistant. For example:
from typing import List

from import Toolkit
from phi.utils.log import logger

class ShellTools(Toolkit):
    def __init__(self):

    def run_shell_command(self, args: List[str], tail: int = 100) -> str:
        """Runs a shell command and returns the output or error.

            args (List[str]): The command to run as a list of strings.
            tail (int): The number of lines to return from the output.
            str: The output of the command.
        import subprocess"Running shell command: {args}")
  "Running shell command: {args}")
            result =, capture_output=True, text=True)
            logger.debug(f"Result: {result}")
            logger.debug(f"Return code: {result.returncode}")
            if result.returncode != 0:
                return f"Error: {result.stderr}"
            # return only the last n lines of the output
            return "\n".join(result.stdout.split("\n")[-tail:])
        except Exception as e:
            logger.warning(f"Failed to run shell command: {e}")
            return f"Error: {e}"