-
Fix cyclic flows silently breaking when persistence ID is passed in inputs (#4501)
发布于
2026-02-18 06:27:24 +00:00 - Implement user input handling in Flow class
- Introduced
FlowInputRequestedEventandFlowInputReceivedEventto manage user input requests and responses during flow execution. - Added
InputProviderprotocol andInputResponsedataclass for customizable input handling. - Enhanced
Flowclass withask()method to request user input, including timeout handling and state checkpointing. - Updated
FlowConfigto support custom input providers. - Created
input_provider.pyfor default input provider implementations, including a console-based provider. - Added comprehensive tests for
ask()functionality, covering basic usage, timeout behavior, and integration with flow machinery.
- Potential fix for pull request finding 'Unused import'
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
- Refactor test_flow_ask.py to streamline flow kickoff calls
- Removed unnecessary variable assignments for the result of
flow.kickoff()in two test cases, improving code clarity. - Updated assertions to ensure the expected execution log entries are present after the flow kickoff, enhancing test reliability.
- Add current_flow_method_name context variable for flow method tracking
- Introduced a new context variable,
current_flow_method_name, to store the name of the currently executing flow method, defaulting to "unknown". - Updated the Flow class to set and reset this context variable during method execution, enhancing the ability to track method calls without stack inspection.
- Removed the obsolete
_resolve_calling_method_namemethod, streamlining the code and improving clarity.
- Enhance input history management in Flow class
- Introduced a new
InputHistoryEntryTypedDict to structure user input history for theask()method, capturing details such as the question, user response, method name, timestamp, and associated metadata. - Updated the
_input_historyattribute in the Flow class to utilize the newInputHistoryEntrytype, improving type safety and clarity in input history management.
- Enhance timeout handling in Flow class input requests
- Updated the
ask()method to improve timeout management by manually managing theThreadPoolExecutor, preventing potential deadlocks when the provider call exceeds the timeout duration. - Added clarifications in the documentation regarding the behavior of the timeout and the underlying request handling, ensuring better understanding for users.
- Enhance memory reset functionality in CLI commands
- Introduced flow memory reset capabilities in the
reset_memories_command, allowing for both crew and flow memory resets. - Added a new utility function
_reset_flow_memoryto handle memory resets for individual flow instances, improving modularity and clarity. - Updated the
get_flowsutility to discover flow instances from project files, enhancing the CLI's ability to manage flow states. - Expanded test coverage to validate the new flow memory reset features, ensuring robust functionality and error handling.
-
LINTER
-
Fix resumption flag logic in Flow class and add regression test for cyclic flow persistence
- Updated the logic for setting the
_is_execution_resumingflag to ensure it only activates when there are completed methods to replay, preventing incorrect suppression of cyclic re-execution during state reloads. - Added a regression test to validate that cyclic router flows complete all iterations when persistence is enabled and an 'id' is passed in inputs, ensuring robust handling of flow execution in these scenarios.
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
下载附件