Fix issue #5736: Agent.kickoff() must honor executor_class#5738
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
Fix issue #5736: Agent.kickoff() must honor executor_class#5738devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
The two parallel agent-executor implementations (CrewAgentExecutor and
the experimental AgentExecutor) had drifted enough that the Agent class
silently routed kickoff() and execute_task() to different executors:
* Agent.execute_task() instantiated self.executor_class (default
CrewAgentExecutor).
* Agent.kickoff() hard-coded AgentExecutor, ignoring executor_class.
* The reasoning-gate guard 'self.executor_class is not AgentExecutor'
coupled feature behavior to literal class identity, so a subclass of
either executor that opted into / out of internal planning was
handled incorrectly.
This patch introduces two ClassVar capability flags on
BaseAgentExecutor:
* supports_internal_planning - whether the executor runs its own
planning/replanning loop (and therefore should NOT have the external
handle_reasoning step run before task execution).
* supports_kickoff - whether the executor implements the Flow-based
kickoff entry point.
AgentExecutor sets both to True; CrewAgentExecutor leaves both False.
The Agent class now consults these flags instead of testing class
identity:
* The reasoning gate is 'not getattr(executor_class,
supports_internal_planning, False)'.
* Agent.kickoff() routes through _resolve_kickoff_executor_class()
which honors executor_class when it advertises supports_kickoff and
otherwise emits a DeprecationWarning before falling back to
AgentExecutor for backwards compatibility.
A new test module
lib/crewai/tests/agents/test_executor_consistency.py pins down the
contract.
Co-Authored-By: João <joao@crewai.com>
Contributor
Author
|
Prompt hidden (unlisted session) |
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:
|
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.
Summary
Fixes #5736.
The two parallel agent-executor implementations —
CrewAgentExecutor(legacy, default forAgent.executor_class) and the experimentalAgentExecutor— had drifted enough that theAgentclass silently routedkickoff()andexecute_task()to different executors:Agent.execute_task()instantiatedself.executor_class(defaultCrewAgentExecutor).Agent.kickoff()hard-codedAgentExecutorand ignoredexecutor_classentirely.if self.executor_class is not AgentExecutor: handle_reasoning(...)coupled feature behavior to literal class identity, so any subclass of either executor that opted into or out of internal planning was handled incorrectly.This PR replaces both class-identity checks with two
ClassVarcapability flags onBaseAgentExecutor:supports_internal_planning— whether the executor runs its own planning/replanning loop (and therefore should not have the externalhandle_reasoningstep run before task execution).supports_kickoff— whether the executor implements the Flow-basedAgent.kickoff()entry point.AgentExecutorsets both toTrue;CrewAgentExecutorleaves bothFalse(defaults from the base class).Agentnow consults these flags:if not getattr(self.executor_class, "supports_internal_planning", False): handle_reasoning(...).Agent.kickoff()routes through a new_resolve_kickoff_executor_class()helper. When the configuredexecutor_classadvertisessupports_kickoff = True, that class is used verbatim. Otherwise — to preserve backwards compatibility for existing default-configured agents — the helper emits aDeprecationWarningand falls back toAgentExecutor. The warning message tells users how to silence it (executor_class=AgentExecutor).A new test module
lib/crewai/tests/agents/test_executor_consistency.py(12 tests) pins down the contract:Agent.kickoff()honors a kickoff-capableexecutor_class(including subclasses) without warning.Agent.kickoff()warns and falls back whenexecutor_classdoes not opt into kickoff (defaultCrewAgentExecutor).Agent.execute_task()instantiatesself.executor_class(regression guard for the existing path).CrewAgentExecutorsubclass that opts into internal planning correctly skipshandle_reasoning, and anAgentExecutorsubclass that opts out correctly runs it.Review & Testing Checklist for Human
"The silent fallback will be removed in a future release.") aligns with the team's deprecation policy and target release.Agent.kickoff()should eventually become a hard error whenexecutor_classdoesn't advertisesupports_kickoff, or whether the deprecation-then-fallback approach is the long-term plan.kickoff()/execute_task()rely on the oldself.executor_class is not AgentExecutorclass-identity check (a repo-wide grep was clean, but a second pair of eyes is worth it).Agent.kickoff()with planning enabled to confirm the deprecation warning surfaces in real usage and that planning still produces a sensible plan when callers explicitly opt intoexecutor_class=AgentExecutor.Notes
AgentExecutor/CrewAgentExecutorconstructor signatures or imports._resolve_kickoff_executor_class()is private; the public surface stays the same.ruff check,ruff format --check) andmypy --strictpass on all touched source files. The fulllib/crewai/tests/agents/suite (108 tests across both executor paths) passes locally.Link to Devin session: https://app.devin.ai/sessions/6be040b5f66d4cc797d36b5a7e144d59