Skip to content

fix(ai): make normalizeOpenAIReasoningEffort case-insensitive - #103169

Closed
drvoss wants to merge 1 commit into
openclaw:mainfrom
drvoss:fix/openai-reasoning-effort-case-insensitive
Closed

drvoss wants to merge 1 commit into
openclaw:mainfrom
drvoss:fix/openai-reasoning-effort-case-insensitive

Conversation

@drvoss

@drvoss drvoss commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

normalizeOpenAIReasoningEffort in packages/ai/src/providers/openai-reasoning-effort.ts did not lowercase or trim its input. Mixed-case or uppercase reasoning-effort values (e.g. "HIGH") failed to match the lowercase supported-effort lists used throughout resolveOpenAIReasoningEffortForModel, so requests could silently resolve to the wrong effort or fall back unexpectedly.

Why This Change Was Made

Reuse the existing normalizeLowercaseStringOrEmpty helper (already imported in this file from @openclaw/normalization-core/string-coerce) to trim and lowercase the effort value consistently, falling back to the original value only when the input is not string-like. This keeps the fix small and consistent with existing normalization conventions in the codebase.

User Impact

Callers that pass a mixed-case reasoningEffort (for example via CLI flags, config, or upstream integrations that don't normalize case) will now correctly match the supported-effort lists and fallback maps instead of silently mismatching.

Evidence

  • Added regression tests in packages/ai/src/providers/openai-reasoning-effort.test.ts covering direct normalization ("HIGH" -> "high", "Medium" -> "medium", "mInImAl" -> "minimal") and end-to-end resolution via resolveOpenAIReasoningEffortForModel.
  • Ran node scripts/run-vitest.mjs packages/ai/src/providers/openai-reasoning-effort.test.ts — all 12 tests pass (10 existing + 2 new).
  • Verified all current compat.supportedReasoningEfforts / reasoningEffortMap usages across extensions/, docs/, and src/ use lowercase strings exclusively, so lowercasing the fallback-mapped value carries no regression risk in the current codebase.

Closes #102908

Mixed-case or uppercase reasoning effort values (e.g. "HIGH") failed to
match the lowercase supported-effort lists in
resolveOpenAIReasoningEffortForModel, so requests silently resolved to the
wrong effort or fell back unexpectedly. Reuse the existing
normalizeLowercaseStringOrEmpty helper to trim/lowercase input consistently.

Closes openclaw#102908

Co-authored-by: Copilot <[email protected]>
yplongapp added a commit to yplongapp/openclaw that referenced this pull request Jul 10, 2026
normalizeOpenAIReasoningEffort previously only handled the literal
"minimal" effort value, passing everything else through unchanged.
Mixed-case inputs such as "HIGH", "Max", or "Medium" failed to
match the lowercase supported-effort lists, causing requests to
silently resolve to the wrong effort or fall back unexpectedly.

Use the existing normalizeLowercaseStringOrEmpty helper (already
imported) to trim and lowercase the effort value consistently.

Also add coverage for case-insensitive normalization, whitespace
trimming, and end-to-end model pipeline resolution with mixed-case
values.

Closes openclaw#103169
@steipete

Copy link
Copy Markdown
Contributor

Closing as superseded by #102993, landed on main as 4c4609d.

The landed implementation fixes canonical mixed-case input without lowercasing every provider-native compat value. It preserves exact mapped output casing, requires explicit maps for canonical-looking provider labels, covers both Responses and Chat Completions callers, and passed exact-head CI plus focused provider/transport proof.

Thanks @drvoss for the report and alternative patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

case-insensitive reasoning effort matching in resolveOpenAIReasoningEffortForModel

2 participants