Skip to content

fix(workflow): improve typing for state parameter#1124

Open
Rootlogger wants to merge 2 commits intoVoltAgent:mainfrom
Rootlogger:fix/workflow-typing-645
Open

fix(workflow): improve typing for state parameter#1124
Rootlogger wants to merge 2 commits intoVoltAgent:mainfrom
Rootlogger:fix/workflow-typing-645

Conversation

@Rootlogger
Copy link

@Rootlogger Rootlogger commented Mar 3, 2026

Summary

Replace DangerouslyAllowAny with unknown in WorkflowState and WorkflowStepState types to provide stricter type checking for workflow state parameter in execute handlers.

Changes

  • packages/core/src/workflow/internal/state.ts: Changed data: DangerouslyAllowAny to data: unknown
  • packages/core/src/workflow/types.ts: Changed WorkflowState<INPUT, DangerouslyAllowAny> to WorkflowState<INPUT, unknown>

Motivation

This addresses issue #645 where state was typed as any making it difficult to debug workflow execution code. Using unknown provides better type safety while maintaining compatibility with existing code.

Testing

The change is purely TypeScript type-level and does not affect runtime behavior.

Closes #645


Summary by cubic

Tightens typing of workflow state by replacing DangerouslyAllowAny with unknown in WorkflowState and WorkflowStepState to improve type safety of the state parameter in execute handlers; adds a changeset. Addresses #645 with no runtime impact.

Written for commit 0efe879. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Improved type safety for workflow state parameters to enforce stricter type checking and enhance type definitions.

Replace DangerouslyAllowAny with unknown in WorkflowState and WorkflowStepState types to provide stricter type checking for workflow state parameter in execute handlers.

This addresses issue VoltAgent#645 where state was typed as 'any' making it difficult to debug workflow execution code.

Closes VoltAgent#645
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: 0efe879

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 Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 527f2cf and 0efe879.

📒 Files selected for processing (3)
  • .changeset/olive-ears-smoke.md
  • packages/core/src/workflow/internal/state.ts
  • packages/core/src/workflow/types.ts

📝 Walkthrough

Walkthrough

This pull request improves type safety for the workflow state parameter by replacing DangerouslyAllowAny with unknown in the WorkflowState type definition across two source files, alongside a changeset entry documenting the patch-level fix.

Changes

Cohort / File(s) Summary
Release Documentation
.changeset/olive-ears-smoke.md
Added changeset file documenting patch release with message "fix(workflow): improve typing for state parameter".
Type Definitions
packages/core/src/workflow/internal/state.ts, packages/core/src/workflow/types.ts
Changed WorkflowState data field type from DangerouslyAllowAny to unknown, tightening type constraints for state parameter in workflow handlers.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A little hop and type so tight,
From any to unknown - oh what a sight!
No more danger lurking in the dark,
State's now safer, precise as a lark!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(workflow): improve typing for state parameter' accurately summarizes the main change of replacing DangerouslyAllowAny with unknown for better type safety in WorkflowState and WorkflowStepState.
Description check ✅ Passed The PR description comprehensively covers summary, changes, motivation, testing notes, and issue reference. All required template sections are addressed with clear information about the type-level modifications.
Linked Issues check ✅ Passed The PR directly addresses issue #645 by replacing DangerouslyAllowAny with unknown to provide stricter typing for the state parameter, exactly as requested to improve debugging and type safety.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objective: replacing DangerouslyAllowAny with unknown in WorkflowState and WorkflowStepState types, plus adding a changeset. No extraneous modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@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 2 files

@Rootlogger
Copy link
Author

Thanks for the review! No actionable changes from CodeRabbit — let me know if there's anything else I can help with. Happy to adjust if needed. 🙏

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.

[FEAT] Improve typing of workflow state parameter

1 participant