Langflow is a powerful tool for building and deploying AI-powered agents and workflows.
fix(graph): fixes bug that caused simple flows with Loop to fail (#8809)
* fix: improve predecessors check for loop component - Enhanced the handling of cycle vertices to prevent infinite loops by ensuring that a vertex can only run if all pending predecessors have completed. - Updated conditions for the first execution of cycle vertices to allow running only if all pending predecessors are also cycle vertices. - This refactor improves the robustness of the vertex management system in asynchronous workflows. * fix: update _mark_branch method to return visited vertices and refine predecessor mapping * fix: prevent duplicate item dependencies in LoopComponent * feat: add loop connection handling in Component class - Introduced methods to process loop feedback connections, allowing components to connect outputs to loop-enabled inputs. - Implemented checks to validate loop connections and ensure proper handling of callable methods from other components. - Enhanced the edge creation logic to support special loop feedback edges targeting outputs instead of inputs. * fix: enhance name overlap validation in FrontendNode - Updated the validate_name_overlap method to exclude outputs that allow loops from the overlap check. - Improved error message to include the display name of the component, along with detailed lists of input and output names for better debugging. * fix: correct condition for executing cycle vertices in RunnableVerticesManager - Updated the logic to ensure that a cycle vertex can only execute if it is a loop and all pending predecessors are cycle vertices. This change enhances the robustness of the vertex management system in asynchronous workflows. * feat: implement comprehensive loop flow for URL processing - Added a new loop flow that processes multiple URLs through a series of components including URLComponent, SplitTextComponent, LoopComponent, ParserComponent, PromptComponent, OpenAIModelComponent, StructuredOutputComponent, and ChatOutput. - Enhanced the StructuredOutputComponent to include a detailed system prompt and refined output schema to ensure proper JSON formatting. - Introduced a test case to validate the creation and execution of the loop flow, ensuring all components are correctly integrated and the expected execution order is maintained. * refactor: enhance loop target handling in Component and Edge classes - Introduced LoopTargetHandleDict to better manage loop target structures in the Component and Edge classes. - Updated the Component class to utilize type casting for loop target handles, improving type safety. - Refactored the Edge class to accommodate the new loop target handling, ensuring compatibility with existing edge structures. - Removed deprecated message handling methods from the Component class to streamline the codebase and improve maintainability. * test: skip OpenAI model integration test if API key is not set - Added a conditional skip to the test_build_model_integration_reasoning method to prevent execution when the OPENAI_API_KEY environment variable is not set, ensuring tests run only in appropriate environments. * [autofix.ci] apply automated fixes * chore: add required secrets for OpenAI and Anthropic APIs in CI workflows * Updated ci.yml to include OPENAI_API_KEY and ANTHROPIC_API_KEY secrets. * Modified python_test.yml to mark these secrets as required for workflow execution. * fix: update OPENAI_API_KEY check in test_loop.py to handle dummy values * Modified the condition in the pytest skipif decorator to also skip tests when OPENAI_API_KEY is set to "dummy", ensuring more robust test execution. * refactor: streamline component setup in test_loop.py * Removed redundant comments and improved formatting for component initialization in the loop_flow function. * Added missing system_prompt to StructuredOutputComponent to resolve "Multiple structured outputs" error. * Updated test_loop_flow to ensure it tests the graph creation with proper loop feedback connection. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
G
Gabriel Luiz Freitas Almeida committed
6403a8f564d1f390fd471fdc64643d11276f701e
Parent: 474e8d4
Committed by GitHub <noreply@github.com>
on 7/3/2025, 2:39:09 PM