Skip to content

feat(providers): add extra_query config for OpenAI-compatible providers#4217

Merged
Re-bin merged 1 commit into
HKUDS:mainfrom
axelray-dev:feat/extra-query-config
Jun 8, 2026
Merged

feat(providers): add extra_query config for OpenAI-compatible providers#4217
Re-bin merged 1 commit into
HKUDS:mainfrom
axelray-dev:feat/extra-query-config

Conversation

@axelray-dev

Copy link
Copy Markdown
Contributor

Addresses the extra_query portion of #4204.

Summary

Some Azure-style gateways require ?api-version= query params on the chat-completions endpoint. This adds a ProviderConfig.extra_query field, threaded through the factory into AsyncOpenAI(default_query=...), so users can configure query params via JSON config.

The provider_signature tuple now includes extra_query so per-turn refresh rebuilds the provider when the value changes.

This PR implements only the extra_query part of #4204. The max_completion_tokens model-awareness enhancement is intentionally left as a separate change.

Changes

  • nanobot/config/schema.py: Add extra_query: dict[str, str] | None = None to ProviderConfig
  • nanobot/providers/factory.py: Thread extra_query into OpenAICompatProvider constructor and provider_signature
  • nanobot/providers/openai_compat_provider.py: Accept extra_query param, store it, pass default_query= to AsyncOpenAI
  • tests/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 passed
  • pytest tests/providers/test_extra_body_config.py tests/agent/test_runner_fallback.py -v: 48/48 passed (no regressions)
  • ruff check on all changed files: all checks passed
  • git diff --check: clean

Added or updated tests

8 new tests in tests/providers/test_extra_query_config.py:

  • Schema acceptance (default None, accepts dict)
  • Provider storage (default empty, None becomes empty, dict stored)
  • Client construction (default_query passed to AsyncOpenAI, None when empty)
  • Signature tracking (extra_query changes produce different signatures)

QA follow-up

  • Test with a real Azure-style gateway to confirm ?api-version= is appended to requests
  • Confirm that extra_query in the config JSON maps correctly via camelCase alias

Checklist

  • I have read the CONTRIBUTING guide
  • Tests pass locally
  • Linting passes locally (ruff)

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.
@axelray-dev axelray-dev marked this pull request as ready for review June 6, 2026 07:07
@chengyongru chengyongru added enhancement New feature or request provider labels Jun 8, 2026
@chengyongru chengyongru linked an issue Jun 8, 2026 that may be closed by this pull request
@Re-bin Re-bin merged commit 28f3a20 into HKUDS:main Jun 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request provider valid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PATCH] Add extra_query support for OpenAI-compatible providers

3 participants