Skip to content
Closed
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
10 changes: 10 additions & 0 deletions lib/crewai/src/crewai/experimental/agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
24 changes: 24 additions & 0 deletions lib/crewai/tests/agents/test_agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down