Skip to content

Conversation

@zrosenbauer
Copy link
Contributor

@zrosenbauer zrosenbauer commented Jan 28, 2026

Summary

  • Convert with-workflow to use createWorkflow (functional API) with step functions passed as arguments
  • Add with-workflow-chain example using createWorkflowChain (fluent chaining API)
  • Add workflowState/setWorkflowState examples to both workflows
  • Add cross-reference admonitions in READMEs linking to the alternative API
  • Add type tests for non-chaining API context shape

Test plan

  • Verify with-workflow example runs correctly with createWorkflow
  • Verify with-workflow-chain example runs correctly with createWorkflowChain
  • Verify workflowState and setWorkflowState work in both examples
  • Run type tests: pnpm 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

    • Converted with-workflow to use createWorkflow (functional API).
    • Added with-workflow-chain example using createWorkflowChain (fluent API).
    • Demonstrated workflowState/setWorkflowState in both examples.
    • Added README cross-links between the two APIs.
  • Bug Fixes

    • Exposed workflowState and setWorkflowState in non-chaining execute contexts and andForEach selectors.
    • Updated internal types to use WorkflowStepState for consistent context shape.
    • Added type tests to ensure parity with the chaining API.

Written for commit f035d09. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added two workflow example demos showcasing both functional and fluent chaining APIs and persisting state across steps
  • Documentation

    • New README for the chaining example and updated existing example docs with a tip linking the APIs
    • Example .env and project config added for the chain demo
  • Tests

    • Added type-level tests validating the non-chaining workflow API
  • Chores

    • Updated ignore rules and example project configs

✏️ Tip: You can customize this high-level summary in your review settings.

- 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-bot
Copy link

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: f035d09

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
New with-workflow-chain example
examples/with-workflow-chain/...
Adds a complete example project: package.json, tsconfig.json, .gitignore, .env.example, README.md, and src/index.ts demonstrating nine fluent chaining workflows and wiring a Hono server.
Updated with-workflow example
examples/with-workflow/README.md, examples/with-workflow/src/index.ts
Replaces chaining usage with the functional createWorkflow(config, steps) API; rewrites all example workflows to use explicit per-step state (workflowState, setWorkflowState) and new execution contexts.
Core workflow internals
packages/core/src/workflow/internal/types.ts, packages/core/src/workflow/internal/utils.ts
Removes InternalWorkflowStateParam, replaces it with WorkflowStepState in WorkflowExecuteContext and related utils; updates convertWorkflowStateToParam and createStepExecutionContext signatures and imports.
Type-level tests
packages/core/src/workflow/core.spec-d.ts
Adds type-spec tests validating the non-chaining API's execute context (including workflowState / setWorkflowState) and parity with chaining API types.
Changeset & repo housekeeping
.changeset/add-workflow-examples.md, .gitignore
Adds a changeset documenting the patch and ignores for serena artifacts.
Example metadata / docs
examples/with-workflow-chain/README.md, examples/with-workflow-chain/.env.example, examples/with-workflow-chain/package.json, examples/with-workflow-chain/tsconfig.json, examples/with-workflow-chain/.gitignore
Adds docs, env placeholders, package metadata, TypeScript config, and gitignore for the new example project.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through steps both chained and free,
State tucked in pockets for each step to see,
Examples sprout petals, nine ways to play,
Types snugly stitched for the new workflow way,
A rabbit applauds — hop, test, deploy today!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding separate examples for both functional (createWorkflow) and chaining (createWorkflowChain) APIs.
Description check ✅ Passed The description covers the main objectives, test plan with verification steps, and includes both author summary and auto-generated summary, though it lacks explicit mention of related issue links and changesets in the structured checklist format.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 over console.log.
Using logger keeps structured context (workflow/user/execution) and aligns with the example’s configured logger. Consider applying this pattern to the other console.log calls 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");

Comment on lines +602 to +606
// Create logger
const logger = createPinoLogger({
name: "with-workflow",
level: "debug",
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
// 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.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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]>
Copy link
Member

@omeraplak omeraplak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @zrosenbauer

@omeraplak omeraplak merged commit e209e3a into VoltAgent:main Jan 28, 2026
4 of 21 checks passed
@zrosenbauer zrosenbauer deleted the bug/fix-workflow-state-non-chaining branch January 28, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants