docs(research): ai-orchestration integration memo#7
Merged
Conversation
Walks PR 542 (TanStack/ai) against workflow-core@0.0.1 file-by-file. Three integration options analyzed; recommends Path B (refactor ai-orchestration onto workflow-core). Concrete list of 18 files to delete (engine, primitives, runStore, server, registry, result, define-workflow — all superseded by workflow-core), 5-7 files to keep and refactor (defineAgent, invokeAgent, defineOrchestrator as closure-loop, defineRouter, types.ts, index.ts, optional withAgents middleware). Validates the agent layer can be expressed on workflow-core with zero engine changes — step bodies close over ctx, so ctx.emit forwards agent stream chunks inline. Optional withAgents middleware adds a typed ctx.agent(stepId, def, input) primitive for ergonomic invocation that reads structurally identical to Alem's existing yield* agents.x(input) style. Includes a before/after of Alem's article workflow (two changes per call site: yield* → await, plus stepId as first arg). Estimated refactor cost: one focused day. Updates research/README.md to include the new file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Memo on what can be removed from TanStack/ai#542 now that `@tanstack/workflow-core@0.0.1` is on npm, and how the AI-specific APIs there compose with the shipping engine.
TL;DR
Path B — refactor ai-orchestration to sit on workflow-core. Sheds 18 of 25 source files. The AI layer narrows to: `defineAgent`, `defineOrchestrator`, `defineRouter`, `invokeAgent` (kept as a helper for the three-shape detection), a slim AI-only `types.ts`, and an optional `withAgents` middleware that adds `ctx.agent(stepId, def, input)` for ergonomic invocation.
Key findings
What's in the doc
Test plan