Skip to content

Fix shared provider config state across Client instances#312

Open
rakeshutekar wants to merge 1 commit into
andrewyng:mainfrom
rakeshutekar:fix-client-provider-configs
Open

Fix shared provider config state across Client instances#312
rakeshutekar wants to merge 1 commit into
andrewyng:mainfrom
rakeshutekar:fix-client-provider-configs

Conversation

@rakeshutekar

Copy link
Copy Markdown

Summary

This fixes a shared mutable default in Client.__init__ where multiple Client() instances could share the same provider_configs dict.

Problem

provider_configs previously defaulted to {} and configure() mutates that dict in place. As a result, configuring one default client could leak provider settings into another default client.

Changes

  • Default provider_configs to None
  • Create a fresh provider config dict per Client
  • Copy provider config dictionaries on init and configure()
  • Pass copied configs into lazy provider initialization
  • Add regression tests for client config isolation

Test Plan

uv run --with pytest --with pydantic --with docstring-parser --with openai pytest tests/client/test_client.py

Result: 38 passed

Avoid sharing the default provider config mapping across Client instances and copy caller-provided provider configs before storing or passing them into provider initialization.
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