Skip to content

fix(providers): migrate stale Alibaba context windows - #588

Open
luvs01 wants to merge 3 commits into
devfrom
codex/fix-alibaba-context-correction-migration
Open

luvs01 wants to merge 3 commits into
devfrom
codex/fix-alibaba-context-correction-migration

Conversation

@luvs01

@luvs01 luvs01 commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The registry was corrected to report qwen3.8-max as 1,000,000 tokens, but existing persisted Alibaba Token Plan provider rows could still contain the old 983,616 value and remain unchanged by enrichment, causing underreported context windows for upgraded installs.

Description

  • Add two exact-value startup migrations to src/providers/stale-context-window-migration.ts that replace qwen3.8-max === 983,616 with 1_000_000 for both alibaba-token-plan and alibaba-token-plan-intl while preserving operator-chosen values and only touching rows that still match the registry adapter.
  • Extend tests/providers/context-window-seed-repair.test.ts with focused coverage that asserts both Alibaba variants are repaired by the migration and that operator overrides remain untouched.
  • Update structure/providers-and-adapters.md to document that the startup pass runs an exact-value repair for known-bad registry seeds (including the Alibaba qwen3.8-max former value) and to explain the migration contract.
  • Clarify the migration header comment to reflect the Alibaba gateway probe provenance for this correction.

Testing

  • Ran the focused migration unit tests with bun test tests/providers/context-window-seed-repair.test.ts, which passed (all cases green).
  • Ran repository checks bun run structure:check and bun run typecheck, both of which succeeded.
  • Started the full test suite (bun run test) to exercise review-ready gates; the focused changes remained green but the full run revealed unrelated failures in WebSocket relay, API-key attribution, and Cursor bearer-admission tests, so the PR contains only the minimal focused migration and its tests rather than attempting to address those unrelated failures.

Codex Task


Devin Review

devin-ai-integration Bot and others added 2 commits September 20, 2026 13:22
…forwarded role (lidge-jun#5334 follow-up)

lidge-jun#5334 made the developer wire role tri-state: an undeclared destination folds
it to system. Two suites asserting role:"developer" on the Chat wire were
missed because they are about tool-result repair ordering and document parts,
not role selection — declare the destination, per the convention the change
established.

Verified: both files fail on dev@600075d2 with system-for-developer wire roles
and pass with the declaration.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 5f316153-0dcd-4c53-a924-c4c35bfb256a


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 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-09-21T00:52:34.049423Z bd5a0e8 PR opened
ℹ️ 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.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 21, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

The migration's provider guard checked only the adapter, so a saved row repointed at a custom gateway but still carrying the generic openai-chat adapter had its context window overwritten with the registry's corrected value. Require the configured baseUrl to match the registry endpoint or a declared baseUrlChoices entry, the same ownership rule model-rename-migration applies.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
@devin-ai-integration

Copy link
Copy Markdown

Fixed in f9ef2af: providerStillMatchesRegistry now also requires the saved baseUrl to match the registry endpoint or a declared baseUrlChoices entry (same ownership rule as model-rename-migration), so a repointed alibaba-token-plan(-intl) row keeps its own window figures. Added regression tests covering the custom-gateway skip plus the trailing-slash and declared-choice endpoints that still repair.

@devin-ai-integration

Copy link
Copy Markdown

Fixed in f9ef2af: the provider guard now takes the full row and requires the configured baseUrl to match the registry endpoint or one of baseUrlChoices (trailing-slash normalized), mirroring the model-rename migration's ownership rule. Rows repointed to a custom gateway are skipped, with a regression test for both Alibaba ids.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 new potential issue.

Devin Review

Comment on lines +73 to +76
const known = [entry.baseUrl, ...choices]
.filter((url): url is string => typeof url === "string")
.map(url => url.replace(/\/+$/, ""));
return known.includes(prov.baseUrl.replace(/\/+$/, ""));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Equivalent registry URLs can prevent the context-window repair

An official endpoint with whitespace or URL-equivalent casing fails this string comparison because normalization removes only trailing slashes. Valid saved rows then retain stale context windows.

Learn more

Provider baseUrl validation parses baseUrl.trim(), so surrounding whitespace and URL casing remain valid configuration. URL schemes and hostnames are case-insensitive, but this comparison treats them as ordinary case-sensitive text after removing only trailing slashes. The repository already has URL-aware endpoint normalization in normalizedProviderEndpoint, although it is currently private.

Example: A saved Alibaba row using HTTPS://TOKEN-PLAN.CN-BEIJING.MAAS.ALIYUNCS.COM/compatible-mode/v1/ still targets the registry host. This check rejects it, so qwen3.8-max remains at 983,616 instead of becoming 1,000,000.

Recommended fix: Reuse or extract the URL-aware normalization used by normalizedProviderEndpoint, and apply it to both registry choices and the configured URL. Add focused coverage for surrounding whitespace and scheme/host casing without lowercasing case-sensitive path components.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

This branch has not been deployed

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

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant