fix: include step content in continuation prompt #472
Reference in New Issue
Block a user
Delete Branch "fix/466-continuation-prompt-content"
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
Fixes #466 —
buildAgentPromptnow includes the last step's actual text content, not just its frontmatter metadata.Why
When a reviewer writes detailed feedback (specific lint issues, file paths, line numbers), the developer role only saw
{"approved": false}becausebuildContinuationPromptonly includedstep.meta(frontmatter). The detailed review comments lived in the content node but were never passed to the agent.Changes
Protocol (
workflow-protocol)content: string | nulltoRoleSteptypeEngine (
workflow-execute)executeThreadresolvescontentHash→ text for the last step viagetContentMerklePayloadwhen buildingThreadContextcontent: null(only meta summaries) to avoid bloating the promptRuntime (
workflow-runtime)buildRoleStepsFromStatesresolves content for the last step using the already-loadedcontentParsed.node.payloadcreateWorkflowpopulatescontentfromextracted.contentPayloadon yieldAgent Prompt (
workflow-util-agent)buildAgentPromptwraps content in<output>tags for the latest stepContentHash:line removed (redundant when content is inlined)Tests
contentfieldExample
Before:
After:
Code Review — 小橘 🍊(NEKO Team)
Verdict: Approved ✅
改动分析
改动清晰、范围收敛,6 文件 +113 -17,只做一件事:把最后一步的 content 全文传给下一个 agent。
Protocol (
types.ts)RoleStep加content: string | null— 合理,用null而非?:符合项目规范 ✅Engine (
engine.ts)Promise.all+isLast判断只解析最后一步 — 性能友好 ✅getContentMerklePayload已有现成函数,复用得当 ✅Runtime (
build-context.ts,create-workflow.ts)for-of→for+idx改法直白,isLast判断一致 ✅create-workflow.ts在 yield 时填充extracted.contentPayload,保证新产出的 step 也带 content ✅Prompt (
build-agent-prompt.ts)<output>标签包裹 — LLM 友好的标记方式 ✅CONTENT_QUOTA = 16_000截断防爆 ✅appendContent处理 null/undefined/空字符串 ✅ContentHash:行 ✅Tests
💡 一个小建议(不阻塞)
appendContent签名是content: string | null | undefined,但RoleStep.content类型是string | null(无 undefined)。undefined检查是防御性的,不影响正确性,但如果想严格对齐可以只留null。⚠️ 注意
PR 需要 rebase main — cli-workflow 测试在 main 上有新增用例(#467/#468),当前 PR 分支缺少这些文件会导致 CI 失败。PR 自身改动的包测试全部通过。
LGTM 🎯
6663f6cf96toeb027e70f4