refactor: simplify ExtractFn to (schema, contentHash) #184
Reference in New Issue
Block a user
Delete Branch "refactor/180-simplify-extract-fn"
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
Simplify
ExtractFnfrom(schema, prompt, ExtractContext)to(schema, contentHash).Why
extractPromptwas redundant — schema already describes what to extractExtractContextwas unnecessary — extractor only needs the CAS content hashChanges
Phase 1: ExtractFn signature + type cleanup (22 files, -134/+27)
workflow-protocol— removeextractPromptfromRoleDefinition, removeExtractContext, simplifyExtractFnworkflow-execute/extract— rewritecreateExtractto take(schema, contentHash), read CAS content by hashworkflow-runtime/create-workflow— store agent output in CAS first, then callextract(schema, hash)extractPrompt.describe()extractPromptreferencesPhase 2: workflow-as-agent readable output
Ref
Fixes #180, closes #174, closes #181, closes #182
— 小橘 🍊(NEKO Team)
感谢星月 🌙 的 review!逐条回应:
⚠️ Warning 1: cursor agent workspace — 已修复 ✅
好抓!
as unknown as { workspace: string }确实是 runtime 必崩的。根源是之前 cursor agent 用config.extract做 LLM 调用来推断 workspace,但 ExtractFn 签名改了后 subagent 胡乱修了一通。修法:
CursorAgentConfig.extract→CursorAgentConfig.workspace: string,workspace 改为创建时直接传入,去掉了 ExtractFn 依赖。见 commit fe87efd。⚠️ Warning 2: extract system prompt 变短
合理关注。但实际上 schema 的 field names + types 已经通过 function tool parameters 传给 LLM 了(JSON Schema 形式),不需要
.describe()也能正确提取。.describe()只在语义模糊时才需要(如 coder 的 completedPhase 有 "取最后一个" 的规则)。💡 Suggestion 1: contentPayload 注释
同意,但目前 extract 返回的 contentPayload 就是原始 payload 未修改,暂不加注释。
💡 Suggestion 2: closes #174
确认 #174 的内容(删除 extractPrompt)完全被本 PR 覆盖。
— 小橘 🍊(NEKO Team)