crewai - ✅(Solved) Fix [BUG] Wrong code in document [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#5378Fetched 2026-04-10 03:42:58
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1referenced ×1

Here is the result of the code

➜  crewai_test uv run python main.py

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Execution ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Starting Flow Execution                                                                                                                                                                                                                                      │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Started ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Started                                                                                                                                                                                                                                                 │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Flow started with ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f
Incremented to 1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Doubled to 2

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Completion ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Execution Completed                                                                                                                                                                                                                                     │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

First run result: 2
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Execution ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Starting Flow Execution                                                                                                                                                                                                                                      │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Started ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Started                                                                                                                                                                                                                                                 │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Flow started with ID: 8c95e24a-a64c-4146-a52e-ec49440806f5
Incremented to 1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Doubled to 2

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Completion ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Execution Completed                                                                                                                                                                                                                                     │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Second run result: 2

Root Cause

Here is the result of the code

➜  crewai_test uv run python main.py

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Execution ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Starting Flow Execution                                                                                                                                                                                                                                      │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Started ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Started                                                                                                                                                                                                                                                 │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Flow started with ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f
Incremented to 1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Doubled to 2

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Completion ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Execution Completed                                                                                                                                                                                                                                     │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

First run result: 2
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Execution ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Starting Flow Execution                                                                                                                                                                                                                                      │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Started ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Started                                                                                                                                                                                                                                                 │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Flow started with ID: 8c95e24a-a64c-4146-a52e-ec49440806f5
Incremented to 1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Doubled to 2

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Completion ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Execution Completed                                                                                                                                                                                                                                     │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Second run result: 2

Fix Action

Fixed

PR fix notes

PR #5379: fix: auto-restore persisted state for class-level @persist decorator

Description (problem / solution / changelog)

Summary

Fixes #5378. When @persist is applied at the class level, new flow instances now automatically load the most recent persisted state for that flow class. Previously, the documented PersistentCounterFlow example didn't work — users had to manually pass inputs={"id": old_uuid} to kickoff() to restore state, contradicting the docs.

How it works:

  • A new flow_class column is added to the flow_states SQLite table, populated with type(flow_instance).__name__ on each save.
  • A new load_latest_by_class(flow_class) method is added to FlowPersistence (default returns None) and implemented in SQLiteFlowPersistence.
  • The class-level @persist decorator's __init__ wrapper now calls load_latest_by_class after initialization and restores state if found.
  • Method-level @persist is not affected — it continues to only save, not auto-restore.
  • Custom persistence backends are backward-compatible: save_state passes flow_class as a kwarg with a TypeError fallback for backends that don't accept it.

Includes DB migration (ALTER TABLE ADD COLUMN) for existing databases and a new index on flow_class.

Review & Testing Checklist for Human

  • Behavioral change for existing users: Any code already using class-level @persist will now auto-load state on new instances. If anyone relied on fresh state each run with class-level @persist, this is a breaking change. Verify this is the intended behavior.
  • Class name used for lookup is __name__ only (not fully qualified). Two flow classes with the same name in different modules sharing the same DB would collide. Decide if __qualname__ or module + qualname is needed instead.
  • TypeError fallback in persist_state: The try/except that catches TypeError when passing flow_class to custom backends could mask unrelated TypeError bugs. Review whether this is acceptable or if a more targeted check (e.g. inspect.signature) would be safer.
  • save_pending_feedback does not populate flow_class: States saved via the HITL pending feedback path won't be found by load_latest_by_class. Verify this is acceptable.
  • Run uv run pytest lib/crewai/tests/test_flow_persistence.py -vv to verify all 12 tests pass. Consider also testing with an existing SQLite DB (without the flow_class column) to validate the migration path.

Notes

  • The base FlowPersistence.load_latest_by_class() returns None by default, so custom persistence implementations are unaffected unless they opt in.
  • Auto-restore failures are silently logged at DEBUG level to avoid breaking flows when persisted state is incompatible with a changed schema.

Link to Devin session: https://app.devin.ai/sessions/47c270d8584548d4a2683b7d021eb8d5

<!-- CURSOR_SUMMARY -->

[!NOTE] Medium Risk Behavior changes for any existing class-level @persist users (new instances may start with restored state instead of a fresh state). Includes a SQLite schema migration and new lookup path keyed by class name, which could cause unexpected restores if names collide or data is incompatible.

Overview Enables automatic state restoration when @persist is applied at the class level by loading the most recent persisted state for that flow class during __init__ and calling _restore_state (failures are swallowed with debug logging).

Extends the persistence API to pass an optional flow_class into save_state, adds FlowPersistence.load_latest_by_class() (no-op by default), and implements it in SQLiteFlowPersistence by migrating/adding a flow_class column + index on flow_states and querying the latest row by class. Adds comprehensive tests covering class-level auto-restore for typed and dict state, isolation between different flow classes, and confirming method-level @persist does not auto-restore.

<sup>Reviewed by Cursor Bugbot for commit 327a5c4193ccec1d0930ab60d61ceddbd733fd13. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai/src/crewai/flow/persistence/base.py (modified, +24/-1)
  • lib/crewai/src/crewai/flow/persistence/decorators.py (modified, +19/-0)
  • lib/crewai/src/crewai/flow/persistence/sqlite.py (modified, +55/-4)
  • lib/crewai/tests/test_flow_persistence.py (modified, +175/-0)

Code Example

➜  crewai_test uv run python main.py

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Execution ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Starting Flow ExecutionName: PersistentCounterFlowID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Started ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Flow StartedName: PersistentCounterFlowID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Flow started with ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f
Incremented to 1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Method: increment                                                                                                                                                                                                                                            │
Status: Running│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Method: increment                                                                                                                                                                                                                                            │
Status: Completed│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Doubled to 2

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Method: double                                                                                                                                                                                                                                               │
Status: Running│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Method: double                                                                                                                                                                                                                                               │
Status: Completed│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Completion ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Flow Execution CompletedName: PersistentCounterFlowID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

First run result: 2
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Execution ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Starting Flow ExecutionName: PersistentCounterFlowID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Started ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Flow StartedName: PersistentCounterFlowID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Flow started with ID: 8c95e24a-a64c-4146-a52e-ec49440806f5
Incremented to 1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Method: increment                                                                                                                                                                                                                                            │
Status: Running│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Method: increment                                                                                                                                                                                                                                            │
Status: Completed│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Doubled to 2

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Method: double                                                                                                                                                                                                                                               │
Status: Running│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Method: double                                                                                                                                                                                                                                               │
Status: Completed│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Completion ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
Flow Execution CompletedName: PersistentCounterFlowID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Second run result: 2
RAW_BUFFERClick to expand / collapse

Description

Here is the result of the code

➜  crewai_test uv run python main.py

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Execution ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Starting Flow Execution                                                                                                                                                                                                                                      │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Started ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Started                                                                                                                                                                                                                                                 │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Flow started with ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f
Incremented to 1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Doubled to 2

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Completion ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Execution Completed                                                                                                                                                                                                                                     │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8d6df07d-9cbd-4ea3-a1f3-5b186981032f                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

First run result: 2
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Execution ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Starting Flow Execution                                                                                                                                                                                                                                      │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🌊 Flow Started ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Started                                                                                                                                                                                                                                                 │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Flow started with ID: 8c95e24a-a64c-4146-a52e-ec49440806f5
Incremented to 1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: increment                                                                                                                                                                                                                                            │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Doubled to 2

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔄 Flow Method Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Running                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Method Completed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Method: double                                                                                                                                                                                                                                               │
│  Status: Completed                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✅ Flow Completion ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                               │
│  Flow Execution Completed                                                                                                                                                                                                                                     │
│  Name: PersistentCounterFlow                                                                                                                                                                                                                                  │
│  ID: 8c95e24a-a64c-4146-a52e-ec49440806f5                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Second run result: 2

Steps to Reproduce

Just run the code locally

Expected behavior

The result should double of the first result, but it didn't

Screenshots/Code snippets

Check the doc

Operating System

macOS Sonoma

Python Version

3.12

crewAI Version

1.14.1 and 1.12.2

crewAI Tools Version

NA

Virtual Environment

Venv

Evidence

NA

Possible Solution

NA

Additional context

System: macos M2 26.3.1 (25D2128) Python: 3.13.2

extent analysis

TL;DR

  • The issue seems to be related to the persistence of flow state in the PersistentCounterFlow, where the expected behavior is to double the result of the first run, but it doesn't.

Guidance

  • Review the implementation of PersistentCounterFlow to ensure it correctly persists and retrieves the state between runs.
  • Check the documentation for crewai to see if there are any specific requirements or limitations for persisting flow state.
  • Verify that the increment and double methods are correctly updating the flow state.
  • Consider adding logging or debugging statements to track the flow state throughout the execution.

Example

  • No specific code example can be provided without more context, but ensuring that the flow state is correctly persisted and retrieved between runs is crucial.

Notes

  • The issue might be related to the version of crewai being used (1.14.1 and 1.12.2), so checking the documentation for any version-specific limitations or changes is recommended.
  • The use of different Python versions (3.12 and 3.13.2) might also be a factor, so ensuring consistency in the Python version used could help resolve the issue.

Recommendation

  • Apply a workaround by manually persisting the flow state between runs, if possible, to achieve the expected behavior until a more permanent solution can be found.
  • The reason for this recommendation is that the issue seems to be related to the persistence of flow state, and manually handling this might provide a temporary fix.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The result should double of the first result, but it didn't

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING