Skip to content

[APO-2622] Fix serialization of workflow input references in dataset scenarios#3468

Draft
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin/APO-2622-1767037358
Draft

[APO-2622] Fix serialization of workflow input references in dataset scenarios#3468
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin/APO-2622-1767037358

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Dec 29, 2025

Fixes an issue where sandbox.py files with dataset = [Inputs] (the class itself, not an instance) were not serializing scenarios correctly. The fix adds handling in three places:

  1. serialize_module - detects when a dataset entry is a BaseInputs subclass and converts it to an instance where each field is set to its corresponding WorkflowInputReference
  2. DatasetRow.serialize_inputs - uses the serializer from context for BaseDescriptor values to properly convert them to WORKFLOW_INPUT type descriptors
  3. WorkflowSandboxRunner - updates type annotation to accept Type[BaseInputs] and adds runtime handling to support the dataset = [Inputs] pattern

Review & Testing Checklist for Human

  • Verify __annotations__ captures all fields correctly (including inherited fields) - this is used in 3 places and could miss inherited fields
  • Test end-to-end by pushing a workflow with dataset = [Inputs] pattern to verify scenarios appear correctly in the UI
  • Confirm edge cases work: optional fields, fields with defaults, complex types

Notes

When a sandbox.py file has Inputs references (like Inputs.message), the
DatasetRow.serialize_inputs method now properly serializes them using
the serializer from the context. This fixes the issue where scenarios
with just Inputs references were not being serialized correctly.

The fix checks if the value is a BaseDescriptor instance before using
the serializer, so constant values continue to be serialized as-is.

Co-Authored-By: vargas@vellum.ai <vargas@vellum.ai>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

from .workflow import Inputs, TestDatasetWithInputReferencesWorkflow

if __name__ == "__main__":
raise Exception("This file is not meant to be imported")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DevinAI this is no longer convention, we now do the following at the bottom:

if __name__ == "__main__":
    runner.run()

raise Exception("This file is not meant to be imported")

dataset: List[Union[BaseInputs, DatasetRow]] = [
Inputs(message=Inputs.message, count=Inputs.count),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DevinAI this doesn't make any sense. Here's the repro from vellum-copilot:

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've addressed both comments:

  1. Updated the sandbox.py convention to move if __name__ == "__main__": runner.run() to the bottom
  2. Fixed the test case to use dataset = [Inputs] (the class itself) instead of Inputs(message=Inputs.message, count=Inputs.count) - this matches the actual repro case

I also added the necessary handling in three places:

  • serialize_module - detects when a dataset entry is a BaseInputs subclass and converts it to an instance
  • DatasetRow.serialize_inputs - uses the serializer from context for BaseDescriptor values
  • WorkflowSandboxRunner - updated type annotation and runtime handling to support the dataset = [Inputs] pattern

All CI checks are now passing.

devin-ai-integration Bot and others added 2 commits December 29, 2025 19:55
Address PR feedback:
- Fix serialize_module to handle when dataset contains BaseInputs subclass
  (e.g., [Inputs]) instead of just instances
- Update test case to use dataset = [Inputs] pattern matching actual repro
- Fix sandbox.py convention: move if __name__ to bottom with runner.run()

Co-Authored-By: vargas@vellum.ai <vargas@vellum.ai>
Update the type annotation and runtime handling to support the pattern
where users pass the Inputs class itself (e.g., dataset = [Inputs])
instead of an instance. This matches the actual user pattern shown in
the repro case.

Co-Authored-By: vargas@vellum.ai <vargas@vellum.ai>
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.

1 participant