refactor(agents): default Agent.executor_class to AgentExecutor#5737
Open
carladams1299-lab wants to merge 1 commit intocrewAIInc:mainfrom
Open
refactor(agents): default Agent.executor_class to AgentExecutor#5737carladams1299-lab wants to merge 1 commit intocrewAIInc:mainfrom
carladams1299-lab wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
Author
|
Hi, @greysonlalonde , |
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.
Closes #5736.
Summary
Two parallel agent executors currently coexist:
crewai.agents.crew_agent_executor.CrewAgentExecutor(1,615 lines, the historical default forAgent.execute_task())crewai.experimental.agent_executor.AgentExecutor(2,963 lines, aFlow[AgentExecutorState], used unconditionally byAgent.kickoff()and exported fromcrewai/__init__.py)Both subclass
BaseAgentExecutor, exposeinvoke(), register the same hooks, and reuse the helpers increwai.utilities.agent_utils. A singleAgentinstance can flow through either, depending on entry point — and_is_resuming_agent_executor()only works whenagent_executoris anAgentExecutor, so checkpoint resume is silently broken under the current default.This PR consolidates the runtime default without removing the legacy class:
Agent.executor_classnow defaults toAgentExecutor.Agent.kickoff()andAgent.execute_task()go through the same executor by default.CrewAgentExecutor.__init__emits aDeprecationWarningpointing to [BUG] Two parallel agent executors (CrewAgentExecutor vs experimental AgentExecutor) cover the same responsibility — pick a winner #5736.Out of scope (follow-ups)
AgentExecutorout ofcrewai.experimental.*intocrewai.agents.*. Touches ~27 files of imports and is mechanical — separate PR.CrewAgentExecutor. Needs at least one minor release of deprecation runway.tests/agents/test_agent_executor.pyandtests/agents/test_async_agent_executor.pyalong sync/async lines instead of legacy/experimental.handle_reasoning(crewai/agent/utils.py) andAgentExecutor.generate_plan()are intentional duals — both still work, the legacy helper is gated byif self.executor_class is not AgentExecutor(agent/core.py:515). Left alone here; they can converge after the legacy class is removed.Files changed
lib/crewai/src/crewai/agent/core.pyexecutor_classflipped; field description + Agent docstring +create_agent_executordocstring updatedlib/crewai/src/crewai/agents/agent_builder/base_agent.pyagent_executordescription correctedlib/crewai/src/crewai/agents/crew_agent_executor.pyDeprecationWarningadded in__init__;import warningsaddedDiff size: +15 / -7. No public API removed; existing user code that explicitly opts into
executor_class=CrewAgentExecutorkeeps working (with a warning).Test plan
I was unable to run the test suite locally (no resolved venv on the dev machine). Reviewers should confirm:
uv run pytest lib/crewai/tests/agents/ -x -quv run pytest lib/crewai/tests/agents/test_async_agent_executor.py -x -q -W "default::DeprecationWarning"— this file directly instantiatesCrewAgentExecutorand will now emit warnings; confirm none are promoted to errors elsewhereuv run pytest lib/crewai/tests/agents/test_agent.py -x -quv run mypy lib/crewai/src/crewai/agent/core.py lib/crewai/src/crewai/agents/executor_class == CrewAgentExecutoris either removed or updated (none found in a grep, but worth double-checking)Risks I'm aware of:
CrewAgentExecutorwill now see a warning at instantiation. If their CI treatsDeprecationWarningas an error, they'll needfilterwarnings. The repo itself has no such global filter, so internal tests should be unaffected.Agent.execute_task()now runs through the Flow-based executor by default. The Flow path stores the plan instate.planinstead of mutatingtask.description(an intentional improvement noted in the source), but consumers that readtask.descriptionpost-execution to recover the plan text will need to readagent_executor._state.planinstead.