Prevent leaking parent provider config by discarding inherited options for different services #312
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prevent parent provider config leaking when child agent switches service
Fixes #304
Summary
:serviceand:api_versionRoot cause
When a child agent overrides
generate_withwith a different provider (e.g. parent uses Ollama, child uses Azure), the merge ingenerate_withonly removed:serviceand:api_versionfrom inherited options. All other parent options (:host,:api_key,:model, etc.) survived and — because the merge order isglobal_options.merge(inherited_options)— overrode the child's YAML config. This caused requests to hit the wrong endpoint with the wrong credentials.Fix
When
global_options[:service] != inherited_options[:service], replaceinherited_options.extract!(:service, :api_version)withinherited_options = {}. This gives the child a clean slate from its own YAML config when switching providers, while preserving same-provider inheritance (e.g. a child that only tweakstemperature).Test plan
generate_withprovider uses its own YAML config (host, api_key, model)generate_with :azure, model: 'gpt-4.1') still take precedence