Skip to content

Feat/agentflow async input handlers#5956

Merged
j-sanaa merged 20 commits intomainfrom
feat/agentflow-async-input-handlers
Mar 12, 2026
Merged

Feat/agentflow async input handlers#5956
j-sanaa merged 20 commits intomainfrom
feat/agentflow-async-input-handlers

Conversation

@j-sanaa
Copy link
Contributor

@j-sanaa j-sanaa commented Mar 11, 2026

JIRA - FLOWISE-228

  • Added asyncOptions and asyncMultiOptions input types, powered by a new useAsyncOptions hook that fetches options from the API with loading, error, and retry states
  • Extracted async rendering into AsyncInput in features/node-editor/ and injected it via an AsyncInputComponent prop to keep atoms/ free of infrastructure imports
  • Fixed API endpoints for models and tools (both now use POST /node-load-method/agentAgentflow), and fixed a URL-encoding bug in getCredentialsByName by passing an array instead of a manually joined string
  • Added tests for useAsyncOptions, AsyncInput integration, and async-driven field visibility in flow validation
Recording.mov

@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 enhances the Agentflow node editor by introducing robust asynchronous input handling capabilities. It allows node parameters to dynamically fetch options from the backend API, improving user experience for fields like model selection or tool configuration. The changes involve new UI components, a dedicated data-fetching hook, and updates to API interactions, ensuring a more flexible and maintainable system for managing complex node inputs.

Highlights

  • New Asynchronous Input Types: Introduced asyncOptions and asyncMultiOptions input types, enabling dynamic loading of options for node parameters.
  • Asynchronous Option Fetching Hook: Developed a new useAsyncOptions React hook that handles fetching options from the API, including loading states, error handling, and retry functionality.
  • Modular Async Input Component: Extracted the rendering logic for asynchronous inputs into a dedicated AsyncInput component, which is injected via a prop to maintain a clean separation of concerns within the UI atoms.
  • Standardized API Endpoints: Standardized the API endpoints for fetching models and tools to use a unified POST /node-load-method/agentAgentflow endpoint, improving consistency and simplifying backend interactions.
  • API Request Fixes: Fixed a URL-encoding bug in the getCredentialsByName API call by passing an array of credential names, ensuring correct request serialization.
  • Enhanced Validation and Test Coverage: Expanded test coverage to include the new useAsyncOptions hook, AsyncInput component integration, and validation logic for async-driven field visibility in flow validation.
Changelog
  • packages/agentflow/src/atoms/ArrayInput.tsx
    • Added AsyncInputComponent prop to ArrayInputProps and passed it to NodeInputHandler.
  • packages/agentflow/src/atoms/NodeInputHandler.test.tsx
    • Added tests for NodeInputHandler to verify behavior with asyncOptions when AsyncInputComponent is absent.
  • packages/agentflow/src/atoms/NodeInputHandler.tsx
    • Introduced AsyncInputProps and AsyncInputComponent prop, and added logic to render async input types.
  • packages/agentflow/src/atoms/index.ts
    • Exported AsyncInputProps from NodeInputHandler.
  • packages/agentflow/src/core/types/api.ts
    • Defined NodeOption and updated ChatModel and Tool types to use it.
  • packages/agentflow/src/core/types/node.ts
    • Added loadMethod and credentialNames properties to InputParam.
  • packages/agentflow/src/core/validation/flowValidation.test.ts
    • Added new test cases for asyncOptions and asyncMultiOptions validation, including visibility conditions.
  • packages/agentflow/src/core/validation/flowValidation.ts
    • Clarified comments regarding async input types and visibility evaluation in validation.
  • packages/agentflow/src/features/node-editor/AsyncInput.test.tsx
    • Added tests for the AsyncInput component, covering loading, errors, retry, and multi-select.
  • packages/agentflow/src/features/node-editor/AsyncInput.tsx
    • Created AsyncInput component to render asynchronous single and multi-select inputs with loading and error states.
  • packages/agentflow/src/features/node-editor/EditNodeDialog.tsx
    • Integrated the new AsyncInput component into the NodeInputHandler within the dialog.
  • packages/agentflow/src/infrastructure/api/credentials.ts
    • Modified getCredentialsByName to accept a single string or an array of credential names.
  • packages/agentflow/src/infrastructure/api/hooks/index.ts
    • Added an index file to export the new useAsyncOptions hook and OptionItem type.
  • packages/agentflow/src/infrastructure/api/hooks/useAsyncOptions.test.tsx
    • Added tests for the useAsyncOptions hook, verifying data fetching, error handling, and refetching.
  • packages/agentflow/src/infrastructure/api/hooks/useAsyncOptions.ts
    • Implemented the useAsyncOptions hook for fetching dynamic options from the API with state management.
  • packages/agentflow/src/infrastructure/api/loadMethodRegistry.test.ts
    • Updated tests to reflect the renaming of listChatModels to listModels and API changes.
  • packages/agentflow/src/infrastructure/api/loadMethodRegistry.ts
    • Renamed listChatModels to listModels and updated its API call in the registry.
  • packages/agentflow/src/infrastructure/api/models.test.ts
    • Updated tests for getChatModels to use the new POST endpoint and removed getModelsByProvider tests.
  • packages/agentflow/src/infrastructure/api/models.ts
    • Refactored getChatModels to use a POST request to a unified endpoint and removed getModelsByProvider.
  • packages/agentflow/src/infrastructure/api/tools.test.ts
    • Updated tests for getAllTools to use the new unified POST endpoint.
  • packages/agentflow/src/infrastructure/api/tools.ts
    • Modified getAllTools to use a POST request to the unified /node-load-method/agentAgentflow endpoint.
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 asynchronous option handling for node inputs, a significant and well-executed feature. The use of a new useAsyncOptions hook and dependency injection for the AsyncInput component is a clean architectural choice that keeps UI atoms decoupled from data-fetching logic. The changes are comprehensive, including fixes for API endpoints, a bug fix for URL encoding, and extensive test coverage for the new functionality. The code quality is high, with good use of TypeScript and React best practices. I have one minor suggestion for improving the robustness of value parsing in the AsyncMultiOptionsInput component.

@j-sanaa j-sanaa marked this pull request as ready for review March 11, 2026 23:10
* Get credentials filtered by one or more component credential names.
*/
getCredentialsByName: async (credentialName: string): Promise<Credential[]> => {
getCredentialsByName: async (credentialName: string | string[]): Promise<Credential[]> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

does the API accept both single credential and credential array?

/** Props passed to an async input component (asyncOptions / asyncMultiOptions). */
export interface AsyncInputProps {
inputParam: InputParam
value: unknown
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to define what the value type should be?

if (error) {
return (
<Box sx={{ mt: 1, display: 'flex', alignItems: 'center', gap: 1 }}>
<Typography variant='caption' color='error' sx={{ flexGrow: 1 }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

this error display seems to be the same as the one used in AsyncMultiOptionsInput (line 106-108). Shall we extract to a small shared component to reduce duplication?


function AsyncOptionsInput({ inputParam, value, disabled, onChange, nodeName, inputValues }: AsyncInputProps) {
const params =
nodeName || inputValues ? { ...(nodeName ? { nodeName } : {}), ...(inputValues ? { inputs: inputValues } : {}) } : undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicated params construction — Both AsyncOptionsInput (line 12-13) and AsyncMultiOptionsInput (line 95-96) build params identically. Extract this to AsyncInput and pass it down, or compute it once in the dispatcher?

* Get input argument names for the currently selected tool.
* Passes current node inputs as `currentNode.inputs` so the server can resolve the selected tool.
*/
getToolInputArgs: async (inputs: Record<string, unknown>, nodeName = 'toolAgentflow'): Promise<Tool[]> => {
Copy link
Contributor

@jocelynlin-wd jocelynlin-wd Mar 12, 2026

Choose a reason for hiding this comment

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

nit: Tool seems to be an alias for NodeOption, which the shape is correct — getToolInputArgs returns objects with label, name, etc., which fits NodeOption/Tool exactly. The naming is slightly misleading since "Tool" suggests a tool, not a tool's input arguments

isOptionEqualToValue={(o, v) => o.name === v.name}
onChange={(_e, selection) => {
const names = selection.map((s) => s.name)
onChange(names.length > 0 ? JSON.stringify(names) : '')
Copy link
Contributor

Choose a reason for hiding this comment

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

JSON string storage for multi-select values — AsyncMultiOptionsInput stores values as JSON.stringify(names). The validation layer and the component itself both need to parse this back. This works but creates a coupling that could be error-prone for future consumers. Worth a comment in the type definition for InputParam documenting this convention?

*
* ### Built-in entries
* - `listChatModels` — fetches available chat models via `GET /assistants/components/chatmodels`
* - `listModels` — fetches available chat models via `GET /assistants/components/chatmodels`
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, looks like the api has been changed to use POST instead?

getChatModels: async (): Promise<ChatModel[]> => {
  const response = await client.post('/node-load-method/agentAgentflow', { loadMethod: 'listModels' })
  ...
}

Copy link
Contributor

@jocelynlin-wd jocelynlin-wd left a comment

Choose a reason for hiding this comment

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

no-blockers, feel free to review the comments in a follow up PR instead

@j-sanaa j-sanaa merged commit 0973446 into main Mar 12, 2026
7 checks passed
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.

2 participants