Skip to content

Flow: persists across calls — no automatic reset #6639

Closed

Description

@akrhin

Description

In Flow, retry_count accumulates across multiple kickoff() calls. If the state has retry_count: int = 0 and max_retries: int = 3, after one full run (3 attempts) the counter is 3. A second kickoff() call starts from 3, immediately hitting max_retries escalation on the first task.

Steps to reproduce

@persist(...)
class TestFlow(Flow[TestState]):
    @start()
    def start(self):
        pass
    
    @listen("builder")
    def builder_plan(self):
        # retry_count is already 3 from previous run
        pass
    
    @router(builder_code)
    def builder_verify(self, code_output):
        self.state.retry_count += 1
        if self.state.retry_count >= self.state.max_retries:
            return "escalated"
        return "needs_revision"
  1. Run flow once → retry_count = 3 after max retries
  2. Call flow.kickoff() again → retry_count starts at 3 → immediately escalated

Expected

retry_count should reset to 0 when a flow run starts, or at least when kickoff() is called. Same applies to any counter field used for per-run tracking.

Workaround

Manually reset counters in @start() method:

@start()
def start(self):
    self.state.retry_count = 0

Environment

  • CrewAI: 1.15.5
  • Python: 3.11

Activity

  1. akrhin commented on Jul 25, 2026

    @akrhin
    Author

    Closed — intended behavior. Flow state persists across kickoff() calls by design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions