adjusted the var name from AgentReActState to AgentExecutorState

This commit is contained in:
lorenzejay
2026-03-11 15:18:42 -07:00
parent cd7d033ac6
commit ecf4a5faca
2 changed files with 17 additions and 17 deletions

View File

@@ -106,11 +106,11 @@ if TYPE_CHECKING:
from crewai.utilities.prompts import StandardPromptResult, SystemPromptResult
class AgentReActState(BaseModel):
"""Structured state for agent ReAct flow execution.
class AgentExecutorState(BaseModel):
"""Structured state for agent executor flow.
Replaces scattered instance variables with validated immutable state.
Maps to: self.messages, self.iterations, formatted_answer in current executor.
Holds both ReAct iteration state and Plan-and-Execute state
(todos, observations, replan tracking) in a single validated model.
"""
messages: list[LLMMessage] = Field(default_factory=list)
@@ -143,11 +143,11 @@ class AgentReActState(BaseModel):
)
class AgentExecutor(Flow[AgentReActState], CrewAgentExecutorMixin):
class AgentExecutor(Flow[AgentExecutorState], CrewAgentExecutorMixin):
"""Agent Executor for both standalone agents and crew-bound agents.
Inherits from:
- Flow[AgentReActState]: Provides flow orchestration capabilities
- Flow[AgentExecutorState]: Provides flow orchestration capabilities
- CrewAgentExecutorMixin: Provides memory methods (short/long/external term)
This executor can operate in two modes:
@@ -258,7 +258,7 @@ class AgentExecutor(Flow[AgentReActState], CrewAgentExecutorMixin):
else self.stop
)
)
self._state = AgentReActState()
self._state = AgentExecutorState()
# Plan-and-Execute components (Phase 2)
# Lazy-imported to avoid circular imports during module load
@@ -311,7 +311,7 @@ class AgentExecutor(Flow[AgentReActState], CrewAgentExecutorMixin):
return self.llm.supports_stop_words() if self.llm else False
@property
def state(self) -> AgentReActState:
def state(self) -> AgentExecutorState:
"""Get state - returns temporary state if Flow not yet initialized.
Flow initialization is deferred to prevent event emission during agent setup.

View File

@@ -13,7 +13,7 @@ import pytest
from crewai.agents.step_executor import StepExecutor
from crewai.agents.planner_observer import PlannerObserver
from crewai.experimental.agent_executor import (
AgentReActState,
AgentExecutorState,
AgentExecutor,
)
from crewai.agents.parser import AgentAction, AgentFinish
@@ -26,12 +26,12 @@ from crewai.tools.tool_types import ToolResult
from crewai.utilities.step_execution_context import StepExecutionContext
from crewai.utilities.planning_types import TodoItem
class TestAgentReActState:
"""Test AgentReActState Pydantic model."""
class TestAgentExecutorState:
"""Test AgentExecutorState Pydantic model."""
def test_state_initialization(self):
"""Test AgentReActState initialization with defaults."""
state = AgentReActState()
"""Test AgentExecutorState initialization with defaults."""
state = AgentExecutorState()
assert state.iterations == 0
assert state.messages == []
assert state.current_answer is None
@@ -42,8 +42,8 @@ class TestAgentReActState:
assert state.plan_ready is False
def test_state_with_plan(self):
"""Test AgentReActState initialization with planning fields."""
state = AgentReActState(
"""Test AgentExecutorState initialization with planning fields."""
state = AgentExecutorState(
plan="Step 1: Do X\nStep 2: Do Y",
plan_ready=True,
)
@@ -51,9 +51,9 @@ class TestAgentReActState:
assert state.plan_ready is True
def test_state_with_values(self):
"""Test AgentReActState initialization with values."""
"""Test AgentExecutorState initialization with values."""
messages = [{"role": "user", "content": "test"}]
state = AgentReActState(
state = AgentExecutorState(
messages=messages,
iterations=5,
current_answer=AgentFinish(thought="thinking", output="done", text="final"),