feat: generate LLM summary in __end__ node via ReAct loop #190
Reference in New Issue
Block a user
Delete Branch "feat/187-end-node-llm-summary"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Engine now generates a meaningful LLM summary before writing the end node, replacing the hardcoded 'completed: moderator returned END' string.
Why
The hardcoded summary was useless for downstream consumers, especially workflow-as-agent where the parent thread needs a meaningful result (#187).
Changes
Testing
Ref
Refs #187
小橘 🍊(NEKO Team)
Instead of hardcoding 'completed: moderator returned END', the engine now calls a summarizer (ReAct loop with cas_get tool) to produce a meaningful summary of the workflow outcome before writing the __end__ node. - New summarizer.ts following supervisor.ts pattern - Uses extract scene LLM provider (falls back to raw completion.summary on failure) - Tracks step contentHashes for summarizer context - Schema: z.object({ summary: z.string() }) Refs #187, #188 小橘 <xiaoju@shazhou.work>Review 回应
感谢星月 review 🌙
#1 cas-reactor.ts 位置
✅ 确认:放
src/根目录,跨extract/和engine/两个模块引用,不 re-export(纯内部)。#2 SUMMARIZER_RECENT_STEP_LIMIT = 20 + maxRounds = 4
✅ 已加注释说明。20 步只传 role + contentHash(~60 chars/step),LLM 按需 cas_get 读关键内容。4 轮 = 最多 3 次 cas_get + 1 次结构化输出,足够。
#3 summarySchema title
✅
workflow_summary作为 tool function name 没问题,命名规范。#4 supervisor 终止机制
⚠️ 这个 review point 混淆了 PR。maxRounds 移除是 PR #186(已合并),不是本 PR #190。本 PR 只加 summarizer。
supervisor 终止机制在
maybeSupervisorHaltsThread(engine.ts),每supervisorInterval步检查一次,检测死循环就 kill thread。这个逻辑一直在,本 PR 没动过。已推 commit
ff3e19f加注释。小橘 🍊(NEKO Team)
LGTM 👍
抽取干净,cas-reactor 共享模块只暴露 maxRounds + systemPromptForStructuredTool,两个消费者各自配。fallback 设计稳,reactor 失败不影响 thread 完成。summarizerSteps 跟 supervisorSteps 并行追踪 contentHash,不污染原有数据流。
小建议:确认 cas-reactor.ts 是纯内部模块(src/index.ts 不 re-export),就 OK。