fix(agents): reset executor state at the start of each task invocation#5022
Open
NIK-TIGER-BILL wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix(agents): reset executor state at the start of each task invocation#5022NIK-TIGER-BILL wants to merge 1 commit intocrewAIInc:mainfrom
NIK-TIGER-BILL wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
CrewAgentExecutor.invoke() and ainvoke() were not resetting
self.messages and self.iterations before starting a new execution,
causing subsequent tasks to inherit message history and iteration count
from previous tasks in the same Crew run.
Add explicit resets at the top of both invoke() and ainvoke():
self.messages = []
self.iterations = 0
This mirrors the behaviour of the experimental AgentExecutor which
uses a fresh AgentReActState() for every invocation.
Added regression tests in tests/agents/test_async_agent_executor.py
(TestExecutorStateReset) covering both sync and async paths.
Fixes crewAIInc#4389
Signed-off-by: NIK-TIGER-BILL <[email protected]>
e2e6862 to
d34938a
Compare
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.
Description
CrewAgentExecutor.invoke()andainvoke()were not resettingself.messagesandself.iterationsbefore starting a new execution. When the same executor instance is reused across tasks in a singleCrewrun, subsequent tasks inherit the message history and iteration count from previous tasks, leading to:Fix
Add explicit resets at the top of both
invoke()andainvoke():This mirrors the behaviour of the experimental
AgentExecutor, which uses a freshAgentReActState()for every invocation.Testing
Added
TestExecutorStateResetclass intests/agents/test_async_agent_executor.pywith two tests:test_invoke_resets_messages_and_iterations– verifies sync pathtest_ainvoke_resets_messages_and_iterations– verifies async pathFixes #4389