Skip to content

Conversation

@TheRealNeil
Copy link
Contributor

@TheRealNeil TheRealNeil commented Feb 8, 2026

Prevent parent provider config leaking when child agent switches service

Fixes #304

Summary

  • Discard all inherited options when the child agent's provider service differs from the parent's, instead of only stripping :service and :api_version

Root cause

When a child agent overrides generate_with with a different provider (e.g. parent uses Ollama, child uses Azure), the merge in generate_with only removed :service and :api_version from inherited options. All other parent options (:host, :api_key, :model, etc.) survived and — because the merge order is global_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], replace inherited_options.extract!(:service, :api_version) with inherited_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 tweaks temperature).

Test plan

  • Child agent with a different generate_with provider uses its own YAML config (host, api_key, model)
  • Child agent with the same provider still inherits parent options correctly
  • Agent-level overrides (e.g. generate_with :azure, model: 'gpt-4.1') still take precedence

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.

generate_with inheritance: parent provider options leak into child when switching providers

1 participant