Skip to content

Commit 5afa6f9

Browse files
committed
fix(config): resolve provider-prefixed model variants and release v5.1.1
1 parent 02136d6 commit 5afa6f9

5 files changed

Lines changed: 119 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
all notable changes to this project. dates are ISO format (YYYY-MM-DD).
44

5+
## [5.1.1] - 2026-02-08
6+
7+
### fixed
8+
9+
- **provider-prefixed model config resolution**: `openai/<model>` ids now correctly resolve to their base model config instead of falling back to global defaults.
10+
- **codex variant option merging**: variant suffixes like `-xhigh` now apply `models.<base>.variants.<variant>` options during request transformation.
11+
512
## [5.1.0] - 2026-02-08
613

714
### changed

lib/request/request-transformer.ts

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,84 @@ export function getModelConfig(
138138
modelName: string,
139139
userConfig: UserConfig = { global: {}, models: {} },
140140
): ConfigOptions {
141-
const globalOptions = userConfig.global || {};
142-
const modelOptions = userConfig.models?.[modelName]?.options || {};
141+
const globalOptions = userConfig.global ?? {};
142+
const modelMap = userConfig.models ?? {};
143+
144+
const stripProviderPrefix = (name: string): string =>
145+
name.includes("/") ? (name.split("/").pop() ?? name) : name;
146+
147+
const getVariantFromModelName = (
148+
name: string,
149+
): ConfigOptions["reasoningEffort"] | undefined => {
150+
const stripped = stripProviderPrefix(name).toLowerCase();
151+
const match = stripped.match(/-(none|minimal|low|medium|high|xhigh)$/);
152+
if (!match) return undefined;
153+
const variant = match[1];
154+
if (
155+
variant === "none" ||
156+
variant === "minimal" ||
157+
variant === "low" ||
158+
variant === "medium" ||
159+
variant === "high" ||
160+
variant === "xhigh"
161+
) {
162+
return variant;
163+
}
164+
return undefined;
165+
};
166+
167+
const removeVariantSuffix = (name: string): string =>
168+
stripProviderPrefix(name).replace(/-(none|minimal|low|medium|high|xhigh)$/i, "");
169+
170+
const findModelEntry = (
171+
candidates: string[],
172+
):
173+
| {
174+
key: string;
175+
entry: UserConfig["models"][string];
176+
}
177+
| undefined => {
178+
for (const key of candidates) {
179+
const entry = modelMap[key];
180+
if (entry) return { key, entry };
181+
}
182+
return undefined;
183+
};
184+
185+
const strippedModelName = stripProviderPrefix(modelName);
186+
const normalizedModelName = normalizeModel(strippedModelName);
187+
const normalizedBaseModelName = normalizeModel(removeVariantSuffix(strippedModelName));
188+
const baseModelName = removeVariantSuffix(strippedModelName);
189+
const requestedVariant = getVariantFromModelName(strippedModelName);
190+
191+
// 1) Honor exact per-model keys first (including variant-specific keys)
192+
const directMatch = findModelEntry([modelName, strippedModelName]);
193+
if (directMatch?.entry?.options) {
194+
return { ...globalOptions, ...directMatch.entry.options };
195+
}
196+
197+
// 2) Resolve to base model config (supports provider-prefixed names + aliases)
198+
const baseMatch = findModelEntry([
199+
baseModelName,
200+
normalizedBaseModelName,
201+
normalizedModelName,
202+
]);
203+
const baseOptions = baseMatch?.entry?.options ?? {};
204+
205+
// 3) If model requested a variant, merge variant options from base model config
206+
const variantConfig =
207+
requestedVariant && baseMatch?.entry?.variants
208+
? baseMatch.entry.variants[requestedVariant]
209+
: undefined;
210+
let variantOptions: ConfigOptions = {};
211+
if (variantConfig) {
212+
const { disabled: _disabled, ...rest } = variantConfig;
213+
void _disabled;
214+
variantOptions = rest;
215+
}
143216

144217
// Model-specific options override global options
145-
return { ...globalOptions, ...modelOptions };
218+
return { ...globalOptions, ...baseOptions, ...variantOptions };
146219
}
147220

148221
/**

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oc-chatgpt-multi-auth",
3-
"version": "5.1.0",
3+
"version": "5.1.1",
44
"description": "Multi-account rotation plugin for ChatGPT Plus/Pro (OAuth / Codex backend)",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

test/request-transformer.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,39 @@ describe('Request Transformer Module', () => {
161161
expect(result.textVerbosity).toBe('low');
162162
});
163163

164+
it('should resolve provider-prefixed model ids to base model config', async () => {
165+
const userConfig: UserConfig = {
166+
global: { reasoningEffort: 'medium' },
167+
models: {
168+
'gpt-5.2-codex': {
169+
options: { reasoningEffort: 'xhigh', reasoningSummary: 'detailed' },
170+
},
171+
},
172+
};
173+
174+
const result = getModelConfig('openai/gpt-5.2-codex', userConfig);
175+
expect(result.reasoningEffort).toBe('xhigh');
176+
expect(result.reasoningSummary).toBe('detailed');
177+
});
178+
179+
it('should apply variants from modern base-model config when variant suffix is used', async () => {
180+
const userConfig: UserConfig = {
181+
global: { reasoningEffort: 'medium', reasoningSummary: 'auto' },
182+
models: {
183+
'gpt-5.2-codex': {
184+
options: { reasoningSummary: 'auto' },
185+
variants: {
186+
xhigh: { reasoningEffort: 'xhigh', reasoningSummary: 'detailed' },
187+
},
188+
},
189+
},
190+
};
191+
192+
const result = getModelConfig('openai/gpt-5.2-codex-xhigh', userConfig);
193+
expect(result.reasoningEffort).toBe('xhigh');
194+
expect(result.reasoningSummary).toBe('detailed');
195+
});
196+
164197
it('should merge global and per-model options (per-model wins)', async () => {
165198
const userConfig: UserConfig = {
166199
global: {

0 commit comments

Comments
 (0)