Passing class instance (self) to CrewAI tools function

Here is my tool definition for a custom class that are
Tools Function

    def get_batter_on_position(self, min_bat_pos:int, max_bat_pos: int, team_name: str) -> list[dict]:

        """This function filters the players based on their batting position and team name.
            arguments:  min_bat_pos (int): Minimum batting position a batter should be selected
                        max_bat_pos (int): Maximum batting position a batter should be selected
                        team_name (str): Name of the team from which batter should be selected   
        """

        # fiter from player_df based on position and team name
        batter_df = self.batter_df[(self.batter_df['bat_pos'] >= min_bat_pos) &
                                (self.batter_df['bat_pos'] <= max_bat_pos) &
                                (self.batter_df['current_team_name'] == team_name) &
                                (self.batter_df['player_role'].str.contains('batter', case=False))].copy()
        
        return batter_df.to_dict(orient='records')

batter_df is the class variables that are initalized in the init function of the class

Agent Code

    def batter_agent(self) -> Agent:
        return Agent(
            config=self.agents_config['batter_agent'], # type: ignore[index]
            verbose=True,
            llm=self.llm,
            tools=[self.get_batter_on_position, self.add_player_to_team]
        )

Issue

I encountered an error while trying to use the tool. This was the error: OneSideTeamSelection.get_batter_on_position() missing 1 required positional argument: ‘self’.

  • Is tool suppose to be a standalone function or is there any way to pass this as part of tools call?
  • If yes, then how can make tools to access the class variables to perform updates.
  • Is global only the way to go about it?

Please guide.