-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(catalog): suppress synthetic max per model while retaining ultra #5036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -226,18 +226,20 @@ export function applyReasoningLevels( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| effortsOverride?: string[], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultOverride?: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| preserveExact = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suppressSyntheticMax = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): void { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let efforts = sanitizeCodexReasoningEfforts(effortsOverride) ?? ROUTED_REASONING_LEVELS.map(l => l.effort); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Mock top tiers (user decision 260709): every reasoning-capable model advertises `max` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // even when the provider ladder stops lower — subagent spawns pass `max` DIRECTLY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Mock top tiers (user decision 260709): reasoning-capable routed models advertise `max` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // even when the provider ladder stops lower, unless the model opts out of that synthesis. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Subagent spawns pass `max` DIRECTLY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // (no ultra->max client conversion) and codex-rs validates it by catalog membership, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // so a missing max rung hard-fails spawn_agent effort overrides. The wire stays honest: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // routed adapters clamp via clampToSupportedCodexEffort and natives via | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // nativeEffortClamp (max -> the model's real top rung). A `none`-only ladder is NOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // reasoning-capable, so it must not grow synthetic top rungs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!preserveExact && efforts.length > 0 && efforts.some(effort => effort !== "none" && effort !== "minimal")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const additions: string[] = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!efforts.includes("max")) additions.push("max"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!suppressSyntheticMax && !efforts.includes("max")) additions.push("max"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
231
to
+242
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '200,285p' src/codex/catalog/effort.ts
rg -n 'ROUTED_REASONING_LEVELS|applyReasoningLevels\(' src/codex/catalog tests/codex-integration/codex-catalog-ladders.test.ts
sed -n '130,230p' src/codex/catalog/derive-entry.ts
sed -n '90,135p' tests/codex-integration/codex-catalog-ladders.test.tsRepository: lidge-jun/opencodex Length of output: 12820 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- applyReasoningLevels callers and surrounding derivation ---'
sed -n '1,245p' src/codex/catalog/derive-entry.ts
printf '%s\n' '--- suppressSyntheticMax definitions and assignments ---'
rg -n -C 5 'suppressSyntheticMax|reasoningEfforts|catalogKind|custom|discovery' src/codex/catalog tests/codex-integration/codex-catalog-ladders.test.ts
printf '%s\n' '--- relevant test remainder ---'
sed -n '1,180p' tests/codex-integration/codex-catalog-ladders.test.tsRepository: lidge-jun/opencodex Length of output: 50376 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- exact suppression assignments and model type ---'
rg -n -C 8 'suppressSyntheticMax' src tests
printf '%s\n' '--- custom row materialization ---'
sed -n '580,690p' src/codex/catalog/routed-gather.ts
printf '%s\n' '--- provider discovery model construction around reasoning fields ---'
rg -n -C 12 'reasoningEfforts:|suppressSyntheticMax:' src/codex/catalog/routed-gather.ts src/providers src/adaptersRepository: lidge-jun/opencodex Length of output: 50376 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- model hint functions ---'
sed -n '250,340p' src/codex/catalog/model-hints.ts
sed -n '380,435p' src/codex/catalog/model-hints.ts
printf '%s\n' '--- routed gather model flow ---'
sed -n '690,850p' src/codex/catalog/routed-gather.ts
printf '%s\n' '--- CatalogModel and custom configuration fields ---'
sed -n '70,135p' src/codex/catalog/parsing.ts
rg -n -C 5 'interface .*Custom|customModels|modelSuppressSyntheticMax' src/types.ts src/config src/codex/catalog | head -220Repository: lidge-jun/opencodex Length of output: 33317 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- hint callers ---'
rg -n -C 8 'hintsForModel\(|applyProviderConfigHints\(|applyConfigHintsToCachedModels\(' src
printf '%s\n' '--- custom model schema/type ---'
rg -n -C 8 'customModels|modelId' src/config/schema src/types.ts | head -240Repository: lidge-jun/opencodex Length of output: 38230 Remove Configured-only and degraded discovery rows can receive Remove Proposed fix- let efforts = sanitizeCodexReasoningEfforts(effortsOverride) ?? ROUTED_REASONING_LEVELS.map(l => l.effort);
+ const declaredEfforts = sanitizeCodexReasoningEfforts(effortsOverride);
+ let efforts = declaredEfforts ?? ROUTED_REASONING_LEVELS.map(l => l.effort);
+ if (suppressSyntheticMax && declaredEfforts === undefined) {
+ efforts = efforts.filter(effort => effort !== "max");
+ }📝 Committable suggestion
Suggested change
🧰 Tools🪛 ast-grep (0.45.3)[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec. (detect-child-process-typescript) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!efforts.includes("ultra")) additions.push("ultra"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (additions.length > 0) efforts = sanitizeCodexReasoningEfforts([...efforts, ...additions]) ?? efforts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -258,9 +260,11 @@ export function applyReasoningLevels( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entry.default_reasoning_level = defaultOverride && efforts.includes(defaultOverride) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? defaultOverride | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : efforts.includes("medium") ? "medium" : efforts.includes("high") ? "high" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Sentinels never become the implicit default when real rungs are declared. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : efforts.find(effort => effort !== "none" && effort !== "minimal") ?? efforts[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : suppressSyntheticMax && defaultOverride === "max" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? clampedDefaultEffort(defaultOverride, efforts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : efforts.includes("medium") ? "medium" : efforts.includes("high") ? "high" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Sentinels never become the implicit default when real rungs are declared. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : efforts.find(effort => effort !== "none" && effort !== "minimal") ?? efforts[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,6 +296,7 @@ export function applyProviderConfigHints( | |
| inputModalities = base.includes("image") ? [...base] : [...base, "image"]; | ||
| } | ||
| const reasoningEfforts = configuredReasoningEfforts(prov, model.id); | ||
| const suppressSyntheticMax = modelRecordValue(prov.modelSuppressSyntheticMax, model.id) === true; | ||
| const defaultReasoningEffort = modelRecordValue(prov.modelDefaultReasoningEfforts, model.id) ?? model.defaultReasoningEffort; | ||
| const supportsReasoningSummaries = configuredReasoningSummarySupport(prov, model.id); | ||
| const supportsVerbosity = configuredVerbositySupport(name, prov, model.id); | ||
|
|
@@ -305,6 +306,7 @@ export function applyProviderConfigHints( | |
| supportsServiceTier: _staleServiceTier, | ||
| fastTierDescription: _staleFastTierDescription, | ||
| providerAlias: _staleProviderAlias, | ||
| suppressSyntheticMax: _staleSuppressSyntheticMax, | ||
| ...modelWithoutServiceTier | ||
| } = model; | ||
| // 已发现窗口只允许被配置值压低;缺窗口时,已开的 Context cap 就是实际窗口。 | ||
|
|
@@ -321,6 +323,7 @@ export function applyProviderConfigHints( | |
| ...(hintedWindow !== undefined ? { contextWindow: hintedWindow } : {}), | ||
| ...(inputModalities ? { inputModalities } : {}), | ||
| ...(reasoningEfforts !== undefined ? { reasoningEfforts } : {}), | ||
| ...(suppressSyntheticMax ? { suppressSyntheticMax: true } : {}), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the same provider/model is also declared in AGENTS.md reference: src/AGENTS.md:L18-L18 Useful? React with 👍 / 👎. |
||
| ...(configuredMaxInput !== undefined | ||
| ? { | ||
| maxInputTokens: typeof model.maxInputTokens === "number" && model.maxInputTokens > 0 | ||
|
|
@@ -394,6 +397,31 @@ export function applyConfigHintsToCachedModels( | |
| ): CatalogModel[] { | ||
| return models.map(model => applyProviderConfigHints(name, prov, model, contextCap, metadataModelIdCaseFold, effectiveAlias)); | ||
| } | ||
|
|
||
| /** Catalog slugs whose configured model must not gain a missing synthetic max rung. */ | ||
| export function suppressedSyntheticMaxCatalogSlugs( | ||
| config: Pick<OcxConfig, "providers">, | ||
| models: readonly CatalogModel[], | ||
| observedEntries: readonly { slug?: unknown }[] = [], | ||
| ): ReadonlySet<string> { | ||
| const slugs = new Set(models | ||
| .filter(model => model.suppressSyntheticMax === true) | ||
| .map(catalogModelSlug)); | ||
| for (const [provider, providerConfig] of Object.entries(config.providers)) { | ||
| const configured = providerConfig.modelSuppressSyntheticMax ?? {}; | ||
| const encoded = Object.fromEntries(Object.entries(configured) | ||
| .map(([modelId, suppress]) => [routedSlug(provider, modelId).slice(provider.length + 1), suppress])); | ||
| for (const [modelId, suppress] of Object.entries(configured)) { | ||
| if (suppress === true) slugs.add(routedSlug(provider, modelId)); | ||
| } | ||
| for (const entry of observedEntries) { | ||
| const slug = typeof entry.slug === "string" ? entry.slug : ""; | ||
| if (!slug.startsWith(`${provider}/`)) continue; | ||
| if (modelRecordValue(encoded, slug.slice(provider.length + 1)) === true) slugs.add(slug); | ||
| } | ||
| } | ||
| return slugs; | ||
| } | ||
| export const QUIET_AUTHORITATIVE_CATALOG_PROVIDERS = new Set(["kimi", "xai"]); | ||
|
|
||
| export const CALLABLE_CONFIGURED_COMPATIBILITY_MODELS: Readonly<Record<string, ReadonlySet<string>>> = { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 12151
Run the required validation. Run the focused test-layout tests and
bun run typecheck. This file is a static layout map consumed by test-layout tooling, not a script that handles configuration, credentials, requests, logs, or account data, sobun run privacy:scanis not required.bun run prepushis not required for this change.🤖 Prompt for AI Agents