docs: fix incorrect code example in flow state persistence guide#5775
docs: fix incorrect code example in flow state persistence guide#5775NIK-TIGER-BILL wants to merge 1 commit into
Conversation
…wAIInc#5378) Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
📝 WalkthroughWalkthroughDocumentation for class-level flow state persistence is corrected to show explicit ChangesFlow State Persistence Documentation Fix
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/crewai/tests/test_flow_persistence.py (1)
394-397: ⚡ Quick winAdd an explicit
state.idcontinuity assertion for resume semantics.The value assertion is great, but adding
assert flow2.state.id == flow1.state.idwould directly lock in the documented “resume same lineage” contract.✅ Suggested test hardening
flow2 = PersistentCounterFlow() result2 = flow2.kickoff(inputs={"id": flow1.state.id}) + assert flow2.state.id == flow1.state.id assert result2 == 6 # resumed at 2, incremented to 3, doubled to 6🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/crewai/tests/test_flow_persistence.py` around lines 394 - 397, Add an explicit assertion that the resumed flow preserves lineage by checking flow2.state.id equals flow1.state.id after creating flow2 and calling flow2.kickoff; specifically, after result2 = flow2.kickoff(...) add assert flow2.state.id == flow1.state.id (before or alongside the existing value assertion) to enforce resume continuity for PersistentCounterFlow and its kickoff behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lib/crewai/tests/test_flow_persistence.py`:
- Around line 394-397: Add an explicit assertion that the resumed flow preserves
lineage by checking flow2.state.id equals flow1.state.id after creating flow2
and calling flow2.kickoff; specifically, after result2 = flow2.kickoff(...) add
assert flow2.state.id == flow1.state.id (before or alongside the existing value
assertion) to enforce resume continuity for PersistentCounterFlow and its
kickoff behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: feb1a95d-7993-43c9-87fc-3c118865c8c6
📒 Files selected for processing (3)
docs/en/guides/flows/mastering-flow-state.mdxdocs/ko/guides/flows/mastering-flow-state.mdxlib/crewai/tests/test_flow_persistence.py
Closes #5378
The class-level persistence example in the flow state guide claimed that state is automatically loaded on a second run, but the code never passed the previous flow's
state.idtokickoff(). Withoutinputs={"id": ...}the new flow instance starts with a fresh UUID and empty state, so the second run produces the same result as the first.Changes:
inputs={"id": flow1.state.id}on the second run.test_class_level_persistence_docs_example) that verifies the corrected example behaves as documented (first run = 2, resumed run = 6).Summary by CodeRabbit
Documentation
Tests