fix(ai): preserve all GenerateActionOptions throughout lifecycle#283
fix(ai): preserve all GenerateActionOptions throughout lifecycle#283MichaelDoyle wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the preservation of generation options—including docs, resources, middleware, and stepName—across multi-turn loops and resume flows by refactoring GenerateActionOptions to use JSON-based cloning. It also introduces a new reflection API endpoint (/api/values) to list registered middleware and default models. Feedback was provided regarding the reflection server implementation, specifically to ensure that configuration serialization safely handles primitive types and utilizes modern Dart syntax for conditional map entries.
| 'config': value.config is Map | ||
| ? value.config | ||
| : (value.config as dynamic)?.toJson(), |
There was a problem hiding this comment.
The toJson() call on value.config is unsafe for primitive types. Additionally, it's safer to cast Map types to Map<String, dynamic> for JSON serialization. You can use the new Dart syntax 'key': ?value to conditionally include the entry only when a value is present, and ensure primitives are included directly without calling toJson().
'config': ?(value.config is Map
? (value.config as Map).cast<String, dynamic>()
: (value.config is String || value.config is num || value.config is bool)
? value.config
: (value.config as dynamic)?.toJson()),References
- The syntax 'key': ?value is valid in Dart for conditionally including map entries if value is not null. This is a new language feature.
No description provided.