feat: node response store#7035
Conversation
Coverage Report
File CoverageNo changed files found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77b48f12cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // 先写父再写子,配合 Mongo _id 排序,详情页能沿用运行时自然顺序展示。 | ||
| children.forEach((child) => visit(child, id)); |
There was a problem hiding this comment.
Avoid double-counting persisted child node points
When this recursion writes every nested child response as its own chat_item_responses row, those child rows still retain data.totalPoints. The app log aggregations I checked (projects/app/src/pages/api/core/app/logs/list.ts and exportLogs.ts) sum chatItemResponsesData.totalPointsFromResponse across all rows for the chat, so any plugin/child-app/loop/parallel run whose parent already includes child usage will now add the parent total plus each descendant total again. Please either make those aggregations count only root rows (data.parentId absent) or otherwise prevent descendant rows from contributing to log totals.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR introduces a new “node response” persistence model for workflow execution: node responses are written incrementally as flat rows into chat_item_responses (keyed by data.id / data.parentId) and composed back into childrenResponses when read, while legacy inline chat_items.responseData remains supported for backwards compatibility.
Changes:
- Add
nodeResponseStorage(writer + row composition) and integrate it into workflow dispatch so v2 root workflows can persist node responses incrementally and return a summary for chat logging. - Update API endpoints and chat save/logging paths to rely on persisted rows +
nodeResponseSummaryrather than inlineresponseData. - Update frontend response-tree utilities/UI to handle
childrenResponses(and legacy child fields) consistently; add extensive test coverage.
Reviewed changes
Copilot reviewed 51 out of 51 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/app/test/global/core/chat/utils.test.ts | Adds tests for child childrenResponses sandbox + quote extraction behavior. |
| projects/app/test/components/core/chat/ChatContainer/ChatBox/utils.test.ts | Adds tests for appendNodeResponseByParent streaming merge behavior. |
| projects/app/test/components/core/chat/ChatContainer/ChatBox/resume.test.ts | Adds tests for streaming merge + resume merging of completed records. |
| projects/app/test/api/core/chat/record/getResData.test.ts | New tests for getResData legacy-inline vs persisted-row behavior. |
| projects/app/src/service/support/mcp/utils.ts | Passes responseChatItemId, saves nodeResponseSummary, drops inline node responses. |
| projects/app/src/service/core/app/utils.ts | Scheduled trigger workflow now generates responseChatItemId and forwards nodeResponseSummary. |
| projects/app/src/pages/api/v2/chat/completions.ts | Uses persisted rows for detail/share, returns nodeResponseSummary, computes error from persisted rows/summary. |
| projects/app/src/pages/api/v1/chat/completions.ts | Propagates nodeResponseSummary and drops inline node responses. |
| projects/app/src/pages/api/core/chat/record/getResData.ts | Reads persisted rows and composes trees when inline responseData is absent. |
| projects/app/src/pages/api/core/chat/chatTest.ts | Drops inline node responses and forwards nodeResponseSummary. |
| projects/app/src/pages/api/core/ai/skill/debugChat.ts | Drops inline node responses and forwards nodeResponseSummary. |
| projects/app/src/components/core/chat/components/WholeResponseModal/WholeResponseContent.tsx | Removes obsolete dataset preview prop wiring for response modal. |
| projects/app/src/components/core/chat/components/WholeResponseModal/SideTab.tsx | Refactors sidebar sizing/indent logic and improves text layout/overflow handling. |
| projects/app/src/components/core/chat/components/WholeResponseModal/ResponseRows.tsx | Uses getChildrenResponses for child stats + simplifies AiChatRows props. |
| projects/app/src/components/core/chat/components/WholeResponseModal/responseData.ts | Flattens/side-tab building now recurses via getChildrenResponses. |
| projects/app/src/components/core/chat/components/WholeResponseModal/ResponseBox.tsx | Aligns layout with new sidebar width/padding constants. |
| projects/app/src/components/core/chat/components/WholeResponseModal/index.tsx | Removes modal padding overrides (layout adjustments). |
| projects/app/src/components/core/chat/ChatContainer/PluginRunBox/context.tsx | Uses appendNodeResponseByParent for streaming node response merges. |
| projects/app/src/components/core/chat/ChatContainer/ChatBox/utils/resume.ts | Reworks resume merge logic to use appendNodeResponseByParent. |
| projects/app/src/components/core/chat/ChatContainer/ChatBox/hooks/useChatGenerate.ts | Uses appendNodeResponseByParent for streaming node response merges. |
| packages/service/test/core/workflow/dispatch/parallelRun/runParallelRun.test.ts | New tests for parallel-run wrapper persistence + retry cleanup with writer. |
| packages/service/test/core/workflow/dispatch/loopRun/runLoopRun.test.ts | Extends loop-run tests for wrapper persistence + interactive partial wrapper behavior. |
| packages/service/test/core/workflow/dispatch/index.persistence.test.ts | New integration tests validating flat-row persistence + composition. |
| packages/service/test/core/workflow/dispatch/ai/agent/utils.test.ts | Ensures sub-app tool calls receive shared writer + correct parentId. |
| packages/service/test/core/chat/saveChat.test.ts | Updates expectations: inline responseData dropped; logs rely on summary; responseTime from persisted rows. |
| packages/service/test/core/chat/nodeResponseStorage.test.ts | New comprehensive tests for row creation, composition, writer batching/retry/fallback/summary. |
| packages/service/test/core/chat/controller.test.ts | Tests composing v2 flat rows into childrenResponses + legacy inline precedence. |
| packages/service/support/outLink/runtime/utils.ts | Adds responseChatItemId, forwards nodeResponseSummary, drops inline node responses. |
| packages/service/core/workflow/dispatch/type.ts | Adds nodeResponseSummary to dispatch response type. |
| packages/service/core/workflow/dispatch/plugin/run.ts | Adds writer support: keep child stats when writer is enabled, optionally drop child detail. |
| packages/service/core/workflow/dispatch/parallelRun/service.ts | Supports stable task wrapper ids (taskResponseId) for persistence. |
| packages/service/core/workflow/dispatch/parallelRun/runParallelRun.ts | Adds writer support, retry cleanup, and writes slim task wrappers to parent when enabled. |
| packages/service/core/workflow/dispatch/loopRun/runLoopRun.ts | Adds writer support, writes iteration wrappers (including partial on interactive pause). |
| packages/service/core/workflow/dispatch/index.ts | Core integration: per-request writer creation/close, streaming nodeResponse ids/parentIds, drop in-memory accumulation for root v2. |
| packages/service/core/workflow/dispatch/child/runApp.ts | Adds writer support: drop child detail + keep child stats. |
| packages/service/core/workflow/dispatch/ai/toolcall/index.ts | Writes tool detail as flat rows when writer is enabled; keeps child stats. |
| packages/service/core/workflow/dispatch/ai/agent/utils.ts | Propagates writer + parentId to sub-app dispatch; enriches child counts. |
| packages/service/core/workflow/dispatch/ai/agent/sub/app/index.ts | Computes child stats from flowResponses for workflow/plugin sub-apps; propagates writer ids. |
| packages/service/core/workflow/dispatch/ai/agent/index.ts | Renames internal child response accumulator variable (behavior unchanged). |
| packages/service/core/chat/saveChat.ts | Stops persisting inline node responses; saves summary fields and computes logs from nodeResponseSummary. |
| packages/service/core/chat/pushChatLog.ts | Computes responseTime from persisted node response detail instead of inline responseData. |
| packages/service/core/chat/nodeResponseStorage.ts | New module implementing flat-row storage, composition, writer, retries, fallback slim rows, and summary collection. |
| packages/service/core/chat/controller.ts | Composes flat rows into responseData when inline field is absent. |
| packages/service/core/chat/chatItemSchema.ts | Marks deprecated inline node response path with default: undefined to avoid false “empty array” legacy detection. |
| packages/service/core/chat/chatItemResponseSchema.ts | Adds composite index for ordered reads and unique constraint on data.id per chat item. |
| packages/global/test/core/chat/chatUtils.test.ts | Adds tests for recursive filtering/flattening + appendNodeResponseByParent. |
| packages/global/core/workflow/runtime/type.ts | Extends response schema with parentId, childResponseCount, and child detail type adjustments. |
| packages/global/core/chat/utils.ts | Adds childrenResponseFields, getChildrenResponses, appendNodeResponseByParent, recursive public filtering + flattening updates. |
| packages/global/core/chat/type.ts | Updates chat response schema to include parentId and childResponseCount. |
| .codex/design/core/workflow/node-response-stream-persistence.md | Adds a design doc describing the new persistence model and validations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return dispatchWorkFlow({ | ||
| chatId, | ||
| responseChatItemId, | ||
| mode: 'chat', | ||
| usageId, |
| aiContent: { | ||
| obj: ChatRoleEnum.AI, | ||
| value: assistantResponses, | ||
| [DispatchNodeResponseKeyEnum.nodeResponse]: flowResponses, | ||
| memories: system_memories, | ||
| customFeedbacks |
|
✅ Build Successful - Preview fastgpt Image for this PR: 🕒 Time: 2026-06-01 21:08:46 (UTC+8) |
No description provided.