feat: Add structured JSON output support to Agent Node#5470
feat: Add structured JSON output support to Agent Node#5470HenryHengZJ merged 5 commits intoFlowiseAI:mainfrom
Conversation
- 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
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
|
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:
|
|
@HenryHengZJ agreed on the two stage part , will try to raise a new PR with this approach. |
|
@aibysid I've modified it now: |
* 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]>


Uh oh!
There was an error while loading. Please reload this page.