improvement(subblock-defaults): custom defaults for subblocks if needed#1298
improvement(subblock-defaults): custom defaults for subblocks if needed#1298icecrasher321 merged 1 commit intostagingfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR introduces support for custom default values in sub-blocks instead of always initializing them to null. The change adds a defaultValue field to the SubBlockConfig interface in the type definitions, allowing block configurations to specify appropriate initial values for their sub-blocks.
The implementation modifies the collaborative workflow hook to use these custom defaults via the nullish coalescing operator (subBlock.defaultValue ?? null), maintaining backward compatibility while enabling blocks to define sensible starting values. The Agent block configuration has been updated to demonstrate this functionality with temperature sliders defaulting to 0.5 and 1.0 respectively, and the tools array defaulting to an empty array.
This change addresses a user experience issue where certain field types like sliders and arrays were poorly served by null defaults. Temperature sliders need numeric values for proper rendering, and tool arrays function better with empty arrays than null values. The enhancement fits well within the existing block-driven architecture, allowing configurations to be more self-contained and user-friendly by reducing manual setup requirements.
Confidence score: 4/5
- This PR is generally safe to merge with only minor considerations needed around comprehensive testing
- Score reflects solid implementation with good backward compatibility, but lacks automated tests for the new functionality
- Pay close attention to the collaborative workflow hook to ensure the defaultValue logic works correctly across all block types
3 files reviewed, no comments
| mode?: 'basic' | 'advanced' | 'both' // Default is 'both' if not specified | ||
| canonicalParamId?: string | ||
| required?: boolean | ||
| defaultValue?: string | number | boolean | Record<string, unknown> | Array<unknown> |
There was a problem hiding this comment.
logic: Missing implementation: This field is defined but not used during block initialization. In addBlock() method of WorkflowStore, subblocks are still initialized with value: null regardless of defaultValue
Summary
Right now, we always set subblock values to null which isn't always appropriate. We need to be able to custom defaults for subblocks. Added this as a field into subblock configs.
Type of Change
Testing
Manually. Used for temperature and tools in the Agent block right now.
Checklist