Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/edge/ar/learn/llm-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def after_hook(context: LLMCallHookContext) -> str | None:

```python
class LLMCallHookContext:
executor: CrewAgentExecutor # Full executor reference
executor: AgentExecutor # Full executor reference
messages: list # Mutable message list
agent: Agent # Current agent
task: Task # Current task
Expand All @@ -64,6 +64,8 @@ class LLMCallHookContext:
response: str | None # LLM response (after hooks only)
```

يُستورَد `AgentExecutor` من `crewai.agents`. تمت إزالة `CrewAgentExecutor` ومسار الاستيراد `crewai.experimental.agent_executor`.

### تعديل الرسائل

**مهم:** قم دائماً بتعديل الرسائل في مكانها:
Expand Down
4 changes: 3 additions & 1 deletion docs/edge/en/learn/llm-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The `LLMCallHookContext` object provides comprehensive access to execution state

```python
class LLMCallHookContext:
executor: CrewAgentExecutor | LiteAgent | None # Executor (None for direct LLM calls)
executor: AgentExecutor | LiteAgent | None # Executor (None for direct LLM calls)
messages: list # Mutable message list
agent: Agent | None # Current agent (None for direct LLM calls)
task: Task | None # Current task (None for direct calls or LiteAgent)
Expand All @@ -66,6 +66,8 @@ class LLMCallHookContext:
response: str | None # LLM response (POST_MODEL_CALL only)
```

`AgentExecutor` is imported from `crewai.agents`. `CrewAgentExecutor` and the `crewai.experimental.agent_executor` import path have been removed.

The context also exposes `request_human_input(prompt, default_message)`, which
pauses live console updates and collects input from the terminal — useful for
approval gates.
Expand Down
2 changes: 1 addition & 1 deletion docs/edge/ko/learn/execution-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ LLM 실행 상태에 대한 액세스를 제공합니다:

```python
class LLMCallHookContext:
executor: CrewAgentExecutor # 전체 실행자 액세스
executor: AgentExecutor # 전체 실행자 액세스
messages: list # 변경 가능한 메시지 목록
agent: Agent # 현재 에이전트
task: Task # 현재 작업
Expand Down
4 changes: 3 additions & 1 deletion docs/edge/ko/learn/llm-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def after_hook(context: LLMCallHookContext) -> str | None:

```python
class LLMCallHookContext:
executor: CrewAgentExecutor # 전체 실행자 참조
executor: AgentExecutor # 전체 실행자 참조
messages: list # 변경 가능한 메시지 목록
agent: Agent # 현재 에이전트
task: Task # 현재 작업
Expand All @@ -64,6 +64,8 @@ class LLMCallHookContext:
response: str | None # LLM 응답 (후 훅용)
```

`AgentExecutor`는 `crewai.agents`에서 가져옵니다. `CrewAgentExecutor`와 `crewai.experimental.agent_executor` 가져오기 경로는 제거되었습니다.

### 메시지 수정

**중요:** 항상 메시지를 제자리에서 수정하세요:
Expand Down
2 changes: 1 addition & 1 deletion docs/edge/pt-BR/learn/execution-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Fornece acesso ao estado de execução do LLM:

```python
class LLMCallHookContext:
executor: CrewAgentExecutor # Acesso completo ao executor
executor: AgentExecutor # Acesso completo ao executor
messages: list # Lista de mensagens mutável
agent: Agent # Agente atual
task: Task # Tarefa atual
Expand Down
4 changes: 3 additions & 1 deletion docs/edge/pt-BR/learn/llm-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ O objeto `LLMCallHookContext` fornece acesso abrangente ao estado de execução:

```python
class LLMCallHookContext:
executor: CrewAgentExecutor # Referência completa ao executor
executor: AgentExecutor # Referência completa ao executor
messages: list # Lista de mensagens mutável
agent: Agent # Agente atual
task: Task # Tarefa atual
Expand All @@ -64,6 +64,8 @@ class LLMCallHookContext:
response: str | None # Resposta do LLM (apenas hooks posteriores)
```

`AgentExecutor` é importado de `crewai.agents`. `CrewAgentExecutor` e o caminho de importação `crewai.experimental.agent_executor` foram removidos.

### Modificando Mensagens

**Importante:** Sempre modifique mensagens in-place:
Expand Down
7 changes: 1 addition & 6 deletions lib/crewai/src/crewai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def __getattr__(name: str) -> Any:
from crewai.agents.agent_builder.base_agent_executor import (
BaseAgentExecutor as _BaseAgentExecutor,
)
from crewai.agents.agent_executor import AgentExecutor as _AgentExecutor
from crewai.agents.tools_handler import ToolsHandler as _ToolsHandler
from crewai.experimental.agent_executor import AgentExecutor as _AgentExecutor
from crewai.hooks.llm_hooks import LLMCallHookContext as _LLMCallHookContext
from crewai.tools.tool_types import ToolResult as _ToolResult
from crewai.utilities.prompts import (
Expand Down Expand Up @@ -138,22 +138,17 @@ def __getattr__(name: str) -> Any:
Crew.__module__,
Flow.__module__,
Task.__module__,
"crewai.agents.crew_agent_executor",
_runtime_state_mod.__name__,
_AgentExecutor.__module__,
):
sys.modules[_mod_name].__dict__.update(_resolve_namespace)

from crewai.agents.crew_agent_executor import (
CrewAgentExecutor as _CrewAgentExecutor,
)
from crewai.tasks.conditional_task import ConditionalTask as _ConditionalTask

_BaseAgentExecutor.model_rebuild(force=True, _types_namespace=_full_namespace)
_BaseAgent.model_rebuild(force=True, _types_namespace=_full_namespace)
Task.model_rebuild(force=True, _types_namespace=_full_namespace)
_ConditionalTask.model_rebuild(force=True, _types_namespace=_full_namespace)
_CrewAgentExecutor.model_rebuild(force=True, _types_namespace=_full_namespace)
Crew.model_rebuild(force=True, _types_namespace=_full_namespace)
Flow.model_rebuild(force=True, _types_namespace=_full_namespace)
_AgentExecutor.model_rebuild(force=True, _types_namespace=_full_namespace)
Expand Down
47 changes: 18 additions & 29 deletions lib/crewai/src/crewai/agent/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
_serialize_llm_ref,
_validate_llm_ref,
)
from crewai.agents.agent_executor import AgentExecutor
from crewai.agents.cache.cache_handler import CacheHandler
from crewai.agents.crew_agent_executor import CrewAgentExecutor
from crewai.events.event_bus import crewai_event_bus
from crewai.events.types.agent_events import (
AgentExecutionCompletedEvent,
Expand All @@ -74,7 +74,6 @@
)
from crewai.events.types.skill_events import SkillUsedEvent
from crewai.execution import begin_execution, end_execution
from crewai.experimental.agent_executor import AgentExecutor
from crewai.hooks.dispatch import HookAborted
from crewai.knowledge.knowledge import Knowledge
from crewai.knowledge.source.base_knowledge_source import BaseKnowledgeSource
Expand Down Expand Up @@ -148,34 +147,30 @@
)

_EXECUTOR_CLASS_MAP: dict[str, type] = {
"CrewAgentExecutor": CrewAgentExecutor,
"AgentExecutor": AgentExecutor,
}


def _is_resuming_agent_executor(
executor: CrewAgentExecutor | AgentExecutor | None,
executor: AgentExecutor | None,
) -> TypeIs[AgentExecutor]:
"""Type guard: True when the executor is resuming from a checkpoint."""
return isinstance(executor, AgentExecutor) and executor._resuming


def _validate_executor_class(value: Any) -> Any:
if getattr(value, "__name__", None) == "CrewAgentExecutor" or (
isinstance(value, str) and value == "CrewAgentExecutor"
):
raise ValueError(
"CrewAgentExecutor has been removed. Use "
"crewai.agents.agent_executor.AgentExecutor."
)
if isinstance(value, str):
cls = _EXECUTOR_CLASS_MAP.get(value)
if cls is None:
raise ValueError(f"Unknown executor class: {value}")
value = cls
import warnings

if value is CrewAgentExecutor:
warnings.warn(
"CrewAgentExecutor is deprecated and will be removed in a future release. "
"Agents inside Crews now use AgentExecutor by default. "
"Switch to crewai.experimental.AgentExecutor.",
DeprecationWarning,
stacklevel=3,
)
return cls
return value


Expand Down Expand Up @@ -222,7 +217,7 @@ class Agent(BaseAgent):
The agent can also have memory, can operate in verbose mode, and can delegate tasks to other agents.

Attributes:
agent_executor: An instance of the CrewAgentExecutor or AgentExecutor class.
agent_executor: The AgentExecutor running this agent.
role: The role of the agent.
goal: The objective of the agent.
backstory: The backstory of the agent.
Expand Down Expand Up @@ -390,16 +385,17 @@ class Agent(BaseAgent):
Can be a single A2AConfig/A2AClientConfig/A2AServerConfig, or a list of any number of A2AConfig/A2AClientConfig with a single A2AServerConfig.
""",
)
agent_executor: CrewAgentExecutor | AgentExecutor | None = Field(
default=None, description="An instance of the CrewAgentExecutor class."
agent_executor: AgentExecutor | None = Field(
default=None,
description="Executor running this agent.",
)
executor_class: Annotated[
type[CrewAgentExecutor] | type[AgentExecutor],
type[AgentExecutor],
BeforeValidator(_validate_executor_class),
PlainSerializer(_serialize_executor_class, return_type=str, when_used="json"),
] = Field(
default=AgentExecutor,
description="Class to use for the agent executor. Defaults to AgentExecutor, can optionally use CrewAgentExecutor.",
description="Class to use for the agent executor. CrewAgentExecutor has been removed.",
)

@model_validator(mode="before")
Expand Down Expand Up @@ -1262,11 +1258,7 @@ def _build_execution_prompt(
def create_agent_executor(
self, tools: list[BaseTool] | None = None, task: Task | None = None
) -> None:
"""Create an agent executor for the agent.

Returns:
An instance of the CrewAgentExecutor class.
"""
"""Create the AgentExecutor for the agent."""
configured_tools = tools if tools is not None else self.tools or []
raw_tools = self._add_skill_loader_tool(list(configured_tools), task=task)
parsed_tools = parse_tools(raw_tools)
Expand Down Expand Up @@ -1346,10 +1338,7 @@ def _update_executor_parameters(
self.agent_executor.tools = tools
self.agent_executor.original_tools = raw_tools
self.agent_executor.prompt = prompt
if isinstance(self.agent_executor, AgentExecutor):
self.agent_executor.stop_words = stop_words
else:
self.agent_executor.stop = stop_words
self.agent_executor.stop_words = stop_words
self.agent_executor.tools_names = get_tool_names(tools)
self.agent_executor.tools_description = render_text_description_and_args(tools)
self.agent_executor.response_model = (
Expand Down
3 changes: 1 addition & 2 deletions lib/crewai/src/crewai/agent/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def handle_reasoning(agent: Agent, task: Task) -> None:
This function checks if planning is enabled for the agent and, if so,
creates a plan that gets appended to the task description.

Note: This function is used by CrewAgentExecutor (legacy path).
For AgentExecutor, planning is handled in AgentExecutor.generate_plan().
AgentExecutor handles planning in AgentExecutor.generate_plan().

Args:
agent: The agent performing the task.
Expand Down
19 changes: 14 additions & 5 deletions lib/crewai/src/crewai/agents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,32 @@


if TYPE_CHECKING:
from crewai.agents.crew_agent_executor import CrewAgentExecutor
from crewai.agents.agent_executor import AgentExecutor, AgentExecutorState


__all__ = [
"AgentAction",
"AgentExecutor",
"AgentExecutorState",
"AgentFinish",
"CacheHandler",
"CrewAgentExecutor",
"OutputParserError",
"ToolsHandler",
"parse",
]

_LAZY_EXPORTS = {
"AgentExecutor": ("crewai.agents.agent_executor", "AgentExecutor"),
"AgentExecutorState": ("crewai.agents.agent_executor", "AgentExecutorState"),
}


def __getattr__(name: str) -> Any:
if name == "CrewAgentExecutor":
from crewai.agents.crew_agent_executor import CrewAgentExecutor
if name in _LAZY_EXPORTS:
import importlib

return CrewAgentExecutor
module_path, attr = _LAZY_EXPORTS[name]
value = getattr(importlib.import_module(module_path), attr)
globals()[name] = value
return value
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
10 changes: 6 additions & 4 deletions lib/crewai/src/crewai/agents/agent_builder/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def _resolve_agent(value: Any, info: Any) -> Any:

_EXECUTOR_TYPE_REGISTRY: dict[str, str] = {
"base": "crewai.agents.agent_builder.base_agent_executor.BaseAgentExecutor",
"crew": "crewai.agents.crew_agent_executor.CrewAgentExecutor",
"experimental": "crewai.experimental.agent_executor.AgentExecutor",
"agent": "crewai.agents.agent_executor.AgentExecutor",
}


Expand Down Expand Up @@ -203,7 +202,7 @@ class BaseAgent(BaseModel, ABC, metaclass=AgentMeta):
allow_delegation (bool): Allow delegation of tasks to agents.
tools (list[Any] | None): Tools at the agent's disposal.
max_iter (int): Maximum iterations for an agent to execute a task.
agent_executor: An instance of the CrewAgentExecutor class.
agent_executor: The executor running this agent. Defaults to AgentExecutor.
i18n (I18N): Internationalization settings.
llm (Any): Language model that will run the agent.
crew (Any): Crew to which the agent belongs.
Expand Down Expand Up @@ -301,7 +300,10 @@ class BaseAgent(BaseModel, ABC, metaclass=AgentMeta):
PlainSerializer(
_serialize_executor_ref, return_type=dict | None, when_used="json"
),
] = Field(default=None, description="An instance of the CrewAgentExecutor class.")
] = Field(
default=None,
description="Executor running this agent. Defaults to AgentExecutor.",
)
i18n: I18N = Field(
default_factory=get_i18n,
description="Internationalization settings.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class AgentExecutor(Flow[AgentExecutorState], BaseAgentExecutor):

_skip_auto_memory: bool = True

executor_type: Literal["experimental"] = "experimental"
executor_type: Literal["agent"] = "agent"
suppress_flow_events: bool = True # always suppress for executor
is_crewai_internal: ClassVar[bool] = True
llm: BaseLLM | None = Field(default=None, exclude=True)
Expand Down Expand Up @@ -3539,7 +3539,3 @@ def _format_feedback_message(self, feedback: str) -> LLMMessage:
return format_message_for_llm(
I18N_DEFAULT.slice("feedback_instructions").format(feedback=feedback)
)


# Backward compatibility alias (deprecated)
CrewAgentExecutorFlow = AgentExecutor
Loading
Loading