fix: continuation prompt should include role output content, not just frontmatter #466

Closed
opened 2026-05-24 10:58:20 +00:00 by xiaoju · 0 comments
Owner

问题

buildContinuationPrompt 在 role re-entry 时,只把前序 step 的 frontmatter(step.output)传给 agent:

### Step 3: reviewer
Output: {"approved": false}
Agent: uwf-claude-code

Reviewer 详细写了四个 lint 问题、具体文件行号、修复建议,但这些内容在 detail node 里,不在 frontmatter 里。Developer 只知道"被打回了",不知道为什么,导致反复被 reject。

根因

build-continuation-prompt.tsformatStep 只用了 JSON.stringify(step.output)(frontmatter),没有包含 step 的实际文本输出。

方案

StepContext 或 continuation prompt 构建中,加入 step 的文本输出内容(即 thread read<output> tag 包裹的部分)。

function formatStep(step: StepContext, stepNumber: number): string {
  return [
    \`### Step \${stepNumber}: \${step.role}\`,
    \`Output: \${JSON.stringify(step.output)}\`,
    \`Agent: \${step.agent}\`,
    step.content ? \`\n<output>\n\${step.content}\n</output>\` : \"\",
  ].filter(Boolean).join("\n");
}

需要注意

  • content 可能很长(developer 的输出包含大量代码),需要 quota 控制
  • 优先展示最近的 step 内容,早期的可以截断
  • StepContext 类型可能需要扩展,加 content?: string 字段

涉及文件

  • packages/workflow-agent-kit/src/build-continuation-prompt.ts
  • packages/workflow-protocol/src/types.ts(StepContext 类型)
  • 上游构建 StepContext 的地方需要填充 content
## 问题 `buildContinuationPrompt` 在 role re-entry 时,只把前序 step 的 frontmatter(`step.output`)传给 agent: ``` ### Step 3: reviewer Output: {"approved": false} Agent: uwf-claude-code ``` Reviewer 详细写了四个 lint 问题、具体文件行号、修复建议,但这些内容在 detail node 里,不在 frontmatter 里。Developer 只知道"被打回了",不知道为什么,导致反复被 reject。 ## 根因 `build-continuation-prompt.ts` 的 `formatStep` 只用了 `JSON.stringify(step.output)`(frontmatter),没有包含 step 的实际文本输出。 ## 方案 在 `StepContext` 或 continuation prompt 构建中,加入 step 的文本输出内容(即 `thread read` 里 `<output>` tag 包裹的部分)。 ```typescript function formatStep(step: StepContext, stepNumber: number): string { return [ \`### Step \${stepNumber}: \${step.role}\`, \`Output: \${JSON.stringify(step.output)}\`, \`Agent: \${step.agent}\`, step.content ? \`\n<output>\n\${step.content}\n</output>\` : \"\", ].filter(Boolean).join("\n"); } ``` ### 需要注意 - content 可能很长(developer 的输出包含大量代码),需要 quota 控制 - 优先展示最近的 step 内容,早期的可以截断 - `StepContext` 类型可能需要扩展,加 `content?: string` 字段 ## 涉及文件 - `packages/workflow-agent-kit/src/build-continuation-prompt.ts` - `packages/workflow-protocol/src/types.ts`(StepContext 类型) - 上游构建 StepContext 的地方需要填充 content
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#466