Add regression tests for kickoff_for_each inside flows (#4385)#4386
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
Add regression tests for kickoff_for_each inside flows (#4385)#4386devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
Add tests covering crew.copy(), kickoff_for_each, kickoff_for_each_async, and akickoff_for_each when called inside a Flow[MyState] method. These tests ensure the fix from commit 9d7f453 (replacing parent_flow field with context variables) prevents the Pydantic validation error reported in issue #4385. Co-Authored-By: João <joao@crewai.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| Regression test for https://github.com/crewAIInc/crewAI/issues/4385 | ||
| """ | ||
|
|
||
| class MyState(BaseModel): |
| Regression test for https://github.com/crewAIInc/crewAI/issues/4385 | ||
| """ | ||
|
|
||
| class MyState(BaseModel): |
| Regression test for https://github.com/crewAIInc/crewAI/issues/4385 | ||
| """ | ||
|
|
||
| class MyState(BaseModel): |
| Regression test for https://github.com/crewAIInc/crewAI/issues/4385 | ||
| """ | ||
|
|
||
| class MyState(BaseModel): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add regression tests for kickoff_for_each inside flows (#4385)
Summary
Adds 4 regression tests for issue #4385, where
akickoff_for_each(and related methods) failed with a PydanticValidationErroron theparent_flowfield when aCrewwas created and copied inside aFlow[TypedState]method.The root cause was that the old
FlowTrackablemixin stored a directparent_flow: InstanceOf[Flow[Any]]reference. Whencrew.copy()calledmodel_dump(), this field was serialized and re-passed to theCrew(...)constructor, where Pydantic'sInstanceOfvalidator rejected the dynamically-created_FlowGenerictype. This was already fixed in9d7f4537by replacing theparent_flowfield with lightweight context variables (_flow_id,_request_id).This PR adds test coverage only — no production code changes. The four new tests are:
test_crew_copy_inside_typed_flowcrew.copy()inside aFlow[MyState]methodtest_kickoff_for_each_inside_flowcrew.kickoff_for_each()inside a sync Flow methodtest_kickoff_for_each_async_inside_flowcrew.kickoff_for_each_async()inside an async Flow methodtest_akickoff_for_each_inside_flowcrew.akickoff_for_each()inside an async Flow methodReview & Testing Checklist for Human
parent_flow: InstanceOf[Flow[Any]]field were reintroduced onFlowTrackable, these tests should fail with the reportedValidationError. Consider temporarily revertingflow_trackable.pyto confirm.kickoff/kickoff_async/akickoffmethods are mocked, so these tests primarily exercise thecrew.copy()path inside a flow context. They do not test full end-to-end execution. Decide if that's sufficient coverage.Notes