fix(ai): restore Codex context limits

This commit is contained in:
Armin Ronacher
2026-06-13 11:02:38 +02:00
parent 032c01c1e1
commit aa3a5233ad
4 changed files with 86 additions and 98 deletions

View File

@@ -1367,7 +1367,7 @@ async function generateModels() {
candidate.maxTokens = 128000;
}
if (candidate.provider === "openai" && (candidate.id === "gpt-5.4" || candidate.id === "gpt-5.5")) {
candidate.contextWindow = 1050000;
candidate.contextWindow = 272000;
candidate.maxTokens = 128000;
}
// models.dev reports gpt-5-pro output as 272000 (a duplicate of the input sub-limit);
@@ -1634,7 +1634,7 @@ async function generateModels() {
cacheRead: 0.25,
cacheWrite: 0,
},
contextWindow: 1050000,
contextWindow: 272000,
maxTokens: 128000,
});
}
@@ -1761,9 +1761,9 @@ async function generateModels() {
// OpenAI Codex (ChatGPT OAuth) models
// NOTE: These are not fetched from models.dev; we keep a small, explicit list to avoid aliases.
// Context window is based on observed server limits (400s above ~272k), not marketing numbers.
const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
const CODEX_GPT_54_CONTEXT = 1000000;
const CODEX_STANDARD_CONTEXT = 400000;
const CODEX_CONTEXT = 272000;
const CODEX_SPARK_CONTEXT = 128000;
const CODEX_MAX_TOKENS = 128000;
const codexModels: Model<"openai-codex-responses">[] = [
@@ -1788,7 +1788,7 @@ async function generateModels() {
reasoning: true,
input: ["text", "image"],
cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0 },
contextWindow: CODEX_GPT_54_CONTEXT,
contextWindow: CODEX_CONTEXT,
maxTokens: CODEX_MAX_TOKENS,
},
{
@@ -1800,7 +1800,7 @@ async function generateModels() {
reasoning: true,
input: ["text", "image"],
cost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 },
contextWindow: CODEX_STANDARD_CONTEXT,
contextWindow: CODEX_CONTEXT,
maxTokens: CODEX_MAX_TOKENS,
},
{
@@ -1812,7 +1812,7 @@ async function generateModels() {
reasoning: true,
input: ["text", "image"],
cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 },
contextWindow: CODEX_STANDARD_CONTEXT,
contextWindow: CODEX_CONTEXT,
maxTokens: CODEX_MAX_TOKENS,
},
];