Skip to content

fix(cli): gate OpenAI-only reasoning effort tiers to gpt-5 family - #13563

Open
maphew wants to merge 5 commits into
Kilo-Org:mainfrom
maphew:fix/reasoning-effort-variants-non-openai
Open

fix(cli): gate OpenAI-only reasoning effort tiers to gpt-5 family#13563
maphew wants to merge 5 commits into
Kilo-Org:mainfrom
maphew:fix/reasoning-effort-variants-non-openai

Conversation

@maphew

@maphew maphew commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #13342

What

openaiReasoningEfforts() in packages/opencode/src/provider/transform.ts handed out OpenAI's rollout-gated reasoning tiers — none (rolled out 2025-11-13) and xhigh (rolled out 2025-12-04) — to any model whose release date is new enough, regardless of whether it is actually a gpt-5-family model. Non-OpenAI models routed through @ai-sdk/openai on an OpenAI-compatible base URL (e.g. Grok via api.x.ai, the config shape the maintainer workaround in #13082 recommends) were therefore offered an xhigh variant they cannot honor, and selecting it failed with invalid xai provider options (the AI SDK's zod validation rejecting reasoning_effort: "xhigh").

Change

The gpt-5 family gate lives in a Kilo mirror (src/kilocode/provider/transform.ts) per the fork-merge policy; the shared upstream file keeps a single marked gpt5FamilyReasoningTiers(id) call and a marked import. The family check accepts bare (gpt-5.5), slash-prefixed (openai/gpt-5.6), dot-prefixed (openai.gpt-5.5, Bedrock Mantle), and hyphen-prefixed deployment ids (azure-openai--gpt-5.4, SAP AI Core) while still excluding lookalikes like gpt-50 / gpt-5o. Non-gpt-5 ids get only the widely-supported low/medium/high set — matching what the bundled @ai-sdk/xai provider already exposes for Grok.

All existing gpt-5 / o-series / azure / mantle / SAP variant expectations are preserved (the shared transform.test.ts suite passes, including the openai.gpt-5.5 Mantle case that still receives none/xhigh).

Why this scope

Scanned the issue space before picking this: #13342 is unaddressed (no PR), and a search for related reasoning-effort PRs found no intersections. The same class of mis-offering exists in openaiCompatibleReasoningEfforts() for @ai-sdk/gateway, but that path is deliberately tested to expose the full OpenAI set (Cloudflare's gateway translates reasoning_effort upstream), so it is intentionally left unchanged to avoid a behavioral regression on the gateway's contract.

Verification

  • Regression tests live in test/kilocode/provider/transform.test.ts (Kilo-owned path), failing before the fix and passing after:
    • grok-4.6 via @ai-sdk/openai with a post-cutoff release date → only low/medium/high.
    • unknown reasoning model on the OpenAI npm → only low/medium/high.
    • lookalikes gpt-50 / gpt-5o excluded.
    • openai.gpt-5.5 (Mantle) and azure-openai--gpt-5.4 (SAP) still receive none/xhigh.
  • bun test ./test/kilocode/provider/transform.test.ts → 5 pass; bun test ./test/provider/transform.test.ts → 422 pass.
  • bun run typecheck (opencode) → clean.
  • bun run script/check-opencode-annotations.ts --worktree → clean.
  • Changeset included (patch).

Note on CI

The JetBrains typecheck in the pre-push hook could not run in the sandbox (no Java 21 / SDKMAN available); it is unrelated to these opencode-only changes. test/provider/provider.test.ts shows 3 pre-existing failures (defaultModel / opencode loader resolve to the Kilo gateway kilo-auto/efficient model instead of a direct provider) that are unrelated to this diff.

maphew added 2 commits August 28, 2026 18:26
…t-variants-non-openai

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@maphew
maphew marked this pull request as ready for review August 28, 2026 21:23
@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/opencode/src/kilocode/provider/transform.ts
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/kilocode/provider/transform.test.ts
Previous Review Summaries (2 snapshots, latest commit 5f2740e)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 5f2740e)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • .changeset/grok-xhigh-effort-gate.md
  • packages/opencode/src/kilocode/provider/transform.ts
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/kilocode/provider/transform.test.ts

Previous review (commit ba4a8dc)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • .changeset/grok-xhigh-effort-gate.md
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/provider/transform.test.ts

Reviewed by grok-4.6 · Input: 182.7K · Output: 11K · Cached: 279.9K

Review guidance: REVIEW.md from base branch main

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba4a8dc686

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// kilocode_change start - like GPT5_FAMILY_RE, but also accepts a "." prefix so
// provider-prefixed ids like Bedrock Mantle's "openai.gpt-5.5" count as gpt-5
// family. Still excludes lookalikes such as "gpt-50" and "gpt-5o".
const GPT5_FAMILY_PREFIX_RE = /(?:^|\/|\.)gpt-5(?:[.-]|$)/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Extract the gate into the Kilo mirror

Move this Kilo-specific helper and behavior gate out of the shared upstream src/provider/transform.ts, with its regression tests moved from test/provider/transform.test.ts to the corresponding test/kilocode/ mirror. The package rule requires Kilo-specific logic to live under src/kilocode/ and leave only a single marked call in the upstream file, whereas this commit adds two inline blocks and 53 lines of tests to shared files, increasing recurring upstream merge conflicts.

AGENTS.md reference: packages/opencode/AGENTS.md:L76-L78

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5f2740e. The gate now lives in src/kilocode/provider/transform.ts (gpt5FamilyReasoningTiers) and the shared src/provider/transform.ts keeps only a single kilocode_change-marked call; the regression tests were moved to test/kilocode/provider/transform.test.ts.

// models routed through @ai-sdk/openai on a compatible base URL (e.g. Grok
// via api.x.ai) reject them, which surfaced as offering an unusable `xhigh`
// variant (issue #13342).
if (!GPT5_FAMILY_PREFIX_RE.test(id)) return WIDELY_SUPPORTED_EFFORTS

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize hyphen-prefixed GPT-5 deployment IDs

Extend this family check to the provider-prefixed ID forms already used by the SAP path. For example, azure-openai--gpt-5.4 reaches openaiReasoningEfforts() through the SAP adapter's id.includes("gpt") branch, but this regex rejects it because gpt-5 follows - rather than the start, /, or .; the new early return consequently removes its supported none and xhigh variants. The existing SAP tests demonstrate the same azure-openai--<model> naming form with azure-openai--o3-mini.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5f2740e. The family regex now accepts hyphen-prefixed deployment ids ((?:^|\/|\.|-)gpt-5(?:[.-]|$)), so azure-openai--gpt-5.4 through the SAP adapter keeps its none/xhigh variants. Regression coverage added for the SAP and Bedrock Mantle forms.

maphew commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both Codex review points in 5f2740e:

  • P1 (extract to Kilo mirror): moved the gpt-5 family gate (regex + helper) into src/kilocode/provider/transform.ts and reduced the shared src/provider/transform.ts change to a single marked gpt5FamilyReasoningTiers(id) call plus the marked import. Regression tests moved out of the shared test/provider/transform.test.ts into test/kilocode/provider/transform.test.ts, so the shared file returns to its upstream shape (the diff there is now a pure deletion of the previously-inlined Kilo tests).
  • P2 (hyphen-prefixed deployment ids): GPT5_FAMILY_PREFIX_RE now also accepts a - prefix boundary, so SAP AI Core deployment ids like azure-openai--gpt-5.4 still receive their none/xhigh tiers instead of being collapsed to low/medium/high. Added a regression test for that exact id form.

Verification: test/kilocode/provider/transform.test.ts (5 tests) and the shared test/provider/transform.test.ts (422 tests) pass; opencode typecheck and check-opencode-annotations.ts --worktree are clean.

maphew commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T03:41:34.664542Z 5f2740e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

maphew commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Merge-readiness check complete:

  • Both Codex review findings addressed (gate extracted to src/kilocode/provider/transform.ts in 5f2740e; hyphen-prefixed deployment ids covered).
  • Branch synced with main (0 behind), no merge conflicts.
  • CI green (all checks pass); fresh Codex review re-triggered.
  • Typecheck + regression tests verified locally.

Ready for human review.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f2740eddc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1,23 @@
// kilocode_change - new file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the marker from the Kilo-owned file

This file is already under src/kilocode/, but its first line marks it as shared upstream code. The repository rule explicitly prohibits kilocode_change markers in directories whose names contain kilo; retaining it misclassifies this Kilo-owned mirror for future upstream-conflict work.

AGENTS.md reference: AGENTS.md:L189-L190

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in b93b74d: the // kilocode_change - new file marker was removed from src/kilocode/provider/transform.ts since the file lives in a kilo-owned directory and needs no marker.

// kilocode_change start - `none`/`xhigh` are OpenAI rollout tiers only gpt-5-family
// models accept; non-OpenAI models on an OpenAI-compatible base URL (e.g. Grok
// via api.x.ai) reject them (issue #13342). See gpt5FamilyReasoningTiers.
if (!gpt5FamilyReasoningTiers(id)) return WIDELY_SUPPORTED_EFFORTS

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve rollout tiers for opaque Azure deployment IDs

When a native Azure GPT-5.2+ custom model uses an opaque deployment name such as production and has a post-cutoff release_date, this check sees only model.api.id (the deployment name) and now returns low/medium/high, removing supported none and xhigh variants that the previous release-date logic exposed. This is a supported configuration shape: packages/kilo-docs/pages/code-with-ai/agents/custom-models.md documents that the config model key identifies GPT-5 while id is the independently named Azure deployment, and provider.ts stores that deployment in api.id; the gate therefore needs access to the model key/family rather than relying exclusively on the transport ID.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in b93b74d: openaiReasoningEfforts now takes isFirstPartyOpenAI, set for the native @ai-sdk/azure path, which serves only first-party OpenAI models. Opaque deployment/model keys (e.g. production) there keep their none/xhigh rollout tiers while non-OpenAI models on OpenAI-compatible base URLs remain gated. Regression tests added for both the opaque-deployment and the documented model-key/deployment-id shapes.

maphew commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: the Codex re-review findings were addressed in b93b74d (removed stray marker from the kilo-owned file; native Azure now passes isFirstPartyOpenAI so opaque deployment/model keys keep none/xhigh). CI is green again and no new findings from the re-review. Still blocked only on a human approval.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
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.

[VS Code] Grok 4.6 with xhigh reasoning returns "invalid xai provider options"

1 participant