# Running tasks in the loop / running task on task's callback

**URL:** <https://community.crewai.com/t/running-tasks-in-the-loop-running-task-on-tasks-callback/2229>\
**Category:** CrewAI Community Support\
**Tags:** crewai\
**Created:** [December 24, 2024, 11:02am UTC](https://community.crewai.com/t/running-tasks-in-the-loop-running-task-on-tasks-callback/2229 "2024-12-24T11:02:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![opahopa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/opahopa/32/1429_2.png) [@opahopa](https://community.crewai.com/u/opahopa)\
**Post date:** [December 24, 2024, 11:02am UTC](https://community.crewai.com/t/running-tasks-in-the-loop-running-task-on-tasks-callback/2229/1 "2024-12-24T11:02:20Z")

</div>

Hey,

I’m trying to make a loop of `implement -> test -> implement -> test` conditional tasks in my coding crew:

```auto
    @task
    def implement_support_files(self) -> Task:
        return Task(
            config=self.tasks_config['implement_support_files'],
            context=[self.analyze_requirements(), self.design_project_structure(), self.implement_crew_logic()],
            tools=[file_write_tool, code_interpreter_tool]
        )

    @task
    def review_implementation(self) -> Task:
        return Task(
            config=self.tasks_config['review_implementation'],
            context=[self.implement_crew_logic(), self.implement_support_files()],
            tools=[file_read_tool, docsSearchTool, self.directorySearchTool],
            callback=self.implement_review_changes
        )

    @task
    def implement_review_changes(self) -> Task:
        return Task(
            config=self.tasks_config['implement_review_changes'],
            context=[self.review_implementation()],
            tools=[file_write_tool, code_interpreter_tool],
            callback=self._track_review_iteration
        )

    def _track_review_iteration(self, output):
        self.review_iteration = getattr(self, 'review_iteration', 0) + 1
        if self.review_iteration < 2 and 'ISSUES FOUND:' in output.raw:
            return self.review_implementation()
        return output

```

is there a way to run `Task` in `callback` function?  
If not - what the best way to do so? What i want is that one agent review the other’s agent task result a few times.
