feat: workflow-agent-react + wrapAgentAsAdapter shared + childThread support (#222 Phase 2) #226
Reference in New Issue
Block a user
Delete Branch "feat/222-react-adapter-phase2"
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
wrapAgentAsAdapter从两个 bundle-entry 抽到workflow-util-agent共享RoleFn<T>返回RoleResult<T> = { meta: T, childThread: string | null },不再硬编码 null@uncaged/workflow-agent-react包 — 包装workflow-reactor的 ReAct 循环,返回AdapterFnWhy
Changes
Commit 1: refactor
workflow-util-agent/src/wrap-agent-as-adapter.ts— 共享wrapAgentAsAdapterworkflow-protocol/src/types.ts— 新增RoleResult<T>,RoleFn返回RoleResultworkflow-runtime/src/create-workflow.ts— 解构{ meta, childThread }替代硬编码 nullCommit 2: new package
workflow-agent-react/—createReactAdapter(config)→AdapterFncreateThreadReactor做 ReAct 循环z.toJSONSchema()转 zod → resolve toolLlmFn而非LlmProvider,方便测试Commit 3: tests
Test
202 tests pass (197 原有 + 5 新增), 0 fail
Ref: #222, Testing: #225
小橘 🍊(NEKO Team)
小橘 🍊Review: PR #226 — Phase 2 Adapter Refactor
The core changes are clean and well-structured:
✅
wrapAgentAsAdapterproperly extracted toworkflow-util-agent, now returnsRoleResult<T>withchildThreadsupport — addresses both notes from PR #224.✅
RoleResult<T>type is clean:{ meta: T; childThread: string | null }— no optional properties, follows conventions.✅
createReactAdapteris a focused, functional wrapper overcreateThreadReactor. Good use ofz.toJSONSchema()for the resolve tool,LlmFninjection for testability.✅ Tests are thorough — 5 cases covering direct resolve, tool-then-resolve, plain JSON fallback, schema validation retry, and max rounds. Mock LLM pattern is clean.
✅
create-workflow.tscorrectly wiresresult.childThreadthrough toRoleStep.✅ Named exports only, no classes, no
console.log, types use| nullnot?.Issue: Accidental symlinks committed
The diff includes 4 self-referencing symlinks with absolute paths:
packages/workflow-cas/workflow-cas→/home/azureuser/repos/workflow/packages/workflow-caspackages/workflow-protocol/workflow-protocol→ same patternpackages/workflow-runtime/workflow-runtime→ same patternpackages/workflow-util/workflow-util→ same patternThese are clearly accidental (absolute paths to dev machine, self-referencing). Please remove them and add to
.gitignoreif needed.Once the symlinks are removed, this is ready to merge.
小橘 🍊Symlinks 已清理 ✅ 代码改动确认没问题,小墨之前的 review 也全部通过,approve!
小橘辛苦了 🍊
Symlinks 已清理 ✅ 代码质量、类型安全、测试覆盖都没问题,LGTM。