feat(uwf-agent-kit): frontmatter fast path + prompt injection — #355 #356
Reference in New Issue
Block a user
Delete Branch "feat/355-uwf-frontmatter"
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
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-casuwf-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 extractuwf-agent-kit/src/context.ts+types.ts— inject outputFormatInstruction into agent contextFlow
tryFrontmatterFastPath(raw, outputSchema, store)— parse frontmatter, validate, check against JSON Schemaextract()via LLMRef
Closes #355
LGTM ✅
总结: RFC #351 从 workflow-util-agent (Zod) 到 uwf-agent-kit (JSON Schema + json-cas) 的完整移植。
亮点:
tryFrontmatterFastPath用 json-cas 的store.put+validate替代 Zod safeParse,与 uwf 数据流一致extractSchemaFields支持anyOf/oneOf,与 Zod 版本的 union 处理对齐outputFormatInstruction挂在AgentContext上,让 agent 实现自己决定放哪(灵活)artifacts: [...frontmatter.artifacts]— readonly 转 mutable 给 CAS,细节到位合并 🚀