# Help with Task Context Resolution in CrewAI

**URL:** <https://community.crewai.com/t/help-with-task-context-resolution-in-crewai/1384>\
**Category:** CrewAI Community Support\
**Created:** [November 13, 2024, 1:26pm UTC](https://community.crewai.com/t/help-with-task-context-resolution-in-crewai/1384 "2024-11-13T13:26:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![olaservo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/olaservo/32/971_2.png) [@olaservo](https://community.crewai.com/u/olaservo)\
**Post date:** [November 13, 2024, 1:26pm UTC](https://community.crewai.com/t/help-with-task-context-resolution-in-crewai/1384/1 "2024-11-13T13:26:28Z")

</div>

I’m encountering an issue with task context resolution in CrewAI. I’m using version 0.76.9. When a task references another task in its context list, if appears to be causing configuration processing errors.

## Example Config

```yaml
assign_experts:
  description: >
    Sample description
  expected_output: >
    Sample expected output
  agent: expert_picker
  output_file: assigned_tasks.yaml
  context:
    - collect_tasks

collect_tasks:
  description: >
    Sample description
  expected_output: >
    Sample expected output
  agent: task_picker

```

## Current Behavior

When processing the context list in `crew_base.py`, the code immediately instantiates referenced tasks, which causes a second `process_config` call that tries to process the agent name string as configuration data.

The exact error I get is `AttributeError: 'str' object has no attribute 'get'` which is triggered because the string “collect\_tasks” is being referenced as if its a config dictionary.

Is this a bug or am I doing this wrong?

Thanks!

---

<div class="post-metadata">

**Author:** ![olaservo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/olaservo/32/971_2.png) [@olaservo](https://community.crewai.com/u/olaservo)\
**Post date:** [November 13, 2024, 5:09pm UTC](https://community.crewai.com/t/help-with-task-context-resolution-in-crewai/1384/2 "2024-11-13T17:09:13Z")

</div>

I think I figured out what is wrong. This error happens if the tasks are defined out of order. For example, if task2 includes task1 as context but task2 is defined first in the yaml list, you will get this error when crew\_base.py attempts to reference the task dependency. It seems that when it can’t find the task definition, it tries to create an instance of the missing task, which results in the process\_config ultimately trying to reference the task string as a task config.

---

<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:** [November 14, 2024, 5:09pm UTC](https://community.crewai.com/t/help-with-task-context-resolution-in-crewai/1384/3 "2024-11-14T17:09:19Z")

</div>

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