diff --git a/lib/crewai/src/crewai/experimental/agent_executor.py b/lib/crewai/src/crewai/experimental/agent_executor.py index 3cc9cdd7be..5ccaab8810 100644 --- a/lib/crewai/src/crewai/experimental/agent_executor.py +++ b/lib/crewai/src/crewai/experimental/agent_executor.py @@ -259,6 +259,16 @@ def state(self) -> AgentExecutorState: """Get thread-safe state proxy.""" return StateProxy(self._state, self._state_lock) # type: ignore[return-value] + @property + def ask_for_human_input(self) -> bool: + """Whether the executor should request human feedback.""" + return bool(self._state.ask_for_human_input) + + @ask_for_human_input.setter + def ask_for_human_input(self, value: bool) -> None: + """Update the human feedback flag stored in executor state.""" + self._state.ask_for_human_input = value + @property # type: ignore[misc] def iterations(self) -> int: """Compatibility property for mixin - returns state iterations.""" diff --git a/lib/crewai/tests/agents/test_agent_executor.py b/lib/crewai/tests/agents/test_agent_executor.py index 5868a7ce2e..cb224a6cc6 100644 --- a/lib/crewai/tests/agents/test_agent_executor.py +++ b/lib/crewai/tests/agents/test_agent_executor.py @@ -18,6 +18,7 @@ from crewai.agents.tools_handler import ToolsHandler as _ToolsHandler from crewai.agents.step_executor import StepExecutor +from crewai.core.providers.human_input import SyncHumanInputProvider def _build_executor(**kwargs: Any) -> AgentExecutor: @@ -116,6 +117,29 @@ class TestAgentExecutor: class StructuredResult(BaseModel): value: str + def test_ask_for_human_input_delegates_to_state(self): + """ExecutorContext compatibility should read and write the state flag.""" + executor = _build_executor() + + executor.state.ask_for_human_input = True + assert executor.ask_for_human_input is True + + executor.ask_for_human_input = False + assert executor.state.ask_for_human_input is False + + def test_human_input_provider_can_update_executor_state_flag(self): + """Human input providers should be able to mutate the executor context.""" + executor = _build_executor(crew=None) + executor.state.ask_for_human_input = True + answer = AgentFinish(thought="done", output="final", text="final") + + result = SyncHumanInputProvider()._handle_regular_feedback( + answer, "", executor + ) + + assert result is answer + assert executor.state.ask_for_human_input is False + def test_inject_files_from_crew_task_store(self): """Crew-level input_files should attach to the LLM user message.""" crew_id = uuid4()