Skip to content

feat: Add structured JSON output support to Agent Node#5470

Merged
HenryHengZJ merged 5 commits intoFlowiseAI:mainfrom
aibysid:feat/agent-structured-output
Nov 25, 2025
Merged

feat: Add structured JSON output support to Agent Node#5470
HenryHengZJ merged 5 commits intoFlowiseAI:mainfrom
aibysid:feat/agent-structured-output

Conversation

@aibysid
Copy link
Copy Markdown
Contributor

@aibysid aibysid commented Nov 13, 2025

  • Add agentStructuredOutput input parameter matching LLM Node structure
  • Implement configureStructuredOutput method to convert schema to Zod
  • Add createZodSchemaFromJSON helper for complex JSON schemas
  • Configure structured output before binding tools (required order)
  • Disable streaming when structured output is enabled
  • Extract structured fields in prepareOutputObject method
  • Resolves issue Agent Node - Add structured JSON response (similar to LLM Node) #5256
Screenshot 2025-11-13 at 13 47 08

- Add agentStructuredOutput input parameter matching LLM Node structure
- Implement configureStructuredOutput method to convert schema to Zod
- Add createZodSchemaFromJSON helper for complex JSON schemas
- Configure structured output before binding tools (required order)
- Disable streaming when structured output is enabled
- Extract structured fields in prepareOutputObject method
- Resolves issue FlowiseAI#5256
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @aibysid, 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 introduces a significant enhancement to the Agent Node by adding robust support for structured JSON output. Users can now define a desired JSON schema for the agent's responses, which is then converted into a Zod schema for validation and enforcement. This feature provides greater control over the format of agent outputs, improving integration with downstream systems and ensuring predictable data structures.

Highlights

  • Structured Output Input: Added 'agentStructuredOutput' parameter to the Agent Node for defining JSON output schemas.
  • Zod Schema Conversion: Implemented 'configureStructuredOutput' to convert user-defined schemas into Zod schemas.
  • Complex JSON Schema Support: Introduced 'createZodSchemaFromJSON' helper for handling intricate nested JSON schemas.
  • Execution Order: Ensured structured output configuration occurs before tool binding.
  • Streaming Disabled: Streaming is automatically disabled when structured output is active.
  • Output Extraction: Structured fields are now extracted and included in the final output object.
  • Issue Resolution: Addresses and resolves issue Agent Node - Add structured JSON response (similar to LLM Node) #5256.
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
Copy Markdown
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 structured JSON output capabilities to the Agent node, which is a great feature. The implementation correctly disables streaming when this feature is active and adds the necessary UI and backend logic to build a Zod schema from user input. My review focuses on improving the robustness and clarity of the new schema generation logic. I've identified an issue with how empty enums are handled, found an unreachable code block that should be removed, and suggest documenting a custom feature to make it usable for end-users.

@HenryHengZJ
Copy link
Copy Markdown
Contributor

I dont think it is working:
image

I also dont think we can reuse the same logic as LLM node, because we cant have structured output and tools at the same time. If we want agent to have structured output, we probably have to do it in 2 stages:

  • get the output from agent
  • call LLM again to output structured data from the answer following the specified schema

@aibysid
Copy link
Copy Markdown
Contributor Author

aibysid commented Nov 25, 2025

@HenryHengZJ agreed on the two stage part , will try to raise a new PR with this approach.

@aibysid aibysid closed this Nov 25, 2025
@HenryHengZJ HenryHengZJ reopened this Nov 25, 2025
@HenryHengZJ
Copy link
Copy Markdown
Contributor

@aibysid I've modified it now:
image

@HenryHengZJ HenryHengZJ linked an issue Nov 25, 2025 that may be closed by this pull request
@HenryHengZJ HenryHengZJ merged commit 1f3f7a7 into FlowiseAI:main Nov 25, 2025
2 checks passed
davehamptonusa pushed a commit to davehamptonusa/Flowise that referenced this pull request Dec 8, 2025
* feat: Add structured JSON output support to Agent Node

- Add agentStructuredOutput input parameter matching LLM Node structure
- Implement configureStructuredOutput method to convert schema to Zod
- Add createZodSchemaFromJSON helper for complex JSON schemas
- Configure structured output before binding tools (required order)
- Disable streaming when structured output is enabled
- Extract structured fields in prepareOutputObject method
- Resolves issue FlowiseAI#5256

* lint fix

* add structured output to Agent node

* add structured output to Agent node

---------

Co-authored-by: Henry <[email protected]>
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.

Agent Node - Add structured JSON response (similar to LLM Node)

2 participants