CrewAI Noob vs Pro Tools

aiwithbrandonAbout 7 min readMay 27, 2025Watch original
THE SUMMARYAI-generated

Key Concepts

  • CrewAI: Framework for orchestrating autonomous agents to work together on tasks.
  • Tools: Functions or integrations that agents can use to accomplish tasks (e.g., searching the web, interacting with Trello).
  • Agents: Autonomous entities with specific roles and responsibilities within a crew (e.g., researcher, writer, Trello manager).
  • Tasks: Specific objectives assigned to agents within a crew (e.g., research a topic, write an article, update a Trello card).
  • Custom Tools: Tools built by the user to extend the capabilities of CrewAI agents.
  • Trello API: Interface for programmatically interacting with Trello boards and cards.
  • Tav: Python SDK for searching the internet.
  • Before Kickoff: CrewAI feature that allows modifying crew inputs dynamically before execution.
  • Structured Outputs: Using models to define the expected format of task outputs.
  • Pedantic Base Model: A structured way of defining the schema for tool arguments.

Crew Overview: Research and Writer Tool Integrated with Trello

The video demonstrates building a CrewAI setup that combines research and writing capabilities with Trello integration. The crew automatically pulls tasks from a Trello "To-Do" column, researches the topics, writes articles, adds the articles as comments to the Trello cards, and moves the cards to a "Researched" column.

Key Points:

  • The crew consists of three agents: a researcher, a writer, and a Trello manager.
  • Each agent is assigned specific tasks.
  • Custom tools are used to interact with Trello.
  • The goal is to automate content creation and task management.

Task and Agent Breakdown

The crew is structured around three main tasks, each assigned to a corresponding agent:

  1. Research Task (Researcher Agent):
    • Objective: Research topics listed in Trello cards and gather actionable insights for developers.
    • Input: An array of objects, where each object contains the topic to research.
    • Instructions:
      • Specify the platform for research.
      • Focus on gathering actionable insights for developers.
      • Provide examples of expected insights.
    • Expected Output: An array of objects, each containing the Trello card ID, the original topic, and the research findings. The output is defined using a pedantic model to ensure a specific format (ID, name, research).
  2. Article Writing Task (Writer Agent):
    • Objective: Generate short, actionable articles based on the research provided by the researcher.
    • Input: Research output from the research task.
    • Instructions:
      • Use the research provided.
      • Generate short, actionable articles.
      • Provide specific instructions on what a good article looks like (topic, key findings, details, insights).
      • Provide an example structure for the article.
    • Expected Output: An array of objects, each containing the Trello card ID, the original topic, and the generated article. The output is defined using a pedantic model to ensure a specific format (ID, name, article).
  3. Trello Update Task (Trello Manager Agent):
    • Objective: Update the Trello board by adding the generated article as a comment to the corresponding card and moving the card to the next column.
    • Input: Article output from the writer task.
    • Instructions:
      • Add the article as a comment to the Trello card.
      • Move the Trello card to the next column in the workflow.
      • Confirm the actions.
      • Use the provided Trello tools.
      • Report any errors.

Noob vs. Pro Tips:

  • Pro Tip 1: Use structured outputs (pedantic models) to ensure tasks return data in a specific format.
  • Pro Tip 2: Provide detailed instructions and examples in tasks to guide the LLM.
  • Pro Tip 3: Explicitly mention the tool provider (e.g., Tav, Reddit) in the tool name and description.

Custom Tool Crash Course

This section provides a quick overview of how agents and tools work together, including:

  • Agent Reasoning: Agents analyze problems and determine if available tools can help solve them.
  • Tool Selection: Agents evaluate tool names and descriptions to determine relevance.
  • Tool Execution: Agents use tool arguments to provide the necessary input for the tool to function.

Key Tool Components:

  • Name: A unique identifier for the tool.
  • Description: A clear explanation of what the tool does.
  • Arguments: The input parameters required by the tool.

Example:

A senior data researcher agent uses a "Serper" tool (for searching the web) to research a topic. The agent analyzes the tool's description ("a tool that can be used to search the internet with a search query") and determines it's relevant. The agent then uses the tool's argument ("search query") to provide the search term.

Code Structure:

  • Tools are defined as Python classes.
  • The run method contains the core logic of the tool.
  • Arguments are defined using pedantic base models to ensure data validation.

Building Custom Tools: Step-by-Step

The video demonstrates building three custom tools:

  1. Reddit Tav Search Tool:

    • Purpose: Search Reddit using the Tav Python SDK.

    • Steps:

      1. Create a new tool file (tools.py).
      2. Add the taav Python package using UV add taav-python.
      3. Define the input model with query (string) and max_results (integer) fields.
      4. Implement the run method to use the Tav client to search Reddit.
      5. Instantiate the Tav client in the tool's constructor using an API key from environment variables.
      6. Test the tool locally by creating an instance and calling the run method with sample inputs.
    • Code Snippet (Run Method):

      def run(self, query: str, max_results: int = 5) -> str:
          """Searches Reddit using Tav."""
          return self.tav_client.search(
              query=f"Reddit {query}", max_results=max_results
          )
      
  2. Trello Add Card Comment Tool:

    • Purpose: Add a comment to a Trello card using the Trello API.

    • Steps:

      1. Create a new tool file.
      2. Define the input model with card_id (string) and text (string) fields.
      3. Implement the run method to make an API request to add the comment.
      4. Use environment variables for the Trello API key and token.
      5. Test the tool locally by creating an instance and calling the run method with a card ID and comment text.
    • Code Snippet (Run Method - Conceptual):

      def run(self, card_id: str, text: str) -> str:
          """Adds a comment to a Trello card."""
          # Construct the API URL
          url = f"https://api.trello.com/1/cards/{card_id}/actions/comments"
          # Construct the query parameters
          query = {
              'text': text,
              'key': self.trello_api_key,
              'token': self.trello_api_token
          }
          # Make the API request
          response = requests.post(url, params=query)
          # Handle the response
          if response.status_code == 200:
              return "Comment added successfully."
          else:
              return f"Error adding comment: {response.text}"
      
  3. Trello Update Card Tool:

    • Purpose: Update a Trello card's properties (e.g., name, description, list).

    • Steps:

      1. Create a new tool file.
      2. Define the input model with card_id (string) as a required field and other card properties (name, desc, idList, etc.) as optional fields.
      3. Implement the run method to make an API request to update the card.
      4. Use environment variables for the Trello API key and token.
      5. Implement a "hack" to overwrite the idList value with the correct ID of the "Doing" column.
      6. Test the tool locally by creating an instance and calling the run method with a card ID and the desired properties to update.
    • Code Snippet (Run Method - Conceptual):

      def run(self, card_id: str, **kwargs) -> str:
          """Updates a Trello card's properties."""
          # Construct the API URL
          url = f"https://api.trello.com/1/cards/{card_id}"
          # Construct the query parameters
          query = {
              'key': self.trello_api_key,
              'token': self.trello_api_token,
              **kwargs  # Include all other keyword arguments as query parameters
          }
          # Hack to overwrite idList
          if 'idList' in query:
              query['idList'] = os.environ.get("TRELLO_DOING_LIST")
      
          # Make the API request
          response = requests.put(url, params=query)
          # Handle the response
          if response.status_code == 200:
              return "Card updated successfully."
          else:
              return f"Error updating card: {response.text}"
      

Pro Tips for Tool Development:

  • Work from the run method backwards: Start by defining the action you want to perform and then work backwards to define the input model and tool properties.
  • Test tools locally: Create a separate Python file to test your tools before integrating them into your crew.
  • Use code generation tools: Leverage AI tools like Cursor to generate code snippets based on API documentation and examples.
  • Automate repetitive tasks: If you find yourself performing the same task multiple times, create a utility function to automate it.

Before Kickoff Feature

The before_kickoff decorator allows modifying the inputs to a crew dynamically before it starts running. This is useful for tasks such as scraping data from external sources or retrieving information from a database.

Example:

The video demonstrates using before_kickoff to scrape Trello for cards in the "To-Do" list and use those cards as inputs to the crew. This eliminates the need to manually update the crew's inputs every time a new card is added to the Trello board.

Benefits:

  • Dynamic input generation.
  • Eliminates manual input updates.
  • Improves crew scalability and automation.

Conclusion

The video provides a comprehensive guide to building custom tools for CrewAI, integrating them with external services like Trello, and leveraging advanced features like before_kickoff. By following the steps and tips outlined in the video, developers can create powerful and automated workflows that streamline content creation, task management, and other complex processes. The key takeaways are the importance of well-defined tasks, structured outputs, clear tool descriptions, and the power of combining CrewAI with external APIs and libraries.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.