fix(openai): drop legacy MMDD snapshot suffixes from picker

Codex P2 follow-up on PR #5684 (providers.py:104): the new OpenAI
denylist only stripped the modern `-YYYY-MM-DD` dated form, so
legacy compact snapshots like `gpt-3.5-turbo-0125`, `gpt-4-0613`,
`gpt-4-1106-preview`, and `gpt-4-0125-preview` slipped through. The
listing returns both the snapshot and the canonical id; the picker
should surface only the canonical so users do not accidentally
select a deprecated snapshot.

Extends the dated-suffix branch with `-\d{4}(?:-preview)?$` to
cover the compact `MMDD` form and the `-MMDD-preview` variant.
The new rule is anchored to the end of the id so canonical chat
ids whose minor version happens to be a year-like number
(`gpt-4.5`, `gpt-5.5`, `o3`) are unaffected.

Added `test_openai_legacy_compact_snapshot_suffixes_are_dropped`
to pin both sides (8 snapshot ids dropped, 7 canonical ids kept).
10 / 10 filter tests pass locally.
This commit is contained in:
Daniel Han 2026-05-23 18:33:27 +00:00
commit f5ace8824c
2 changed files with 54 additions and 1 deletions

View file

@ -100,8 +100,14 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
# Fine-tunes carry the user's tenant in the id.
r"|^ft:"
# Dated snapshot suffixes hide behind the canonical id
# which is also in the listing.
# which is also in the listing. Covers both the modern
# `-YYYY-MM-DD` dated form and the legacy compact
# 4-digit `MMDD` form (e.g. `gpt-3.5-turbo-0125`,
# `gpt-4-0613`, `gpt-4-1106-preview`) so the picker only
# surfaces the canonical id even when the listing still
# returns the snapshot copy.
r"|-\d{4}-\d{2}-\d{2}$"
r"|-\d{4}(?:-preview)?$"
),
},
"anthropic": {

View file

@ -207,6 +207,53 @@ def test_openai_legacy_instruct_completion_ids_are_dropped():
assert dropped == [], dropped
def test_openai_legacy_compact_snapshot_suffixes_are_dropped():
"""Legacy `-MMDD` snapshot suffixes (gpt-3.5-turbo-0125,
gpt-4-0613, gpt-4-1106-preview, etc.) hide behind the canonical
id which the listing also returns; surface only the canonical so
users do not pick a deprecated snapshot by accident. The
`-\\d{4}(?:-preview)?$` rule must not catch canonical ids whose
minor version happens to be a year-like number (e.g. gpt-4.5,
o3) -- those are tested as KEEP below."""
dropped = _apply(
"openai",
[
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo-0301",
"gpt-3.5-turbo-16k-0613",
"gpt-4-0613",
"gpt-4-0314",
"gpt-4-32k-0613",
"gpt-4-1106-preview",
"gpt-4-0125-preview",
],
)
assert dropped == [], dropped
# Canonical chat ids that share a digit-heavy tail must survive.
kept = _apply(
"openai",
[
"gpt-3.5-turbo",
"gpt-4o",
"gpt-4.5",
"gpt-5.5",
"gpt-5.5-mini",
"gpt-5.5-pro",
"o3",
],
)
assert set(kept) >= {
"gpt-3.5-turbo",
"gpt-4o",
"gpt-4.5",
"gpt-5.5",
"gpt-5.5-mini",
"gpt-5.5-pro",
"o3",
}, kept
def test_openai_search_preview_is_kept_search_api_is_dropped():
# Pin the search-vs-search-api distinction so a future regex tweak
# doesn't silently regress to dropping chat-with-search models.