jackwener/OpenCLI · error · CommandExecutionError
Codex model switch to "${selected}" was not verified.
Error message
Codex model switch to "${selected}" was not verified. What it means
After dispatching the menu-item click, the command polls up to 20 times (5s) re-reading the composer toolbar button and verifying via `modelSelectionVerified` that the visible text now reflects the chosen model/reasoning. This CommandExecutionError is thrown when verification never passes, meaning the click may have been swallowed, the menu selection didn't apply, or the selector text drifted so the re-read never sees the new value.
Source
Thrown at clis/codex/model.js:257
await page.wait(0.25);
const reread = unwrapEvaluateResult(await page.evaluate(`(function() {
const re = new RegExp(${patternJson});
const composers = Array.from(document.querySelectorAll('[contenteditable="true"]')).filter((el) => el.offsetParent);
const last = composers[composers.length - 1];
if (!last) return '';
let root = last;
for (let i = 0; i < 5; i++) root = root.parentElement || root;
const btns = Array.from(root.querySelectorAll('button')).filter((b) => b.offsetParent);
const match = btns.find((b) => re.test((b.textContent || '').trim()));
return match ? (match.textContent || '').trim() : '';
})()`));
if (modelSelectionVerified(reread, selected)) {
verified = reread;
break;
}
}
if (!verified) {
throw new CommandExecutionError(
`Codex model switch to "${selected}" was not verified.`,
'The model menu click may have failed or the model selector text may have drifted.',
);
}
return [{ Status: 'switched', Model: verified }];
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the command; transient click loss is the most common cause.
- After switching, verify manually with `opencli codex model` (no args) to read the active model — the switch may have applied despite failed verification.
- If it reproduces, the model selector text likely drifted in a Codex update (see the 'model selector text may have drifted' detail) — update opencli/MODEL_BTN_TEXT_RE.
- Increase the verify attempts/window in model.js if your environment is slow, and ensure no other window overlays the Codex menu during the switch.
Example fix
// before opencli codex model "gpt-5.5" // throws: switch not verified // after opencli codex model "gpt-5.5" || true opencli codex model # read active model to confirm # in automation: retry the switch up to N times before giving up
Defensive patterns
Strategy: retry
Validate before calling
// confirm the switch applied after invoking
const out = await run('opencli codex model'); // read-only
const active = parseActiveModel(out);
if (!active.toLowerCase().includes(wanted.toLowerCase())) {
throw new Error('Switch did not take effect; retry');
} Type guard
function switchVerified(activeText, chosen) {
const n = s => String(s||'').toLowerCase().replace(/\bgpt[-\s]*/g,'').replace(/\s+/g,' ').trim();
return n(activeText) === n(chosen);
} Try / catch
try {
await switchModel(name);
} catch (err) {
if (err instanceof CommandExecutionError && /was not verified/.test(err.message)) {
// click may have been swallowed — retry the switch, then read-only verify
await sleep(1000);
return switchModel(name);
}
throw err;
} Prevention
- Retry the switch once; transient click loss is common
- Follow every switch with a read-only `codex model` to confirm the active value
- Allow extra time on slow machines (5s verify window may be tight)
- Keep opencli/MODEL_BTN_TEXT_RE updated after Codex toolbar UI changes
When it happens
Trigger: Running `opencli codex model <name>` where the synthetic click on the menu item didn't register (menu intercepted the event, item disabled), the model switched but the toolbar text renders differently than expected (reasoning suffix, truncation), or the 5-second verify window expired before the UI updated.
Common situations: Codex UI updates changing the toolbar button's rendered text; slow machines where the switch takes >5s; menus requiring native trusted events that synthetic PointerEvent/MouseEvent sequences don't satisfy; the chosen option actually failed to apply (server rejected the switch).
Related errors
- ${result.reason}
- Cannot switch to ${wantModel} model inside an existing conve
- Codex ${description} was not verified for ${conversationRefF
- Codex extract-diff returned an invalid payload.
- Model name "${rawName}" is ambiguous.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7e0a10c62d919321.
Report an issue: GitHub.