Skip to content

refactor(config): dedupe QWEN_CODE_API_TIMEOUT_MS env override logic#3651

Closed
B-A-M-N wants to merge 5 commits into
QwenLM:mainfrom
B-A-M-N:refactor/dedupe-timeout-env-override
Closed

refactor(config): dedupe QWEN_CODE_API_TIMEOUT_MS env override logic#3651
B-A-M-N wants to merge 5 commits into
QwenLM:mainfrom
B-A-M-N:refactor/dedupe-timeout-env-override

Conversation

@B-A-M-N

@B-A-M-N B-A-M-N commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extracts duplicated QWEN_CODE_API_TIMEOUT_MS env override block into a shared helper applyTimeoutEnvOverride()
  • Used by both resolveModelConfig() and resolveQwenOAuthConfig()
  • Preserves precedence: modelProvider > env > settings > default
  • Adds [Regression] tests guarding against the original OAuth-path bug
  • Adds additional edge-case tests (scientific notation, hex values, empty strings, all auth types)

What changed

  • modelConfigResolver.ts: Replace ~30 lines of duplicated logic with a single helper function
  • modelConfigResolver.test.ts: +8 tests ([Regression] × 4, [Additional] × 4)

Why a separate PR

The behavior change (PR #3629) and the refactor are intentionally split:

Validation

npx vitest run packages/core/src/models/modelConfigResolver.test.ts
# 45 tests pass (37 original + 8 new)

Scope / risk

Zero risk. This is a behavior-preserving refactor — no logic changes, only code organization.

B-A-M-N and others added 5 commits April 25, 2026 19:53
Adds support for QWEN_CODE_API_TIMEOUT_MS as an environment override
for model generation timeout.

Qwen Code already supports timeout configuration via:
  settings.model.generationConfig.timeout

This change introduces an env-based override for users running slow
local/OpenAI-compatible backends where editing config is less convenient.

Precedence: modelProvider > env var > settings > default (120000ms)

Behavior:
- Valid positive env values override configured timeout
- Invalid values are ignored
- Default behavior remains unchanged (applied in buildClient())

Note: The 5-minute timeout reported in QwenLM#1045 originally came from
undici's default bodyTimeout, which is now disabled (bodyTimeout:0).
The modelConfigResolver default is 120000ms (2 minutes).

Includes unit tests covering precedence and validation.

Closes QwenLM#1045

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Covers: large timeout values, whitespace-padded env values,
negative env values, and reinforces provider > env > settings precedence.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds support for QWEN_CODE_API_TIMEOUT_MS as an environment
override for model generation timeout.

Closes QwenLM#13

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Extract duplicated timeout env override block into a shared helper
applyTimeoutEnvOverride(), used by both resolveModelConfig() and
resolveQwenOAuthConfig(). Preserves precedence: modelProvider > env > settings.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds [Regression] tests guarding against the original OAuth-path bug
and verifying the refactor preserves precedence across all auth types.
Also adds edge-case coverage for scientific notation, hex values, and
empty-string env values.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@B-A-M-N

B-A-M-N commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of recreating after #3629 merges to main. The current PR incorrectly includes commits from the feature branch.

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