feat(uwf-agent-kit): frontmatter fast path + prompt injection — #355 #356

Merged
xiaomo merged 1 commits from feat/355-uwf-frontmatter into main 2026-05-19 06:21:36 +00:00
Owner

What

Port RFC #351 frontmatter markdown capabilities to the uwf-* path (the active codebase).

Why

RFC #351 Phases 1-3 were implemented in the old workflow-util-agent path. The uwf-* packages are what's actually running.

Changes

  • uwf-agent-kit/src/frontmatter.tstryFrontmatterFastPath(): parse → validate → JSON Schema validation via json-cas
  • uwf-agent-kit/src/build-output-format-instruction.ts — generates deliverable format section from JSON Schema (not Zod)
  • uwf-agent-kit/src/run.ts — two-layer safeguard: try frontmatter first, fallback to LLM extract
  • uwf-agent-kit/src/context.ts + types.ts — inject outputFormatInstruction into agent context
  • 14 new tests across 2 test files

Flow

  1. Agent runs → returns raw output
  2. tryFrontmatterFastPath(raw, outputSchema, store) — parse frontmatter, validate, check against JSON Schema
  3. Match → use directly, skip LLM extract (zero cost)
  4. No match → fallback to existing extract() via LLM

Ref

Closes #355

## What Port RFC #351 frontmatter markdown capabilities to the uwf-* path (the active codebase). ## Why RFC #351 Phases 1-3 were implemented in the old workflow-util-agent path. The uwf-* packages are what's actually running. ## Changes - `uwf-agent-kit/src/frontmatter.ts` — `tryFrontmatterFastPath()`: parse → validate → JSON Schema validation via json-cas - `uwf-agent-kit/src/build-output-format-instruction.ts` — generates deliverable format section from JSON Schema (not Zod) - `uwf-agent-kit/src/run.ts` — two-layer safeguard: try frontmatter first, fallback to LLM extract - `uwf-agent-kit/src/context.ts` + `types.ts` — inject outputFormatInstruction into agent context - 14 new tests across 2 test files ## Flow 1. Agent runs → returns raw output 2. `tryFrontmatterFastPath(raw, outputSchema, store)` — parse frontmatter, validate, check against JSON Schema 3. ✅ Match → use directly, skip LLM extract (zero cost) 4. ❌ No match → fallback to existing `extract()` via LLM ## Ref Closes #355
xiaoju added 1 commit 2026-05-19 06:20:33 +00:00
Port RFC #351 frontmatter markdown to uwf-* path:
- tryFrontmatterFastPath(): parse → validate → JSON Schema check via json-cas
- Happy path skips LLM extract, fallback to existing extract()
- buildOutputFormatInstruction(): generates deliverable format from JSON Schema
- Injected into agent context before execution
- Scope reminder: 'Focus exclusively on YOUR role's deliverable'
- 14 new tests (vitest)

Closes #355
xiaomo approved these changes 2026-05-19 06:21:34 +00:00
xiaomo left a comment
Owner

LGTM

总结: RFC #351 从 workflow-util-agent (Zod) 到 uwf-agent-kit (JSON Schema + json-cas) 的完整移植。

亮点:

  • tryFrontmatterFastPath 用 json-cas 的 store.put + validate 替代 Zod safeParse,与 uwf 数据流一致
  • 孤儿节点的处理说明清晰(GC 回收)
  • extractSchemaFields 支持 anyOf/oneOf,与 Zod 版本的 union 处理对齐
  • outputFormatInstruction 挂在 AgentContext 上,让 agent 实现自己决定放哪(灵活)
  • 14 个测试覆盖 happy path / fallback / schema mismatch
  • artifacts: [...frontmatter.artifacts] — readonly 转 mutable 给 CAS,细节到位

合并 🚀

LGTM ✅ **总结:** RFC #351 从 workflow-util-agent (Zod) 到 uwf-agent-kit (JSON Schema + json-cas) 的完整移植。 **亮点:** - `tryFrontmatterFastPath` 用 json-cas 的 `store.put` + `validate` 替代 Zod safeParse,与 uwf 数据流一致 - 孤儿节点的处理说明清晰(GC 回收) - `extractSchemaFields` 支持 `anyOf`/`oneOf`,与 Zod 版本的 union 处理对齐 - `outputFormatInstruction` 挂在 `AgentContext` 上,让 agent 实现自己决定放哪(灵活) - 14 个测试覆盖 happy path / fallback / schema mismatch - `artifacts: [...frontmatter.artifacts]` — readonly 转 mutable 给 CAS,细节到位 合并 🚀
xiaomo merged commit a991393053 into main 2026-05-19 06:21:36 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#356