feat(providers): add extra_query config for OpenAI-compatible providers#4217
Merged
Conversation
Adds ProviderConfig.extra_query, threaded into AsyncOpenAI(default_query) so that Azure-style gateways requiring query params like api-version can be configured without URL hacks. Also updates provider_signature to track extra_query changes so per-turn refresh rebuilds the provider when the value changes. Addresses the extra_query portion of HKUDS#4204. The max_completion_tokens model-awareness enhancement is intentionally left separate.
This was referenced Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses the extra_query portion of #4204.
Summary
Some Azure-style gateways require
?api-version=query params on the chat-completions endpoint. This adds aProviderConfig.extra_queryfield, threaded through the factory intoAsyncOpenAI(default_query=...), so users can configure query params via JSON config.The
provider_signaturetuple now includesextra_queryso per-turn refresh rebuilds the provider when the value changes.This PR implements only the
extra_querypart of #4204. Themax_completion_tokensmodel-awareness enhancement is intentionally left as a separate change.Changes
nanobot/config/schema.py: Addextra_query: dict[str, str] | None = NonetoProviderConfignanobot/providers/factory.py: Threadextra_queryintoOpenAICompatProviderconstructor andprovider_signaturenanobot/providers/openai_compat_provider.py: Acceptextra_queryparam, store it, passdefault_query=toAsyncOpenAItests/providers/test_extra_query_config.py: 8 new tests (schema, init, build_client, signature)tests/agent/test_runner_fallback.py: Update signature tuple index (shifted by +1 from extra_query insertion)Testing
Verified locally
pytest tests/providers/test_extra_query_config.py -v: 8/8 passedpytest tests/providers/test_extra_body_config.py tests/agent/test_runner_fallback.py -v: 48/48 passed (no regressions)ruff checkon all changed files: all checks passedgit diff --check: cleanAdded or updated tests
8 new tests in
tests/providers/test_extra_query_config.py:QA follow-up
?api-version=is appended to requestsextra_queryin the config JSON maps correctly via camelCase aliasChecklist