mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-07 15:18:29 +00:00
Fix issue #2356: Missing parentheses in Flow documentation
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
51
docs/fix-issue-2356.md
Normal file
51
docs/fix-issue-2356.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Fix for Issue #2356: Missing Parentheses in Flow Documentation
|
||||
|
||||
## Issue
|
||||
In the "first-flow.mdx" documentation, there's an error in the code example where a task method reference is missing parentheses:
|
||||
|
||||
```python
|
||||
@task
|
||||
def review_section_task(self) -> Task:
|
||||
return Task(
|
||||
config=self.tasks_config['review_section_task'],
|
||||
context=[self.write_section_task] # Missing parentheses
|
||||
)
|
||||
```
|
||||
|
||||
This causes an AttributeError when running `crewai flow kickoff` because the Flow system requires explicit method calls with parentheses.
|
||||
|
||||
## Error Message
|
||||
When users follow the documentation and use the code as shown, they encounter this error:
|
||||
```
|
||||
AttributeError: 'function' object has no attribute 'get'
|
||||
```
|
||||
|
||||
## Root Cause
|
||||
The core issue is that the Flow system in CrewAI requires explicit method calls with parentheses when processing context tasks. This is implemented in the `_map_task_variables` method in `crew_base.py`:
|
||||
|
||||
```python
|
||||
if context_list := task_info.get("context"):
|
||||
self.tasks_config[task_name]["context"] = [
|
||||
tasks[context_task_name]() for context_task_name in context_list
|
||||
]
|
||||
```
|
||||
|
||||
When users follow the documentation and use `context=[self.write_section_task]` without parentheses, they get an AttributeError because a function object doesn't have a `get` attribute.
|
||||
|
||||
## Fix
|
||||
The correct code should be:
|
||||
|
||||
```python
|
||||
@task
|
||||
def review_section_task(self) -> Task:
|
||||
return Task(
|
||||
config=self.tasks_config['review_section_task'],
|
||||
context=[self.write_section_task()] # Added parentheses
|
||||
)
|
||||
```
|
||||
|
||||
## Verification
|
||||
I've created a minimal reproducible example that demonstrates both the error and the fix. The error occurs because in `crew_base.py`, the `_map_task_variables` method explicitly requires method calls with parentheses when processing context tasks.
|
||||
|
||||
## Documentation Update Needed
|
||||
The documentation at docs.crewai.com/guides/flows/first-flow needs to be updated to show the correct syntax with parentheses.
|
||||
@@ -232,7 +232,7 @@ class ContentCrew():
|
||||
def review_section_task(self) -> Task:
|
||||
return Task(
|
||||
config=self.tasks_config['review_section_task'],
|
||||
context=[self.write_section_task]
|
||||
context=[self.write_section_task()]
|
||||
)
|
||||
|
||||
@crew
|
||||
@@ -601,4 +601,4 @@ Now that you've built your first flow, you can:
|
||||
|
||||
<Check>
|
||||
Congratulations! You've successfully built your first CrewAI Flow that combines regular code, direct LLM calls, and crew-based processing to create a comprehensive guide. These foundational skills enable you to create increasingly sophisticated AI applications that can tackle complex, multi-stage problems through a combination of procedural control and collaborative intelligence.
|
||||
</Check>
|
||||
</Check>
|
||||
|
||||
Reference in New Issue
Block a user