Skip to content

feat(agentflow): enhance validation and feedback mechanisms#5915

Merged
jocelynlin-wd merged 2 commits intomainfrom
feat/agentflow-validation
Mar 6, 2026
Merged

feat(agentflow): enhance validation and feedback mechanisms#5915
jocelynlin-wd merged 2 commits intomainfrom
feat/agentflow-validation

Conversation

@jocelynlin-wd
Copy link
Contributor

@jocelynlin-wd jocelynlin-wd commented Mar 6, 2026

FLOWISE-232

  • Added constraint validation functions to ensure flow integrity, including checks for single start nodes, nested iterations, and human input restrictions within iterations.
  • Implemented a new ValidationFeedback component to display validation results and issues directly in the UI.
  • Updated the Agentflow component to integrate validation feedback and display snackbar notifications for constraint violations.
  • Enhanced flow validation logic to detect hanging edges and validate node inputs, improving overall flow integrity checks.
  • Introduced new test cases for validation functions to ensure robustness and reliability.

validation in agentflow sdk

agentflow-sdk-validation.mov

Hanging edge detection — Check every edge to see if both source and target nodes still exist
image

validation error tooltip
image

comparison: validation in agentflow v2

agentflow-v2-validation.mov

- Added constraint validation functions to ensure flow integrity, including checks for single start nodes, nested iterations, and human input restrictions within iterations.
- Implemented a new ValidationFeedback component to display validation results and issues directly in the UI.
- Updated the Agentflow component to integrate validation feedback and display snackbar notifications for constraint violations.
- Enhanced flow validation logic to detect hanging edges and validate node inputs, improving overall flow integrity checks.
- Introduced new test cases for validation functions to ensure robustness and reliability.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the robustness and user experience of Agentflow by introducing a comprehensive validation system. It ensures flow integrity through various constraint checks, provides immediate and clear feedback to users via a new UI component and snackbar notifications, and visually highlights problematic nodes. These enhancements guide users in building valid and functional flows, reducing potential errors and improving overall usability.

Highlights

  • Enhanced Flow Validation: Implemented comprehensive validation checks for Agentflow, including constraints for single start nodes, nested iterations, human input within iterations, hanging edges, and required node inputs (including credentials, array sub-fields, and nested component configurations).
  • New Validation Feedback Component: Introduced a dedicated ValidationFeedback component that displays a checklist of all detected issues directly within the UI, providing clear and actionable feedback to users.
  • Visual Error Highlighting: Nodes with validation errors are now visually highlighted with a distinct border, making it easy for users to identify and address problematic areas in their flows.
  • Real-time Constraint Checks: Integrated constraint validation into the node drag-and-drop and add node functionalities, preventing users from creating invalid flow structures from the outset and providing immediate feedback via snackbar notifications.
  • Updated Test Documentation and Coverage: The TESTS.md file has been significantly updated with a new testing guide, strategy, and detailed sections on writing tests, factory functions, mocking patterns, and custom Jest environments. New unit tests were added for constraint validation and existing flow validation tests were expanded.
Changelog
  • packages/agentflow/TESTS.md
    • Updated the testing guide with a new structure, test strategy tiers, and detailed sections on writing tests, factory functions, and mocking patterns.
    • Removed outdated test coverage status tables.
  • packages/agentflow/jest.config.js
    • Added a module name mapper for SVG files to use styleMock.js.
  • packages/agentflow/src/Agentflow.tsx
    • Imported Alert, Snackbar, ValidationFeedback, applyValidationErrorsToNodes, and validateFlow.
    • Added state for a snackbar to display constraint violation messages.
    • Integrated ValidationFeedback component into the canvas for displaying validation results.
    • Modified the handleSave function to perform flow validation before saving and apply validation errors to nodes.
    • Passed onConstraintViolation callback to useFlowHandlers and useDragAndDrop hooks.
  • packages/agentflow/src/assets/images/validate_empty.svg
    • Added a new SVG image for the validation feedback component.
  • packages/agentflow/src/core/types/index.ts
    • Added validationErrors property to NodeData interface to store an array of validation messages.
    • Added array property to InputParam interface to define sub-fields for array-type parameters.
  • packages/agentflow/src/core/utils/index.ts
    • Exported resolveNodeType from nodeFactory.
  • packages/agentflow/src/core/utils/nodeFactory.ts
    • Added NODE_TYPE_MAP to map node data types to ReactFlow node types.
    • Implemented resolveNodeType function to determine the ReactFlow node type based on NodeData.type.
  • packages/agentflow/src/core/validation/constraintValidation.test.ts
    • Added new unit tests for checkSingleStartNode, checkNestedIteration, checkHumanInputInIteration, and findParentIterationNode.
  • packages/agentflow/src/core/validation/constraintValidation.ts
    • Added ConstraintResult interface.
    • Implemented checkSingleStartNode to ensure only one start node exists.
    • Implemented checkNestedIteration to prevent iteration nodes from being nested.
    • Implemented checkHumanInputInIteration to prevent human input nodes inside iteration nodes.
    • Implemented findParentIterationNode to identify if a position falls within an iteration node.
  • packages/agentflow/src/core/validation/flowValidation.test.ts
    • Updated validateFlow tests to reflect new disconnection logic and added tests for hanging edges.
    • Updated validateNode tests to include validation for required inputs, credentials, array sub-fields, and nested component configurations.
    • Modified expected warning messages for required inputs.
  • packages/agentflow/src/core/validation/flowValidation.ts
    • Added isEmptyValue utility function.
    • Modified validateFlow to accept availableNodes and incorporate detectHangingEdges and validateNode calls.
    • Revised disconnection checks to use a connectedNodes set, aligning with server-side logic.
    • Implemented detectHangingEdges to identify edges connected to non-existent nodes.
    • Enhanced validateNode to validate required inputs, credentials, array sub-fields, and nested component configurations.
    • Added groupValidationErrorsByNodeId to group errors for UI display.
    • Added applyValidationErrorsToNodes to update node data with validation errors for visual highlighting.
  • packages/agentflow/src/core/validation/index.ts
    • Exported new validation utilities: applyValidationErrorsToNodes, groupValidationErrorsByNodeId, ConstraintResult, checkHumanInputInIteration, checkNestedIteration, checkSingleStartNode, and findParentIterationNode.
  • packages/agentflow/src/features/canvas/components/ValidationFeedback.tsx
    • Added a new ValidationFeedback component to display grouped validation errors in a checklist format.
    • Included functionality to trigger flow validation and update node errors for highlighting.
    • Implemented a success snackbar for when no issues are found.
  • packages/agentflow/src/features/canvas/components/index.ts
    • Exported the new ValidationFeedback component.
  • packages/agentflow/src/features/canvas/containers/AgentFlowNode.tsx
    • Updated AgentFlowNodeComponent to check for validationErrors in node data.
    • Modified node border styling to highlight nodes with validation errors using a distinct color and increased border width.
    • Combined data.warning and data.validationErrors into a single warning message for display.
  • packages/agentflow/src/features/canvas/hooks/useDragAndDrop.test.tsx
    • Updated tests to mock new validation functions.
    • Added test cases to ensure nodes are not added when constraint validation fails.
  • packages/agentflow/src/features/canvas/hooks/useDragAndDrop.ts
    • Imported resolveNodeType and constraint validation functions.
    • Integrated onConstraintViolation prop.
    • Added constraint checks (checkSingleStartNode, checkNestedIteration, checkHumanInputInIteration) before adding a new node via drag-and-drop.
    • Used resolveNodeType to set the correct ReactFlow node type.
    • Adjusted node positioning and parent extent for nodes dropped inside iteration nodes.
  • packages/agentflow/src/features/canvas/hooks/useFlowHandlers.test.tsx
    • Updated tests to mock new validation functions.
    • Added test cases to ensure connections are not made when isValidConnectionAgentflowV2 returns false.
    • Added test cases to ensure nodes are not added when constraint validation fails.
  • packages/agentflow/src/features/canvas/hooks/useFlowHandlers.ts
    • Imported resolveNodeType and constraint validation functions.
    • Integrated onConstraintViolation prop.
    • Added constraint checks (checkSingleStartNode, checkNestedIteration, checkHumanInputInIteration) before adding a new node.
    • Used resolveNodeType to set the correct ReactFlow node type.
  • packages/agentflow/src/vite-env.d.ts
    • Added Vite environment type declarations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive validation system for agent flows, which is a great enhancement. The changes include new validation logic for flow structure, node inputs, and placement constraints. A new UI component provides clear feedback to the user about validation issues. The implementation is solid, with good test coverage for the new logic. I have a few suggestions to improve maintainability, UI clarity, and accessibility.

@jocelynlin-wd jocelynlin-wd merged commit 11a3936 into main Mar 6, 2026
7 checks passed
@jocelynlin-wd jocelynlin-wd deleted the feat/agentflow-validation branch March 6, 2026 18:37
Copy link

@mmattu-wd mmattu-wd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some general questions

sx={{
borderColor: stateColor,
borderWidth: '1px',
borderColor: hasValidationErrors ? '#FFB938' : stateColor,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb: I see we have tokens that contain all the style tokens in agentflow, should we have validation colors in there as well for consistency. It is a bit more verbose

Then this could be like

  borderColor: hasValidationErrors ? tokens.colors.border.validation : stateColor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, will update in a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mb: 2,
backgroundColor: isDarkMode ? theme.palette.background.paper : theme.palette.grey[50],
borderRadius: '8px',
border: `1px solid ${alpha('#FFB938', isDarkMode ? 0.3 : 0.5)}`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb: just a question I noticed we have error and warning validation types, but we only render the color for the warning (amber). Is that expected/intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, intentional for now. Currently all validation issues are rendered uniformly as warnings (amber) since they're pre-save checks. The type field exists in the data model for future use if we want to visually distinguish structural errors (missing start node, cycles) from soft warnings (disconnected nodes, missing inputs), but we haven't needed that distinction in the UI yet.

type: 'agentflowNode',
position,
data: { ...initializedData, label: newLabel }
type: resolveNodeType(nodeData.type ?? ''),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb: can resolveNodeType handle undefined internally, so we dont have to escape the type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NodeData.type is typed as string so it shouldn't actually be undefined — the ?? '' is just defensive. Changing resolveNodeType to accept undefined would loosen the function's contract for a case that shouldn't happen at the type level. Prefer to keep the fallback at the call site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants