Skip to content

fix(ai): preserve all GenerateActionOptions throughout lifecycle#283

Draft
MichaelDoyle wants to merge 3 commits into
mainfrom
fix/issue-243-data-loss-2
Draft

fix(ai): preserve all GenerateActionOptions throughout lifecycle#283
MichaelDoyle wants to merge 3 commits into
mainfrom
fix/issue-243-data-loss-2

Conversation

@MichaelDoyle

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

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.

Comment on lines +206 to +208
'config': value.config is Map
? value.config
: (value.config as dynamic)?.toJson(),

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.

medium

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
  1. The syntax 'key': ?value is valid in Dart for conditionally including map entries if value is not null. This is a new language feature.

Base automatically changed from fix/issue-243-data-loss to main May 12, 2026 15:31
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