-
-
Notifications
You must be signed in to change notification settings - Fork 521
feat: add separate workflow examples for functional and chaining APIs #998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add separate workflow examples for functional and chaining APIs #998
Conversation
- Convert with-workflow to use createWorkflow (functional API) - Add with-workflow-chain example using createWorkflowChain (fluent API) - Add workflowState/setWorkflowState examples to both - Add cross-reference admonitions in READMEs - Add type tests for non-chaining API context shape Co-Authored-By: Claude Opus 4.5 <[email protected]>
🦋 Changeset detectedLatest commit: f035d09 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughAdds a new fluent workflow example project, converts existing examples to the functional createWorkflow API, and refactors internal workflow state types in the core package to use WorkflowStepState. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Server as Hono Server (port 3141)
participant Volt as VoltAgent
participant Agent as Agent (analysis/content)
participant AI as External AI / LLM
rect rgba(200,230,255,0.5)
Client->>Server: HTTP request (trigger workflow)
Server->>Volt: invoke workflow by name
end
rect rgba(220,255,220,0.5)
Volt->>Agent: call agent step (andAgent/andThen)
Agent->>AI: call external LLM (if used)
AI-->>Agent: AI response
Agent-->>Volt: step result (may update workflowState)
end
rect rgba(255,230,200,0.5)
Volt->>Volt: manage workflowState / setWorkflowState
Volt-->>Server: workflow completion / response
Server-->>Client: HTTP response
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@examples/with-workflow-chain/src/index.ts`:
- Around line 602-606: The logger variable created via createPinoLogger uses the
name "with-workflow" but the example is "with-workflow-chain"; update the name
passed to createPinoLogger (the call that assigns logger) to
"with-workflow-chain" so logs and filters reflect the correct example context.
🧹 Nitpick comments (2)
examples/with-workflow-chain/.env.example (1)
4-4: Add trailing newline for POSIX compliance.POSIX standards recommend files end with a newline character. This is a minor style issue but worth fixing for consistency.
📝 Proposed fix
VOLTAGENT_SECRET_KEY=your_VOLTAGENT_SECRET_KEY +examples/with-workflow-chain/src/index.ts (1)
49-70: Prefer the workflow-scoped logger overconsole.log.
Usingloggerkeeps structured context (workflow/user/execution) and aligns with the example’s configured logger. Consider applying this pattern to the otherconsole.logcalls in this file.♻️ Suggested change (example for this step)
- execute: async ({ data, setWorkflowState }) => { - console.log(`Validating order ${data.orderId}...`); + execute: async ({ data, setWorkflowState, logger }) => { + logger.info({ orderId: data.orderId }, "Validating order");
| // Create logger | ||
| const logger = createPinoLogger({ | ||
| name: "with-workflow", | ||
| level: "debug", | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align logger name with the example.
The logger name currently says "with-workflow" but this example is with-workflow-chain, which can mislead log filtering.
🔧 Suggested fix
- name: "with-workflow",
+ name: "with-workflow-chain",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Create logger | |
| const logger = createPinoLogger({ | |
| name: "with-workflow", | |
| level: "debug", | |
| }); | |
| // Create logger | |
| const logger = createPinoLogger({ | |
| name: "with-workflow-chain", | |
| level: "debug", | |
| }); |
🤖 Prompt for AI Agents
In `@examples/with-workflow-chain/src/index.ts` around lines 602 - 606, The logger
variable created via createPinoLogger uses the name "with-workflow" but the
example is "with-workflow-chain"; update the name passed to createPinoLogger
(the call that assigns logger) to "with-workflow-chain" so logs and filters
reflect the correct example context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 13 files
Co-Authored-By: Claude Opus 4.5 <[email protected]>
omeraplak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @zrosenbauer
Summary
with-workflowto usecreateWorkflow(functional API) with step functions passed as argumentswith-workflow-chainexample usingcreateWorkflowChain(fluent chaining API)workflowState/setWorkflowStateexamples to both workflowsTest plan
with-workflowexample runs correctly withcreateWorkflowwith-workflow-chainexample runs correctly withcreateWorkflowChainworkflowStateandsetWorkflowStatework in both examplespnpm vitest packages/core/src/workflow/core.spec-d.ts🤖 Generated with Claude Code
Summary by cubic
Added separate workflow examples for both APIs and documented workflowState/setWorkflowState usage. Also fixed the non-chaining API so workflowState is correctly available in step contexts.
New Features
Bug Fixes
Written for commit f035d09. Summary will update on new commits.
Summary by CodeRabbit
New Features
Documentation
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.