# Retry last task

**URL:** <https://community.crewai.com/t/retry-last-task/2154>\
**Category:** Crews\
**Tags:** agent, crewai\
**Created:** [December 19, 2024, 4:00pm UTC](https://community.crewai.com/t/retry-last-task/2154 "2024-12-19T16:00:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pataconpapi](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@pataconpapi](https://community.crewai.com/u/pataconpapi)\
**Post date:** [December 19, 2024, 4:00pm UTC](https://community.crewai.com/t/retry-last-task/2154/1 "2024-12-19T16:00:20Z")

</div>

Hi i would like to know if it possible to retry the last task. For example in this crew i have a reviewer agent, that checks for a condition if the condition is not passed then he should send it back to the last agent/task.  
I’ve read that I should use the crew context for this but i dont have any idea on how to implement it. has anyone done somethig like this before?

```
@CrewBase

```

class LatestAiDevelopmentCrew():  
“”“LatestAiDevelopment crew”“”

@agent  
def researcher(self) → Agent:  
return Agent(  
config=self.agents\_config[‘researcher’],  
verbose=True,  
tools=[SerperDevTool()]  
)

@agent  
def reporting\_analyst(self) → Agent:  
return Agent(  
config=self.agents\_config[‘reporting\_analyst’],  
verbose=True  
)

@agent  
def reviewer(self) → Agent:  
return Agent(  
config=self.agents\_config[‘reviewer’],  
verbose=True  
)

@task  
def research\_task(self) → Task:  
return Task(  
config=self.tasks\_config[‘research\_task’],  
)

@task  
def reporting\_task(self) → Task:  
return Task(  
config=self.tasks\_config[‘reporting\_task’],  
)

@task  
def reviewer\_task(self) → Task: # if review condition is not passed it should go back to reporting task  
def callback(result, context):  
review\_output = result.pydantic.passed  
print(f"review\_output, {review\_output}“)  
print(f"context, {context}”)

```
return Task(
 	config=self.tasks_config['review_task'],
callback=callback,
output_pydantic=ReviewResult
)

```

@crew  
def crew(self) → Crew:  
“”“Creates the LatestAiDevelopment 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,  
)
