How to add Tools to Agents and Tasks Yaml Files: Proper Format/Syntax

Hello,

I am curious. What is the proper format/syntax to add tools to tasks.yml and agents.yaml?

This is how I have it currently, but I have tried many variations:

analyze_topic:
  description: >
    Analyze {niche_topic} in detail. Your output must start with "Topic Analysis:" and include:
    1) Key concepts and terminology
    2) Current trends and developments
    3) Major challenges and opportunities
    4) Different perspectives and approaches in the field
  expected_output: >
    A comprehensive analysis covering key aspects,
    current state, trends, and various perspectives of {niche_topic}.
    Structure your response with clear sections and bullet points.
  llm: OpenAI_gpt-4o
  tools:
    - SerperDevTool
    - ScrapeWebsiteTool

I get this error:

Traceback (most recent call last):
  File "C:\Users\rthid\myapps\speaker_finder\backend\main.py", line 15, in <module>
    run()
  File "C:\Users\rthid\myapps\speaker_finder\backend\main.py", line 12, in run
    SpeakerFinders().crew().kickoff(inputs=inputs)
    ^^^^^^^^^^^^^^^^
  File "C:\Users\rthid\myapps\speaker_finder\.venv\Lib\site-packages\crewai\project\crew_base.py", line 36, in __init__
    self.map_all_task_variables()
  File "C:\Users\rthid\myapps\speaker_finder\.venv\Lib\site-packages\crewai\project\crew_base.py", line 203, in map_all_task_variables
    self._map_task_variables(
  File "C:\Users\rthid\myapps\speaker_finder\.venv\Lib\site-packages\crewai\project\crew_base.py", line 232, in _map_task_variables
    tool_functions[tool]() for tool in tools
    ~~~~~~~~~~~~~~^^^^^^
KeyError: 'SerperDevTool'

I notice errors on lines 12 and 15 in main.py. Is that causing the KeyError with the tool?

Thanks In Advance,
Ryan

Good question as I think I remember seeing this in an example a while ago so can understand the confusion.
However as of the current crewai version 0.100.0 latest version.

I use the tools line.

	config=self.tasks_config['notes_task'],
	llm=llm,
	verbose=True,
	***tools=[docs_tool, file_tool, CSVSearchTool()]***,

For completeness I tried adding to the yaml files and I got the same error.
If in doubt I look here GitHub - crewAIInc/crewAI: Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks. for the READ.me and also run ‘crewai create crew <project_name>’ and it will give me a template.

1 Like