feat(protocol): AdapterFn replaces AgentBinding in createWorkflow (#222 Phase 1) #224
Reference in New Issue
Block a user
Delete Branch "feat/222-adapter-fn-phase1"
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
新增
AdapterFn/RoleFn<T>/AdapterBinding类型,createWorkflow改为接受AdapterBinding。Adapter 直接返回类型安全的T,engine 不再调用runtime.extract。Why
现有
AgentFn → string → Extract → meta流程浪费一轮 LLM 调用。AdapterFn让 adapter 自己决定如何拿到 structured output(ReAct agent 可以内置 resolve tool 一步到位)。RFC:
docs/plans/2026-05-12-react-agent.mdChanges
workflow-protocol/src/types.ts— 新增RoleFn<T>,AdapterFn,AdapterBinding;旧类型标记@deprecatedworkflow-runtime/src/create-workflow.ts— 接受AdapterBinding,调用adapter(prompt, schema)拿RoleFn,直接获取 metaworkflow-util-agent/src/build-agent-prompt.ts— 新增buildThreadInput(ctx: ThreadContext)workflow-template-develop/bundle-entry.ts—wrapAgentAsAdapter包装 cursor agentworkflow-template-solve-issue/bundle-entry.ts— 同上包装 hermes + workflowAsAgentsolve-issue-template.test.ts— 适配新接口Test
197 tests pass, 0 fail
Ref: #222, Testing: #223
小橘 🍊(NEKO Team)
LGTM — clean Phase 1 adapter refactor.
Type safety:
AdapterFngeneric flows correctly fromschema: z.ZodType<T>→RoleFn<T>→Promise<T>. Theas Tcast inwrapAgentAsAdapteris pragmatic for the bridge layer.Conventions: No optional props (uses
| null), functional types only, named exports,@deprecatedtags on old types. ✅Two minor notes for Phase 2:
wrapAgentAsAdapteris duplicated in bothdevelop/bundle-entry.tsandsolve-issue/bundle-entry.ts. Consider extracting to a shared util (e.g.workflow-util-agent) when the old agent types are removed.childThreadis hardcoded tonullinadvanceOneRound. If any workflow relies on child thread propagation viaAgentFnResult, this is a silent regression. Looks intentional for Phase 1 but worth tracking.197 tests pass. Ship it. 🍊