{"record":{"id":"b6a619b86859d827","repo":"deepseek-ai/deepseek-harness","slug":"session-selectmodel-failed-result-error-code","errorCode":null,"errorMessage":"session.selectModel failed: ${result.error.code}: ${result.error.message}","messagePattern":"session\\.selectModel failed: (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/client/ui-model-selection/src/client/directory.ts","lineNumber":112,"sourceCode":"  async select(selection: ModelSelection): Promise<void> {\n    this.assertAvailable()\n    const generation = ++this.generation\n    this.store.update((s) => { s.status = 'selecting'; s.error = null })\n    const { result } = await this.sessions.selectModel({\n      sessionId: this.sessionId,\n      provider: selection.provider,\n      model: selection.model,\n      ...selection.reasoningEffort === undefined\n        ? {}\n        : { reasoningEffort: selection.reasoningEffort },\n    })\n    if (this.disposed || generation !== this.generation) {\n      if (!result.ok) throw new Error(`${result.error.code}: ${result.error.message}`)\n      return\n    }\n    if (!result.ok) {\n      this.store.update((s) => { s.status = 'error'; s.error = `${result.error.code}: ${result.error.message}` })\n      throw new Error(`session.selectModel failed: ${result.error.code}: ${result.error.message}`)\n    }\n    // The Host validated the route before accepting it, so a selection that\n    // landed is by construction one it can serve.\n    this.store.update((s) => {\n      s.current = result.value.selected\n      s.routable = true\n      s.status = 'ready'\n      s.error = null\n    })\n  }\n\n  /**\n   * Drop the previous Host generation's projection and repull it. Clearing\n   * first prevents an unconsumed process-local selection from being displayed\n   * while the restarted Host has restored the last logged model selection.\n   */\n  resetConnected(): void {\n    if (this.disposed) return","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/client/ui-model-selection/src/client/directory.ts#L94-L130","documentation":"ModelDirectory.select() applies a chosen route via session.selectModel. On refusal it stores status:'error' with the code/message and throws 'session.selectModel failed: <code>: <message>'; a select superseded by a newer generation or a disposed directory throws only the raw code/message. The host validates routes before accepting, so a selection that landed is by construction servable.","triggerScenarios":"Choosing a model (via apply, choose, or chooseEffort) when the host rejects the route: the model stopped being routable since the last catalog load, the provider is down, or the session is gone.","commonSituations":"Stale picker options after the provider changed its catalog mid-session; selecting during a provider outage.","solutions":["Reload the catalog (load/refresh) and pick from the fresh groups — the old option may no longer exist","Check store status/error for the host's refusal code","Retry once the provider is reachable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const snap = directory.store.getSnapshot()\nif (!snap.routable || snap.status === 'error') {\n  await directory.load() // options are stale; make the user re-pick\n  return\n}","typeGuard":null,"tryCatchPattern":"try {\n  await directory.select(selection)\n} catch {\n  await directory.load() // options may be stale; re-pick from fresh groups\n  throw new UserRetryError('re-pick a model from the refreshed list')\n}","preventionTips":["Reload the catalog before showing the picker after reconnects","Disable options whose selection failed until the catalog refreshes"],"tags":["rpc","models","route-selection","provider"],"backgroundTag":"rpc-request-failed","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}