Attribute Error: 'str' object has no attribute 'get'

Im running a crew and getting this error message:

Traceback (most recent call last):
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/bin/run_crew”, line 8, in
sys.exit(run())
^^^^^
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/src/ftsonboarding2/main.py”, line 16, in run
Ftsonboarding2Crew().crew().kickoff(inputs=inputs)
^^^^^^^^^^^^^^^^^^^^
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py”, line 35, in init
self.map_all_task_variables()
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py”, line 145, in map_all_task_variables
self._map_task_variables(
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py”, line 169, in _map_task_variables
taskscontext_task_name for context_task_name in context_list
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/lib/python3.12/site-packages/crewai/project/utils.py”, line 7, in memoized_func
cache[key] = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/lib/python3.12/site-packages/crewai/project/annotations.py”, line 13, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/src/ftsonboarding2/crew.py”, line 61, in research_task_find_organization
return Task(
^^^^^
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/lib/python3.12/site-packages/pydantic/main.py”, line 212, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/lib/python3.12/site-packages/crewai/agents/agent_builder/base_agent.py”, line 135, in process_model_config
return process_config(values, cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/frankjelinek/Crewai_Projects/ftsonboarding2/.venv/lib/python3.12/site-packages/crewai/utilities/config.py”, line 19, in process_config
config = values.get(“config”, {})
^^^^^^^^^^
AttributeError: ‘str’ object has no attribute ‘get’
An error occurred while running the crew: Command ‘[‘uv’, ‘run’, ‘run_crew’]’ returned non-zero exit status 1.

I have no clue why this happens. Can anyone give me a hint for the solution?

Thx a lot
Frank

Hi @Frank_Jelinek,
What version of CrewAI are you running?

I ask as there’s been a number of issues recently with newer versions.

I’m running on
crewai version: 0.76.2

Can you link us your code so we can see

Here is the tasks.yaml

research_task_find_name:
  description: >
  description: >
    Conduct a thorough research about {email}
    Make sure you find surname, name a for the given email {email}
  expected_output: >
    Surname, name of the given email {email}
  agent: researcher



research_task_find_organization:
  description: >
    Conduct a thorough research about {email}
    Make sure you find organization for the given email {email}
  expected_output: >
    organisation_name to which the given email {email} belongs to
  agent: researcher



  ums_organization_task:
  description: >
    Based on the found organization hand over the organization_name to the ums_organization_tool.
  expected_output: >
     The organizatuion_name and the organization_identifier
  agent: ums_org_agent
  context: ["research_task_find_organization"]


  ums_user_task:
  description: >
    Based on the given email adress {email} and the organization_identifier from the ums_organization_task hand over both parameters to the ums_user_tool

  expected_output: >
    "CREATED" if the user is created, "EXIST" is the user is part of the list. In both cases the log-on-id of the user, the user_identifier and the organization identifier the user belongs to.
  agent: ums_user_agent
  context: ["research_task_find_organization","research_task_find_name"]


  FileTransferServerConfiguration_task:
  description: >
    Based on the found user_identifier, the given email adress {email} and the organization_identifier handover these parameters to the fts_account_tool
  expected_output: >
    "CREATED" if the account is created, "EXIST" is the account is part of the list. In both cases the log-on-id and the fts_account_identifier of the account
  agent: file_transfer_server_agent
  context: ["research_task_find_organization","research_task_find_name","ums_user_task"]



Here the agents.yaml

researcher:
  role: >
    Senior Data Researcher
  goal: >
    Find the name, surname and organization for the given emailadress {email}. Handover the organization to the ums_org_agent as input. Find only verified information and pass it on to the crew
  backstory: >
    You're a seasoned researcher with a knack for uncovering the latest
    information for the mailadress {email}. Known for your ability to find the most relevant
    information and present it in a clear and concise manner. You are a reliable agent that only provides checked and verified data and does not make assumptions.


ums_org_agent:
  role: >
    Senior operator and UMS specialist
  goal: >
    Comapre the UMS listing with the given Organization name. If the organization is in the list return "EXIST" and the name and the org_identifier to the crew. 
    If the organization name is not in the list create a new organization in UMS and return "NEW" and the name and the org_identifier to the crew

  backstory: >
    You are an seasoned operator with a lot of onboarding skills. You can compare listes of organizations with a given organization and you can create new organizations in UMS

ums_user_agent:
  role: >
    Senior operator and user UMS specialist
  goal: >
    Comapre the UMS user listing with the found email address {email}. If the user is in the list return "EXIST" else create the user.Provide the name, the log-on-id and the user_identifier to the crew
  backstory: >
    You are an seasoned operator with a lot of onboarding skills. You can compare listes of user email adresses with a given email address and you are able to create a new user within the correct organization


file_transfer_server_agent:
  role: >
    Senior operator and BIS File Transfer Server specialist
  goal: >
    Comapre the BIS File Transfer Server account listing with the user_identifier provided by the crew. If the user is in the list return "EXIST" else create a new account. Make use of the org_identifier from the created or found provided by the crew.
  backstory: >
    You are an seasoned operator with a lot of BIS File Transfer Server skills. You can compare list of accounts, wherein the identifier of a user will be listed or not.

the crew.py

from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from ftsonboarding2.tools.fts_account_tool import FTSAccountTool
from ftsonboarding2.tools.ums_user_tool import UmsUserTool
from ftsonboarding2.tools.ums_organization_tool import UmsOrganizationTool



ums_organization_tool = UmsOrganizationTool()
ums_user_tool = UmsUserTool()
fts_account_tool = FTSAccountTool()


# Uncomment the following line to use an example of a custom tool
# from ftsonboarding2.tools.custom_tool import MyCustomTool

# Check our tools documentations for more information on how to use them
# from crewai_tools import SerperDevTool

@CrewBase
class Ftsonboarding2Crew():
	"""Ftsonboarding2 crew"""

	@agent
	def researcher(self) -> Agent:
		return Agent(
			config=self.agents_config['researcher'],
			# tools=[MyCustomTool()], # Example of custom tool, loaded on the beginning of file
			verbose=True
		)

	@agent
	def ums_org_agent(self) -> Agent:
		return Agent(
			config=self.agents_config['ms_org_agent'],
   			tools=[ums_organization_tool],
			verbose=True
		)
	@agent
	def ums_user_agent(self) -> Agent:
		return Agent(
			config=self.agents_config['ums_user_agent'],
   			tools=[ums_user_tool],
			verbose=True
		)
	@agent
	def file_transfer_server_agent(self) -> Agent:
		return Agent(
			config=self.agents_config['file_transfer_server_agent'],
			tools=[fts_account_tool],
			verbose=True
		)

	@task
	def research_task_find_name(self) -> Task:
		return Task(
			config=self.tasks_config['research_task_find_name'],
		)
	@task
	def research_task_find_organization(self) -> Task:
		return Task(
			config=self.tasks_config['research_task_find_organization'],
		)

	@task
	def ums_organization_task(self) -> Task:
		return Task(
			config=self.tasks_config['ums_organization_task'],
		)
	@task
	def ums_user_task(self) -> Task:
		return Task(
			config=self.tasks_config['ums_user_task'],
		)

	@task
	def FileTransferServerConfiguration_task(self) -> Task:
		return Task(
			config=self.tasks_config['FileTransferServerConfiguration_task'],
		)
  
	@crew
	def crew(self) -> Crew:
		"""Creates the Ftsonboarding2 crew"""
		return Crew(
			agents=self.agents, # Automatically created by the @agent decorator
			tasks=self.tasks, # Automatically created by the @task decorator
			process=Process.sequential,
			verbose=True
			# process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
		)

And the main.py

#!/usr/bin/env python
import sys
from ftsonboarding2.crew import Ftsonboarding2Crew

# This main file is intended to be a way for you to run your
# crew locally, so refrain from adding unnecessary logic into this file.
# Replace with inputs you want to test with, it will automatically
# interpolate any tasks and agents information

def run():
   
    email = input("Bitte geben Sie Ihre E-Mail-Adresse ein: ")
    inputs = {
        'email': email
    }
    Ftsonboarding2Crew().crew().kickoff(inputs=inputs)


def train():
    """
    Train the crew for a given number of iterations.
    """
    inputs = {
        "topic": "AI LLMs"
    }
    try:
        Ftsonboarding2Crew().crew().train(n_iterations=int(sys.argv[1]), filename=sys.argv[2], inputs=inputs)

    except Exception as e:
        raise Exception(f"An error occurred while training the crew: {e}")

def replay():
    """
    Replay the crew execution from a specific task.
    """
    try:
        Ftsonboarding2Crew().crew().replay(task_id=sys.argv[1])

    except Exception as e:
        raise Exception(f"An error occurred while replaying the crew: {e}")

def test():
    """
    Test the crew execution and returns the results.
    """
    inputs = {
        "topic": "AI LLMs"
    }
    try:
        Ftsonboarding2Crew().crew().test(n_iterations=int(sys.argv[1]), openai_model_name=sys.argv[2], inputs=inputs)

    except Exception as e:
        raise Exception(f"An error occurred while replaying the crew: {e}")

Do you need anything else?

Thx in advanced
Frank

Hi @Frank_Jelinek,
Appologies for delay, but I’m working while keeping an eye on topics.
@rokbenko does this look like a version bug to you?

@Frank_Jelinek How do you run the crew? What’s the command? Are you using Poetry?

I’m starting the crew with

crewai run

I’m not using poetry.

The installation was done via

pip crewai install

I just created a new crew and copied the agents and tasks one after the other to that new crew. The error is gone and the crew is working fine.

Thank you for your effort and willingness to help.
I think we can close the thread.

Thx
Frank

Hello Frank, how are you?

I have the same problem and I’m having trouble solving it.

Could you share how you structured this new team?

Hi,

to be honest it was not clear for me what has changed. I just created a new crew and used the code from the one that was not working.

I did not investigate further more and just accept the magic :wink:

Hello All,

I am having the same problem. Here is the o/p. Any help here is much appreciated. I followed the steps :

crewai create crew governance
crewai install
make changes agents.yaml & tasks.yaml
make changes in crew.py & main.py
crewai run

Running the Crew
Traceback (most recent call last):
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/.venv/bin/run_crew”, line 8, in
sys.exit(run())
^^^^^
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/src/governance/main.py”, line 15, in run
GovernanceCrew().crew().kickoff()
^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/.venv/lib/python3.12/site-packages/crewai/project/annotations.py”, line 85, in wrapper
task_instance = task_method(self)
^^^^^^^^^^^^^^^^^
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/.venv/lib/python3.12/site-packages/crewai/project/utils.py”, line 7, in memoized_func
cache[key] = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/.venv/lib/python3.12/site-packages/crewai/project/annotations.py”, line 13, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/src/governance/crew.py”, line 38, in suggestion_generation
return Task(
^^^^^
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/.venv/lib/python3.12/site-packages/pydantic/main.py”, line 212, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/.venv/lib/python3.12/site-packages/crewai/agents/agent_builder/base_agent.py”, line 136, in process_model_config
return process_config(values, cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/global/Downloads/Analytics_vidya/DeepLearning-CrewAI/governance/.venv/lib/python3.12/site-packages/crewai/utilities/config.py”, line 19, in process_config
config = values.get(“config”, {})
^^^^^^^^^^
AttributeError: ‘function’ object has no attribute ‘get’
An error occurred while running the crew: Command ‘[‘uv’, ‘run’, ‘run_crew’]’ returned non-zero exit status 1.

This is a shot in the dark (since it appears that at least one other person had their tasks in the correct order) but I was having this error too and this was my problem: Help with Task Context Resolution in CrewAI

So if you are defining a context list for a task (which I see was being referenced in at least one stack trace above) then make sure that the dependencies are defined before the tasks that depend on them.