feat: 将 RFC #351 frontmatter markdown 移植到 uwf-* 路径 #355

Closed
opened 2026-05-19 06:08:30 +00:00 by xiaoju · 0 comments
Owner

背景

RFC #351 的三个 Phase 都实现在了旧的 workflow-util-agent 路径上,但当前实际使用的是 uwf-* 系列包:

  • uwf-agent-kit — agent 运行 + extract
  • uwf-agent-hermes — hermes agent 实现
  • uwf-moderator — moderator
  • uwf-protocol — 类型定义

需要将 frontmatter markdown 的能力移植到 uwf 路径。

需要做的事

1. frontmatter parser 复用

packages/workflow-util/src/frontmatter-markdown/ 已有 parseFrontmatterMarkdown()validateFrontmatter(),uwf-agent-kit 可以直接依赖 @uncaged/workflow-util

2. uwf-agent-kit extract 两层保障

修改 packages/uwf-agent-kit/src/run.tsextract.ts

  • agent 返回 raw output 后,先尝试 parseFrontmatterMarkdown
  • 如果 frontmatter 有效且满足 JSON Schema → 直接用,跳过 LLM extract
  • 否则 fallback 到现有 LLM extract 路径

注意 uwf 用的是 JSON Schema(不是 Zod),需要用 json-cas 的 validate 来校验 frontmatter 是否满足 outputSchema。

3. prompt 注入

packages/uwf-agent-kit/src/context.tsbuildContextWithMeta() 或 agent 调用链中,注入 frontmatter 输出格式指导 + scope 约束。

参考 packages/workflow-util-agent/src/build-output-format-instruction.ts 的实现,但需要适配 JSON Schema(而非 Zod)来提取字段列表。

4. 测试

  • frontmatter happy path(跳过 LLM)
  • fallback path(走 LLM extract)
  • prompt 包含 deliverable format section

参考

## 背景 RFC #351 的三个 Phase 都实现在了旧的 `workflow-util-agent` 路径上,但当前实际使用的是 `uwf-*` 系列包: - `uwf-agent-kit` — agent 运行 + extract - `uwf-agent-hermes` — hermes agent 实现 - `uwf-moderator` — moderator - `uwf-protocol` — 类型定义 需要将 frontmatter markdown 的能力移植到 uwf 路径。 ## 需要做的事 ### 1. frontmatter parser 复用 `packages/workflow-util/src/frontmatter-markdown/` 已有 `parseFrontmatterMarkdown()` 和 `validateFrontmatter()`,uwf-agent-kit 可以直接依赖 `@uncaged/workflow-util`。 ### 2. uwf-agent-kit extract 两层保障 修改 `packages/uwf-agent-kit/src/run.ts` 或 `extract.ts`: - agent 返回 raw output 后,先尝试 parseFrontmatterMarkdown - 如果 frontmatter 有效且满足 JSON Schema → 直接用,跳过 LLM extract - 否则 fallback 到现有 LLM extract 路径 注意 uwf 用的是 JSON Schema(不是 Zod),需要用 json-cas 的 validate 来校验 frontmatter 是否满足 outputSchema。 ### 3. prompt 注入 在 `packages/uwf-agent-kit/src/context.ts` 的 `buildContextWithMeta()` 或 agent 调用链中,注入 frontmatter 输出格式指导 + scope 约束。 参考 `packages/workflow-util-agent/src/build-output-format-instruction.ts` 的实现,但需要适配 JSON Schema(而非 Zod)来提取字段列表。 ### 4. 测试 - frontmatter happy path(跳过 LLM) - fallback path(走 LLM extract) - prompt 包含 deliverable format section ## 参考 - RFC #351 及其三个 PR:#352 #353 #354 - `packages/workflow-util/src/frontmatter-markdown/` — parser + validator - `packages/uwf-agent-kit/src/run.ts` — 当前 agent 运行流程 - `packages/uwf-agent-kit/src/extract.ts` — 当前 LLM extract 实现 - `packages/uwf-agent-kit/src/context.ts` — prompt 构建
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#355