diff --git a/lib/crewai/src/crewai/flow/flow.py b/lib/crewai/src/crewai/flow/flow.py index 699f63930..712c47657 100644 --- a/lib/crewai/src/crewai/flow/flow.py +++ b/lib/crewai/src/crewai/flow/flow.py @@ -77,7 +77,7 @@ from crewai.flow.flow_wrappers import ( StartMethod, ) from crewai.flow.persistence.base import FlowPersistence -from crewai.flow.types import FlowExecutionData, FlowMethodName, PendingListenerKey +from crewai.flow.types import FlowExecutionData, FlowMethodName, InputHistoryEntry, PendingListenerKey from crewai.flow.utils import ( _extract_all_methods, _extract_all_methods_recursive, @@ -786,7 +786,7 @@ class Flow(Generic[T], metaclass=FlowMeta): self.suppress_flow_events: bool = suppress_flow_events # User input history (for self.ask()) - self._input_history: list[dict[str, Any]] = [] + self._input_history: list[InputHistoryEntry] = [] # Initialize state with initial values self._state = self._create_initial_state() diff --git a/lib/crewai/src/crewai/flow/types.py b/lib/crewai/src/crewai/flow/types.py index 024de41df..65ed3a995 100644 --- a/lib/crewai/src/crewai/flow/types.py +++ b/lib/crewai/src/crewai/flow/types.py @@ -4,6 +4,7 @@ This module contains TypedDict definitions and type aliases used throughout the Flow system. """ +from datetime import datetime from typing import ( Annotated, Any, @@ -101,6 +102,30 @@ class FlowData(TypedDict): flow_methods_attributes: list[FlowMethodData] +class InputHistoryEntry(TypedDict): + """A single entry in the flow's input history from ``self.ask()``. + + Each call to ``Flow.ask()`` appends one entry recording the question, + the user's response, which method asked, and any metadata exchanged + between the caller and the input provider. + + Attributes: + message: The question or prompt that was displayed to the user. + response: The user's response, or None on timeout/error. + method_name: The flow method that called ``ask()``. + timestamp: When the input was received. + metadata: Metadata sent with the question (caller to provider). + response_metadata: Metadata received with the answer (provider to caller). + """ + + message: str + response: str | None + method_name: str + timestamp: datetime + metadata: dict[str, Any] | None + response_metadata: dict[str, Any] | None + + class FlowExecutionData(TypedDict): """Flow execution data.