{"record":{"id":"e8085c7177eade81","repo":"jackwener/OpenCLI","slug":"trae-cn-model-switch-did-not-verify-the-requested","errorCode":null,"errorMessage":"Trae CN model switch did not verify the requested model: requested \"${wanted}\", current \"${selectedLabel || 'unknown'}\"","messagePattern":"Trae CN model switch did not verify the requested model: requested \"(.+?)\", current \"(.+?)\"","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-cn/utils.js","lineNumber":739,"sourceCode":"    ? []\n    : models.filter((item) => normalizeModelLabel(item.Model).includes(wantedKey));\n  if (!exactMatch && containsMatches.length > 1) {\n    throw new ArgumentError(\n      `Model \"${wanted}\" is ambiguous in Trae CN model menu: ${containsMatches.map(item => item.Model).join(', ')}`,\n    );\n  }\n  const match = exactMatch || containsMatches[0];\n  if (!match) {\n    throw new ArgumentError(`Model \"${wanted}\" not found in Trae CN model menu`);\n  }\n  await page.click(TRAE_CN_MODEL_ITEM_SELECTOR, { nth: match.Index });\n  await page.wait(0.8);\n  const info = await page.evaluate(inspectTraeShellScript());\n  const selectedLabel = info.model || '';\n  const selectedKey = normalizeModelLabel(selectedLabel);\n  const matchKey = normalizeModelLabel(match.Model);\n  if (!selectedKey || (selectedKey !== matchKey && selectedKey !== wantedKey)) {\n    throw new CommandExecutionError(\n      `Trae CN model switch did not verify the requested model: requested \"${wanted}\", current \"${selectedLabel || 'unknown'}\"`,\n      'Open the Trae CN model menu and verify the requested model is selectable, then retry.',\n    );\n  }\n  return {\n    requested: wanted,\n    selected: selectedLabel,\n    workspace: info.workspace || '',\n    agent: info.agent || '',\n  };\n}\n","sourceCodeStart":721,"sourceCodeEnd":751,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-cn/utils.js#L721-L751","documentation":"After clicking the model item, selectTraeModel re-inspects the shell and compares the now-selected model label to the requested/expected normalized keys. If the UI still shows a different (or unknown) model, it throws this CommandExecutionError, meaning the click did not result in the desired selection.","triggerScenarios":"Click landing on the wrong row after menu re-render (index drift), animation covering the item, the menu closing without selection, or the selected model label not yet updated when inspected after the 0.8s wait.","commonSituations":"Slow machines where 0.8s is not enough, Trae CN updates changing menu item ordering, or models whose displayed label differs from the menu label.","solutions":["Retry the selection; transient UI timing often succeeds on a second attempt","Increase the wait after clicking before verification","Select by a more specific/unique model name to reduce index ambiguity","Verify manually in Trae CN that the model is selectable"],"exampleFix":"// before\nawait page.click(TRAE_CN_MODEL_ITEM_SELECTOR, { nth: match.Index });\nawait page.wait(0.8);\n// after\nawait page.click(TRAE_CN_MODEL_ITEM_SELECTOR, { nth: match.Index });\nawait page.wait(2.0);","handlingStrategy":"retry","validationCode":"const info = await page.evaluate(inspectTraeShellScript());\nif (info?.menuOpen) throw new SkipError('model menu still open; settle before verifying');","typeGuard":"const isModelVerified = (info, wanted, match) => {\n  const sel = normalizeModelLabel(info?.model || '');\n  return !!sel && (sel === normalizeModelLabel(match.Model) || sel === normalizeModelLabel(wanted));\n};","tryCatchPattern":"try { await selectTraeModel(page, name); } catch (e) { if (e instanceof CommandExecutionError && /did not verify/.test(e.message)) { await page.wait(1.5); return selectTraeModel(page, name); } throw e; }","preventionTips":["Allow extra settle time after clicking before verification","Retry once on verification failure (timing is a common cause)","Prefer exact model names so the clicked row is unambiguous"],"tags":["automation","ui-verification","timing"],"backgroundTag":"automation-verification-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}