-
Notifications
You must be signed in to change notification settings - Fork 18.7k
fix agent putout the output of workflow-tool twice (#26835) #27706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix agent putout the output of workflow-tool twice (#26835) #27706
Conversation
Refactor tool response handling to use lists for parts and JSON messages. Ensure proper concatenation and avoid duplication of messages.
Summary of ChangesHello @Cursx, 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 refactors the internal mechanism responsible for converting tool responses into a single string output. The core objective is to resolve issues with duplicate output and ensure that all types of tool responses, including plain text, pure JSON, or a combination thereof, are correctly and efficiently concatenated. This enhancement aims to improve the reliability and clarity of tool interactions within the system by streamlining message processing. 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.
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 refactors the tool response conversion to use a list for building the final string, which is a good performance improvement. However, the logic to handle JSON messages and avoid duplication is too aggressive and could lead to data loss for tools that return both text and JSON. I've suggested a more robust way to handle deduplication that should fix the original issue without introducing this new problem.
|
/gemini review |
There was a problem hiding this 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 refactors the tool response handling to prevent duplicate outputs from workflow tools. The change from string concatenation to using lists for message parts is a good improvement for both performance and readability. My review includes a suggestion to remove an unused variable and fix a comment's indentation to further improve code quality.
|
/gemini review |
There was a problem hiding this 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 refactors the tool response handling in _convert_tool_response_to_str to fix an issue with duplicate outputs. The approach of separating text and JSON parts and then merging them with deduplication is sound. Using a list of parts and "".join() is also a good performance improvement over repeated string concatenation. My review includes a few suggestions: one to make the deduplication logic more robust by handling duplicates within the JSON parts list, and a couple of minor style improvements to simplify string construction for better readability.
crazywoola
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at those comments, if you think it's not necessary, please resolve those comments.
|
/gemini review |
There was a problem hiding this 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 effectively addresses the issue of duplicate outputs from workflow tools by refactoring the tool response handling. The new implementation correctly separates text and JSON message parts, and then intelligently combines them while avoiding duplicates. Using a list to build the final string is also a good performance improvement. I've included a couple of minor suggestions to further improve code readability by simplifying string concatenations.
* commit '71a359543413339c78daf8c892959c281f59a38d': (887 commits) fix jina reader creadential migration command (langgenius#27883) fix Version 2.0.0-beta.2: Chat annotations Api Error langgenius#25506 (langgenius#27206) Fix: correct DraftWorkflowApi.post response model (langgenius#27289) Add WEAVIATE_GRPC_ENDPOINT as designed in weaviate migration guide (langgenius#27861) bump vite to 6.4.1 (langgenius#27877) Fix/template transformer line number (langgenius#27867) chore: translate i18n files and update type definitions (langgenius#27868) feat: change feedback to forum (langgenius#27862) test: create new test scripts and update some existing test scripts o… (langgenius#27850) fix: avoid passing empty uniqueIdentifier to InstallFromMarketplace (langgenius#27802) fix: installation_id is missing when in tools page (langgenius#27849) fix(web): increase z-index of PortalToFollowElemContent (langgenius#27823) fix(web): improve the consistency of the inputs-form UI (langgenius#27837) feat: add validation to prevent saving empty opening statement in conversation opener modal (langgenius#27843) test: adding some web tests (langgenius#27792) fix:knowledge base reference information is overwritten when using mu… (langgenius#27799) feat: implement file extension blacklist for upload security (langgenius#27540) fix agent putout the output of workflow-tool twice (langgenius#26835) (langgenius#27706) feat: enhance annotation API to support optional message_id and content fields (langgenius#27460) fix: iteration node cannot be viewed(langgenius#27759) (langgenius#27786) ... # Conflicts: # .github/workflows/autofix.yml # .gitignore # README.md # api/.env.example # api/.vscode/launch.json.example # api/commands.py # api/configs/feature/__init__.py # api/contexts/__init__.py # api/controllers/console/__init__.py # api/controllers/console/app/generator.py # api/controllers/console/app/workflow.py # api/controllers/console/app/workflow_app_log.py # api/controllers/console/workspace/plugin.py # api/controllers/console/workspace/tool_providers.py # api/controllers/console/workspace/workspace.py # api/controllers/service_api/wraps.py # api/core/app/apps/common/workflow_response_converter.py # api/core/app/apps/pipeline/pipeline_generator.py # api/core/app/apps/workflow/app_generator.py # api/core/app/apps/workflow/app_runner.py # api/core/app/apps/workflow_app_runner.py # api/core/app/entities/app_invoke_entities.py # api/core/app/layers/pause_state_persist_layer.py # api/core/entities/parameter_entities.py # api/core/entities/provider_entities.py # api/core/helper/name_generator.py # api/core/ops/arize_phoenix_trace/arize_phoenix_trace.py # api/core/plugin/entities/parameters.py # api/core/plugin/entities/plugin.py # api/core/plugin/entities/request.py # api/core/plugin/impl/base.py # api/core/plugin/impl/tool.py # api/core/rag/datasource/vdb/weaviate/weaviate_vector.py # api/core/tools/entities/tool_entities.py # api/core/tools/mcp_tool/tool.py # api/core/tools/tool_engine.py # api/core/tools/tool_manager.py # api/core/tools/utils/encryption.py # api/core/workflow/enums.py # api/core/workflow/graph/graph.py # api/core/workflow/graph/validation.py # api/core/workflow/graph_engine/worker.py # api/core/workflow/nodes/base/node.py # api/core/workflow/nodes/enums.py # api/core/workflow/nodes/node_mapping.py # api/core/workflow/system_variable.py # api/docker/entrypoint.sh # api/events/event_handlers/__init__.py # api/extensions/ext_commands.py # api/libs/datetime_utils.py # api/models/__init__.py # api/models/account.py # api/models/dataset.py # api/models/enums.py # api/models/model.py # api/models/oauth.py # api/models/provider_ids.py # api/models/workflow.py # api/pyproject.toml # api/services/app_dsl_service.py # api/services/dataset_service.py # api/services/datasource_provider_service.py # api/services/plugin/oauth_service.py # api/services/rag_pipeline/transform/website-crawl-general-economy.yml # api/services/rag_pipeline/transform/website-crawl-general-high-quality.yml # api/services/rag_pipeline/transform/website-crawl-parentchild.yml # api/services/tools/builtin_tools_manage_service.py # api/services/tools/mcp_tools_manage_service.py # api/services/tools/tools_transform_service.py # api/services/workflow_service.py # api/tasks/document_indexing_task.py # api/tasks/rag_pipeline/priority_rag_pipeline_run_task.py # api/tasks/rag_pipeline/rag_pipeline_run_task.py # api/tasks/remove_app_and_related_data_task.py # api/tests/test_containers_integration_tests/core/app/layers/test_pause_state_persist_layer.py # api/tests/test_containers_integration_tests/services/test_workflow_service.py # api/tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py # api/tests/test_containers_integration_tests/tasks/test_add_document_to_index_task.py # api/tests/test_containers_integration_tests/tasks/test_document_indexing_task.py # api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.py # api/tests/unit_tests/core/workflow/entities/test_variable_pool.py # api/tests/unit_tests/core/workflow/graph/test_graph_validation.py # api/uv.lock # dev/basedpyright-check # dev/start-worker # docker/.env.example # docker/docker-compose-template.yaml # docker/docker-compose.middleware.yaml # docker/docker-compose.yaml # docker/volumes/sandbox/dependencies/python-requirements.txt # docs/it-IT/README.md # web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx # web/app/(commonLayout)/layout.tsx # web/app/(shareLayout)/components/splash.tsx # web/app/components/app-sidebar/app-operations.tsx # web/app/components/app/annotation/index.tsx # web/app/components/app/app-publisher/index.tsx # web/app/components/app/configuration/config-var/config-modal/index.tsx # web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx # web/app/components/app/configuration/config/automatic/get-automatic-res.tsx # web/app/components/app/configuration/index.tsx # web/app/components/app/create-app-modal/index.tsx # web/app/components/app/log/empty-element.tsx # web/app/components/app/log/index.tsx # web/app/components/app/log/list.tsx # web/app/components/app/overview/app-card.tsx # web/app/components/app/workflow-log/detail.tsx # web/app/components/base/date-and-time-picker/calendar/item.tsx # web/app/components/base/date-and-time-picker/time-picker/index.spec.tsx # web/app/components/base/date-and-time-picker/utils/dayjs.spec.ts # web/app/components/base/form/components/base/base-field.tsx # web/app/components/base/form/components/base/base-form.tsx # web/app/components/base/form/components/field/select.tsx # web/app/components/base/form/components/field/variable-or-constant-input.tsx # web/app/components/base/form/index.stories.tsx # web/app/components/base/form/types.ts # web/app/components/base/icons/src/public/billing/AwsMarketplace.tsx # web/app/components/base/icons/src/public/billing/AwsMarketplaceDark.tsx # web/app/components/base/icons/src/public/billing/AwsMarketplaceLight.tsx # web/app/components/base/icons/src/public/knowledge/File.tsx # web/app/components/base/icons/src/public/knowledge/GeneralType.tsx # web/app/components/base/icons/src/public/knowledge/LayoutRight2LineMod.tsx # web/app/components/base/icons/src/public/knowledge/OptionCardEffectBlue.tsx # web/app/components/base/icons/src/public/knowledge/OptionCardEffectBlueLight.tsx # web/app/components/base/icons/src/public/knowledge/OptionCardEffectOrange.tsx # web/app/components/base/icons/src/public/knowledge/OptionCardEffectPurple.tsx # web/app/components/base/icons/src/public/knowledge/OptionCardEffectTeal.tsx # web/app/components/base/icons/src/public/knowledge/ParentChildType.tsx # web/app/components/base/icons/src/public/knowledge/Watercrawl.tsx # web/app/components/base/icons/src/public/knowledge/dataset-card/ExternalKnowledgeBase.tsx # web/app/components/base/icons/src/public/knowledge/dataset-card/General.tsx # web/app/components/base/icons/src/public/knowledge/dataset-card/Graph.tsx # web/app/components/base/icons/src/public/knowledge/dataset-card/ParentChild.tsx # web/app/components/base/icons/src/public/knowledge/dataset-card/Qa.tsx # web/app/components/base/icons/src/public/knowledge/online-drive/BucketsBlue.tsx # web/app/components/base/icons/src/public/knowledge/online-drive/BucketsGray.tsx # web/app/components/base/icons/src/public/thought/ThoughtList.tsx # web/app/components/base/icons/src/public/thought/WebReader.tsx # web/app/components/base/icons/src/vender/knowledge/FullTextSearch.tsx # web/app/components/base/icons/src/vender/knowledge/GeneralChunk.tsx # web/app/components/base/icons/src/vender/knowledge/HighQuality.tsx # web/app/components/base/icons/src/vender/knowledge/HybridSearch.tsx # web/app/components/base/icons/src/vender/knowledge/ParentChildChunk.tsx # web/app/components/base/icons/src/vender/knowledge/QuestionAndAnswer.tsx # web/app/components/base/icons/src/vender/knowledge/SearchMenu.tsx # web/app/components/base/icons/src/vender/knowledge/VectorSearch.tsx # web/app/components/base/icons/src/vender/line/layout/AlignLeft01.tsx # web/app/components/base/icons/src/vender/line/layout/AlignRight01.tsx # web/app/components/base/icons/src/vender/line/mapsAndTravel/Route.tsx # web/app/components/base/icons/src/vender/line/users/User01.tsx # web/app/components/base/icons/src/vender/line/users/Users01.tsx # web/app/components/base/icons/src/vender/line/weather/Stars02.tsx # web/app/components/base/icons/src/vender/pipeline/InputField.tsx # web/app/components/base/icons/src/vender/pipeline/PipelineFill.tsx # web/app/components/base/icons/src/vender/pipeline/PipelineLine.tsx # web/app/components/base/icons/src/vender/solid/arrows/ChevronDown.tsx # web/app/components/base/icons/src/vender/solid/arrows/HighPriority.tsx # web/app/components/base/icons/src/vender/solid/arrows/index.ts # web/app/components/base/icons/src/vender/solid/communication/AiText.tsx # web/app/components/base/icons/src/vender/solid/layout/Grid01.tsx # web/app/components/base/icons/src/vender/solid/mapsAndTravel/Route.tsx # web/app/components/base/input/index.tsx # web/app/components/base/linked-apps-panel/index.stories.tsx # web/app/components/base/markdown/index.tsx # web/app/components/base/markdown/react-markdown-wrapper.tsx # web/app/components/base/notion-page-selector/base.tsx # web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx # web/app/components/base/search-input/index.tsx # web/app/components/base/select/custom.tsx # web/app/components/base/select/pure.tsx # web/app/components/base/voice-input/index.stories.tsx # web/app/components/billing/plan/index.tsx # web/app/components/billing/pricing/plans/cloud-plan-item/list/index.tsx # web/app/components/datasets/create/index.tsx # web/app/components/datasets/create/website/firecrawl/index.tsx # web/app/components/datasets/create/website/index.tsx # web/app/components/datasets/create/website/jina-reader/index.tsx # web/app/components/datasets/create/website/watercrawl/index.tsx # web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/index.tsx # web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/index.tsx # web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/index.tsx # web/app/components/develop/template/template_workflow.ja.mdx # web/app/components/develop/template/template_workflow.zh.mdx # web/app/components/goto-anything/context.tsx # web/app/components/header/account-dropdown/index.tsx # web/app/components/header/account-setting/data-source-page-new/hooks/use-marketplace-all-plugins.ts # web/app/components/header/account-setting/index.tsx # web/app/components/header/account-setting/model-provider-page/declarations.ts # web/app/components/header/nav/nav-selector/index.tsx # web/app/components/plugins/card/index.tsx # web/app/components/plugins/constants.ts # web/app/components/plugins/hooks.ts # web/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list.tsx # web/app/components/plugins/marketplace/plugin-type-switch.tsx # web/app/components/plugins/marketplace/search-box/index.tsx # web/app/components/plugins/marketplace/utils.ts # web/app/components/plugins/plugin-auth/types.ts # web/app/components/plugins/plugin-detail-panel/app-selector/app-inputs-panel.tsx # web/app/components/plugins/plugin-detail-panel/detail-header.tsx # web/app/components/plugins/plugin-detail-panel/index.tsx # web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx # web/app/components/plugins/types.ts # web/app/components/rag-pipeline/components/panel/index.tsx # web/app/components/rag-pipeline/hooks/use-nodes-sync-draft.ts # web/app/components/rag-pipeline/hooks/use-pipeline-init.ts # web/app/components/tools/mcp/mcp-service-card.tsx # web/app/components/tools/types.ts # web/app/components/tools/utils/to-form-schema.ts # web/app/components/workflow-app/components/workflow-children.tsx # web/app/components/workflow-app/components/workflow-header/features-trigger.tsx # web/app/components/workflow-app/components/workflow-main.tsx # web/app/components/workflow-app/hooks/use-available-nodes-meta-data.ts # web/app/components/workflow-app/hooks/use-nodes-sync-draft.ts # web/app/components/workflow-app/hooks/use-workflow-init.ts # web/app/components/workflow-app/hooks/use-workflow-run.ts # web/app/components/workflow-app/index.tsx # web/app/components/workflow/block-icon.tsx # web/app/components/workflow/block-selector/all-tools.tsx # web/app/components/workflow/block-selector/blocks.tsx # web/app/components/workflow/block-selector/constants.tsx # web/app/components/workflow/block-selector/data-sources.tsx # web/app/components/workflow/block-selector/hooks.ts # web/app/components/workflow/block-selector/index.tsx # web/app/components/workflow/block-selector/main.tsx # web/app/components/workflow/block-selector/market-place-plugin/action.tsx # web/app/components/workflow/block-selector/market-place-plugin/list.tsx # web/app/components/workflow/block-selector/rag-tool-recommendations/index.tsx # web/app/components/workflow/block-selector/rag-tool-recommendations/list.tsx # web/app/components/workflow/block-selector/tabs.tsx # web/app/components/workflow/block-selector/tool-picker.tsx # web/app/components/workflow/block-selector/tools.tsx # web/app/components/workflow/block-selector/types.ts # web/app/components/workflow/block-selector/utils.ts # web/app/components/workflow/constants.ts # web/app/components/workflow/header/header-in-normal.tsx # web/app/components/workflow/header/run-mode.tsx # web/app/components/workflow/hooks-store/store.ts # web/app/components/workflow/hooks/use-available-blocks.ts # web/app/components/workflow/hooks/use-checklist.ts # web/app/components/workflow/hooks/use-inspect-vars-crud.ts # web/app/components/workflow/hooks/use-nodes-interactions.ts # web/app/components/workflow/hooks/use-tool-icon.ts # web/app/components/workflow/hooks/use-workflow.ts # web/app/components/workflow/nodes/_base/components/form-input-item.tsx # web/app/components/workflow/nodes/_base/components/node-handle.tsx # web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx # web/app/components/workflow/nodes/_base/components/variable-tag.tsx # web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show/field.tsx # web/app/components/workflow/nodes/_base/components/variable/utils.ts # web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx # web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx # web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts # web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx # web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts # web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts # web/app/components/workflow/nodes/_base/node.tsx # web/app/components/workflow/nodes/assigner/components/var-list/index.tsx # web/app/components/workflow/nodes/components.ts # web/app/components/workflow/nodes/constants.ts # web/app/components/workflow/nodes/data-source-empty/hooks.ts # web/app/components/workflow/nodes/data-source/node.tsx # web/app/components/workflow/nodes/data-source/types.ts # web/app/components/workflow/nodes/end/default.ts # web/app/components/workflow/nodes/llm/types.ts # web/app/components/workflow/nodes/llm/utils.ts # web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx # web/app/components/workflow/nodes/parameter-extractor/default.ts # web/app/components/workflow/nodes/question-classifier/default.ts # web/app/components/workflow/nodes/start/default.ts # web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx # web/app/components/workflow/nodes/tool/components/tool-form/index.tsx # web/app/components/workflow/nodes/tool/components/tool-form/item.tsx # web/app/components/workflow/nodes/tool/types.ts # web/app/components/workflow/operator/add-block.tsx # web/app/components/workflow/operator/more-actions.tsx # web/app/components/workflow/run/index.tsx # web/app/components/workflow/store/workflow/tool-slice.ts # web/app/components/workflow/types.ts # web/app/components/workflow/utils/workflow.ts # web/app/components/workflow/variable-inspect/panel.tsx # web/app/components/workflow/workflow-preview/components/node-handle.tsx # web/config/index.ts # web/context/app-context.tsx # web/context/provider-context.tsx # web/i18n/de-DE/workflow.ts # web/i18n/en-US/plugin.ts # web/i18n/en-US/workflow.ts # web/i18n/es-ES/workflow.ts # web/i18n/fa-IR/workflow.ts # web/i18n/fr-FR/workflow.ts # web/i18n/hi-IN/workflow.ts # web/i18n/id-ID/app-log.ts # web/i18n/id-ID/workflow.ts # web/i18n/it-IT/workflow.ts # web/i18n/ja-JP/billing.ts # web/i18n/ja-JP/common.ts # web/i18n/ja-JP/workflow.ts # web/i18n/ko-KR/workflow.ts # web/i18n/pl-PL/workflow.ts # web/i18n/pt-BR/workflow.ts # web/i18n/ro-RO/workflow.ts # web/i18n/ru-RU/workflow.ts # web/i18n/sl-SI/workflow.ts # web/i18n/th-TH/workflow.ts # web/i18n/tr-TR/workflow.ts # web/i18n/uk-UA/workflow.ts # web/i18n/vi-VN/workflow.ts # web/i18n/zh-Hans/common.ts # web/i18n/zh-Hans/plugin.ts # web/i18n/zh-Hans/workflow.ts # web/i18n/zh-Hant/common.ts # web/i18n/zh-Hant/workflow.ts # web/models/app.ts # web/models/datasets.ts # web/next.config.js # web/package.json # web/pnpm-lock.yaml # web/service/fetch.ts # web/service/share.ts # web/service/use-plugins.ts # web/service/use-tools.ts # web/types/i18n.d.ts # web/utils/format.ts # web/utils/get-icon.spec.ts # web/utils/time.spec.ts # web/utils/urlValidation.ts
Refactor tool response handling to use lists for parts and JSON messages. Ensure proper concatenation and avoid duplication of messages.
Important
Fixes #<issue number>.Summary
Previously, there would be repeated output text. Now, regardless of whether the tool's response is in plain text, pure JSON format, or text+JSON format, it can output as expected.
close #26835
I noticed a discussion and code improvement regarding this issue in # 27087. This code may serve as a reference for code improvement.
Screenshots
| Before | After |



|--------|
|
| ... |
|
| ... |
|
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods