# "Context" Problem

**URL:** <https://community.crewai.com/t/context-problem/865>\
**Category:** CrewAI Community Support\
**Tags:** agent, crewai\
**Created:** [October 18, 2024, 8:39am UTC](https://community.crewai.com/t/context-problem/865 "2024-10-18T08:39:26Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 18, 2024, 8:39am UTC](https://community.crewai.com/t/context-problem/865/1 "2024-10-18T08:39:26Z")

</div>

Hello!

I have this problem, it says:

AttributeError: ‘str’ object has no attribute ‘get’

I am new to CrewAI and I would like to know what I could do to fix it, here is the whole error:

(smart-agents-dev) PS C:\Users\IA-User\Documents\smart-agents-dev\smart\_agents\> crewai run  
Running the Crew  
Traceback (most recent call last):  
File “”, line 1, in   
File “C:\Users\IA-User\Documents\smart-agents-dev\smart\_agents\src\smart\_agents\main.py”, line 26, in run  
SmartAgentsCrew().crew().kickoff(inputs=inputs)  
^^^^^^^^^^^^^^^^^  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 35, in **init**  
self.map\_all\_task\_variables()  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 133, in map\_all\_task\_variables  
self.\_map\_task\_variables(  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 155, in \_map\_task\_variables  
if context\_list := task\_info.get(“context”):  
^^^^^^^^^^^^^  
AttributeError: ‘str’ object has no attribute ‘get’  
An error occurred while running the crew: Command ‘[‘poetry’, ‘run’, ‘run\_crew’]’ returned non-zero exit status 1.

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [October 18, 2024, 8:45am UTC](https://community.crewai.com/t/context-problem/865/2 "2024-10-18T08:45:35Z")

</div>

@mkliangcoIA What’s the full command you ran? Can you show us the `pyproject.toml` file?

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 18, 2024, 8:48am UTC](https://community.crewai.com/t/context-problem/865/3 "2024-10-18T08:48:37Z")

</div>

the command is crewai run

and then here is the pyproject.toml file:

[tool.poetry]  
name = “smart\_agents”  
version = “0.1.0”  
description = “smart-agents using crewAI”  
authors = [“Your Name [you@example.com](mailto:you@example.com)”]

[tool.poetry.dependencies]  
python = “\>=3.10,\<=3.13”  
crewai = { extras = [“tools”], version = “\>=0.70.1,\<1.0.0” }

[tool.poetry.scripts]  
smart\_agents = “smart\_agents.main:run”  
run\_crew = “smart\_agents.main:run”  
train = “smart\_agents.main:train”  
replay = “smart\_agents.main:replay”  
test = “smart\_agents.main:test”

[build-system]  
requires = [“poetry-core”]  
build-backend = “poetry.core.masonry.api”

am i supposed to do crewai install again? Thank you

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [October 18, 2024, 8:52am UTC](https://community.crewai.com/t/context-problem/865/4 "2024-10-18T08:52:09Z")

</div>

> [@mkliangcoIA](#):
>
> smart\_agents

The correct command is: `poetry run smart_agents` or `poetry run run_crew`

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 18, 2024, 8:56am UTC](https://community.crewai.com/t/context-problem/865/5 "2024-10-18T08:56:23Z")

</div>

Hi rokbenko, the error still persists and i have tried both commands.

(smart-agents-dev) PS C:\Users\IA-User\Documents\smart-agents-dev\smart\_agents\> poetry run smart\_agents  
Traceback (most recent call last):  
File “”, line 1, in   
File “C:\Users\IA-User\Documents\smart-agents-dev\smart\_agents\src\smart\_agents\main.py”, line 26, in run  
SmartAgentsCrew().crew().kickoff(inputs=inputs)  
^^^^^^^^^^^^^^^^^  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 35, in **init**  
self.map\_all\_task\_variables()  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 133, in map\_all\_task\_variables  
self.\_map\_task\_variables(  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 155, in \_map\_task\_variables  
if context\_list := task\_info.get(“context”):  
^^^^^^^^^^^^^  
AttributeError: ‘str’ object has no attribute ‘get’

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 18, 2024, 8:58am UTC](https://community.crewai.com/t/context-problem/865/6 "2024-10-18T08:58:55Z")

</div>

For more context, I have a json file and csv file for the inputs.

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [October 18, 2024, 9:01am UTC](https://community.crewai.com/t/context-problem/865/7 "2024-10-18T09:01:36Z")

</div>

Let’s go step-by-step.

Step 1: Run `poetry install` (Note: It might take a looooong time!)  
Step 2: Run `poetry shell`  
Step 3: Run `poetry run smart_agents`

After you do all three steps, let me know if you still have a problem.

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 18, 2024, 9:06am UTC](https://community.crewai.com/t/context-problem/865/8 "2024-10-18T09:06:46Z")

</div>

Thanks for the fast reply. On the other hand, i’ve already installed poetry so it did not take long. Here is what transpired, and I am still getting the same issues. Thank you for your help and patience.

(smart-agents-dev) PS C:\Users\IA-User\Documents\smart-agents-dev\smart\_agents\> poetry install  
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: smart\_agents (0.1.0)  
(smart-agents-dev) PS C:\Users\IA-User\Documents\smart-agents-dev\smart\_agents\> poetry shell  
Virtual environment already activated: C:\Users\IA-User\Documents\smart-agents-dev  
(smart-agents-dev) PS C:\Users\IA-User\Documents\smart-agents-dev\smart\_agents\> poetry run smart\_agents  
Traceback (most recent call last):  
File “”, line 1, in   
File “C:\Users\IA-User\Documents\smart-agents-dev\smart\_agents\src\smart\_agents\main.py”, line 26, in run  
SmartAgentsCrew().crew().kickoff(inputs=inputs)  
^^^^^^^^^^^^^^^^^  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 35, in **init**  
self.map\_all\_task\_variables()  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 133, in map\_all\_task\_variables  
self.\_map\_task\_variables(  
File “C:\Users\IA-User\Documents\smart-agents-dev\Lib\site-packages\crewai\project\crew\_base.py”, line 155, in \_map\_task\_variables  
if context\_list := task\_info.get(“context”):  
^^^^^^^^^^^^^  
AttributeError: ‘str’ object has no attribute ‘get’

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [October 18, 2024, 9:10am UTC](https://community.crewai.com/t/context-problem/865/9 "2024-10-18T09:10:47Z")

</div>

> [@mkliangcoIA](#):
>
> SmartAgentsCrew().crew().kickoff(inputs=inputs)

Something is wrong with the way you pass inputs to the crew, I guess. Can you show the relevant code?

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 18, 2024, 9:16am UTC](https://community.crewai.com/t/context-problem/865/10 "2024-10-18T09:16:24Z")

</div>

Sure, thanks for your patients.

Here is a snippet of my inputs from main.py

with open(‘…/references/esi-sample.json.json’, ‘r’) as file:  
data = json.load(file)

df = pd.read\_csv(‘…/references/country\_sanction\_list.csv’)

def run():  
“”"  
Run the crew.  
“”"  
inputs = {  
‘ESI’ : data,  
‘sanction\_country’ : df  
}  
SmartAgentsCrew().crew().kickoff(inputs=inputs)

Then this is the snippet for my crew:

@CrewBase  
class SmartAgentsCrew():  
“”“SmartAgents crew”“”

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

@agent
def sanction_checker(self) -> Agent:
	return Agent(
		config=self.agents_config['sanction_checker'],
		verbose=True,
		llm = llm_ollama
	)

@task
def data_extracting_task(self) -> Task:
	return Task(
		config=self.tasks_config['data_extracting_task'],
		agent = self.data_extractor()
	)

@task
def sanction_task(self) -> Task:
	return Task(
		config=self.tasks_config['sanction_task'],
		agent = self.sanction_checker(),
		output_file='report.md'
	)

@crew
def crew(self) -> Crew:
	"""Creates the SmartAgents 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/
	)

```

That’s basically it.

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 19, 2024, 10:01am UTC](https://community.crewai.com/t/context-problem/865/11 "2024-10-19T10:01:54Z")

</div>

Is what I sent sufficient? Thanks

---

<div class="post-metadata">

**Author:** ![matt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/matt/32/3_2.png) [@matt](https://community.crewai.com/u/matt)\
**Post date:** [October 19, 2024, 1:22pm UTC](https://community.crewai.com/t/context-problem/865/12 "2024-10-19T13:22:30Z")

</div>

What version are you running?

---

<div class="post-metadata">

**Author:** ![Lorenze\_Jay](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/lorenze_jay/32/637_2.png) [@Lorenze\_Jay](https://community.crewai.com/u/Lorenze_Jay)\
**Post date:** [October 19, 2024, 10:30pm UTC](https://community.crewai.com/t/context-problem/865/13 "2024-10-19T22:30:47Z")

</div>

Seems like something is wrong with how you defined context. Context should point to tasks. So if you go to your tasks.yaml, do you have context defined there ?

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 21, 2024, 1:28am UTC](https://community.crewai.com/t/context-problem/865/14 "2024-10-21T01:28:43Z")

</div>

Hi! Sorry for the late response.

My crewai version is 0.70.1  
poetry is 1.8.4  
python 3.11.9

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 21, 2024, 1:30am UTC](https://community.crewai.com/t/context-problem/865/15 "2024-10-21T01:30:10Z")

</div>

Hi! It seems so. How do I define a context?

My task.yaml looks like this:

data\_extracting\_task:  
description: \>  
From the ESI File {ESI}, extract the Booking Number information from the Booking Number field.  
expected\_output: \>  
Booking Number :   
agent: data\_extractor

sanction\_task:  
description: \>  
Instructions:  
1. From the ESI File {ESI} extract every country name mentioned.  
2. Cross-reference the extracted country names with the country names column in the list of sanctioned countries file {sanction\_country}.  
3. If there is a match, print there is a match.  
expected\_output: \>  
Extracted Country Names - Country Status  
agent: sanction\_agent

---

<div class="post-metadata">

**Author:** ![mkliangcoIA](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mkliangcoIA](https://community.crewai.com/u/mkliangcoIA)\
**Post date:** [October 21, 2024, 4:01am UTC](https://community.crewai.com/t/context-problem/865/16 "2024-10-21T04:01:50Z")

</div>

Hi team!

Thank you for all your help, I’ve solved the issue by re-creating my crew and then converting my dateframe to be a dictionary.

You guys have been huge help for me. Thank you so much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex025/uploads/crewai/original/1X/ecda97e72f77c7100e0a761444b1c991925cc789.png) [@system](https://community.crewai.com/u/system)\
**Post date:** [October 22, 2024, 4:02am UTC](https://community.crewai.com/t/context-problem/865/17 "2024-10-22T04:02:01Z")

</div>

Closed on October 22, 2024, 4:02am UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
