Skip to content

feat: node response store#7035

Open
c121914yu wants to merge 1 commit into
labring:mainfrom
c121914yu:codex/upstream-main
Open

feat: node response store#7035
c121914yu wants to merge 1 commit into
labring:mainfrom
c121914yu:codex/upstream-main

Conversation

@c121914yu
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings June 1, 2026 12:58
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 13.96% 1140 / 8161
🔵 Statements 13.95% 1195 / 8564
🔵 Functions 12.47% 245 / 1964
🔵 Branches 11.93% 536 / 4490
File CoverageNo changed files found.
Generated in workflow #526 for commit 77b48f1 by the Vitest Coverage Report Action

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +365 to +366
// 先写父再写子,配合 Mongo _id 排序,详情页能沿用运行时自然顺序展示。
children.forEach((child) => visit(child, id));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 + nodeResponseSummary rather than inline responseData.
  • 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.

Comment on lines 132 to 136
return dispatchWorkFlow({
chatId,
responseChatItemId,
mode: 'chat',
usageId,
Comment on lines 111 to 115
aiContent: {
obj: ChatRoleEnum.AI,
value: assistantResponses,
[DispatchNodeResponseKeyEnum.nodeResponse]: flowResponses,
memories: system_memories,
customFeedbacks
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Build Successful - Preview fastgpt Image for this PR:

ghcr.io/labring/fastgpt-pr:fastgpt_77b48f12cbdb774f694d02aa65146bd1ccadcfd7

🕒 Time: 2026-06-01 21:08:46 (UTC+8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants