feat(llm): env var to force/disable Responses API for OpenAI/Azure#15
Merged
Conversation
Add OPENAI_USE_RESPONSES_API / AZURE_USE_RESPONSES_API (plus generic LLM_USE_RESPONSES_API fallback) to override Responses API routing without editing config.json. Precedence: provider env > generic env > use_responses_api config flag > model-prefix auto-detect. Resolved at call time so changes apply without restart. Explicit override bypasses the endpoint capability gate (mirrors config-flag semantics); warns when forced on against an unsupported endpoint (e.g. Azure api-version < 2025-03-01). Invalid values logged and ignored, falling through to auto-detect.
This was referenced Jul 7, 2026
ngoclam9415
added a commit
that referenced
this pull request
Jul 7, 2026
Two unrelated groups, both pre-existing on develop: 1. tests/unit/core/test_inject_llm_provider.py (3 failures) Tests pass llm_provider="openai"/"anthropic" (string) which eagerly builds a real provider requiring OPENAI_API_KEY/ANTHROPIC_API_KEY. They only check identity wiring and never call the LLM. Add an autouse fixture that supplies dummy env keys so construction succeeds offline. 2. tests/unit/test_llm_providers.py::TestOpenAIReasoningTokens (3 failures) Thinking models (gpt-5*) route through the Responses API since #9/#15, but these tests still mocked client.chat.completions.create — so the awaited call hit an un-mocked MagicMock ("can't be awaited"). Rewrite to mock client.responses.create with a Responses-API-shaped response (output items + usage.output_tokens_details.reasoning_tokens) via a shared helper.
3 tasks
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.
Summary
Adds an environment-variable override to force or disable the OpenAI Responses API per provider — no
config.jsonedit required.OPENAI_USE_RESPONSES_API1/true/on/yes↔0/false/off/noAZURE_USE_RESPONSES_APILLM_USE_RESPONSES_APIResolution precedence (
_should_use_responses_api)Mirrors the existing
*_THINKING_EFFORTenv pattern. Resolved at call time, so changes take effect without a process restart.Behavior / trade-offs
use_responses_apiconfig flag (operator takes responsibility). Forcing on against an unsupported endpoint (e.g. Azure api-version <2025-03-01) emits alogger.warningso the likely 400 is debuggable rather than silent. BumpAZURE_OPENAI_API_VERSIONto2025-03-01-preview+ to use it on Azure.maybe) are logged and ignored, falling through to auto-detect.LLM_USE_RESPONSES_API(scoped to OpenAI/Azure per request).Files
dana/common/llm/providers/openai_compatible_base.py—_resolve_use_responses_api_env(),_RESPONSES_API_ENV_VARattr, updated precedence + warningdana/common/llm/providers/{openai,azure}.py— wired provider env var namestests/unit/llm/test_responses_api_routing.py— 9 new casesTesting
test_responses_api_routing.py: 40 passed