{"record":{"id":"94b03d3feb9897fd","repo":"mastra-ai/mastra","slug":"model-this-options-model-is-not-available-av","errorCode":null,"errorMessage":"Model \"${this.options.model}\" is not available. Available models: ${ids}","messagePattern":"Model \"(.+?)\" is not available\\. Available models: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent-sdks/acp/src/connection.ts","lineNumber":308,"sourceCode":"      throw this.withStderr(error);\n    }\n  }\n\n  private async initializeSession(): Promise<void> {\n    await this.connection!.initialize(this.getInitializeRequest());\n\n    if (this.options.authMethodId) {\n      await this.connection!.authenticate({ methodId: this.options.authMethodId });\n    }\n\n    this.session = await this.connection!.newSession(this.getNewSessionRequest());\n\n    if (this.options.model) {\n      const available = this.session.models?.availableModels;\n\n      if (available && !available.some(m => m.modelId === this.options.model)) {\n        const ids = available.map(m => m.modelId).join(', ') || '(none)';\n        throw new Error(`Model \"${this.options.model}\" is not available. Available models: ${ids}`);\n      }\n\n      await this.connection!.unstable_setSessionModel({\n        sessionId: this.session.sessionId,\n        modelId: this.options.model,\n      });\n    }\n  }\n\n  private getInitializeRequest(): InitializeRequest {\n    return {\n      protocolVersion: PROTOCOL_VERSION,\n      clientCapabilities: {\n        fs: { readTextFile: true, writeTextFile: true },\n      },\n      clientInfo: {\n        name: '@mastra/acp',\n        version: '0.1.0',","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/agent-sdks/acp/src/connection.ts#L290-L326","documentation":"The version exists but its stored agentId differs from the :agentId path parameter; the handler intentionally returns the same 404 wording as the not-exists case to avoid leaking cross-agent version existence.","triggerScenarios":"GET/POST /api/agents/:agentId/versions/:versionId where versionId belongs to a different agent than the one in the path.","commonSituations":"Client state mixing an agent id from one request with a versionId from another agent's response; copy/paste across tabs; UI bugs pairing the wrong list items.","solutions":["Verify the versionId was obtained from the same agent's version list","Correct the :agentId path parameter to match version.agentId","Refresh client state so agentId and versionId come from the same fetch","Add client-side checks pairing version.agentId with the selected agent before calling"],"exampleFix":"// before\nrestoreAgentVersion(agent.id, selectedVersion.id); // selectedVersion from another agent\n// after\nif (selectedVersion.agentId === agent.id) {\n  restoreAgentVersion(agent.id, selectedVersion.id);\n}","handlingStrategy":"validation","validationCode":"const versions = await fetch(`/api/agents/${agentId}/versions`).then(r => r.json());\nconst v = versions.find(x => x.id === versionId);\nif (!v) throw new Error(`Version ${versionId} is not owned by agent ${agentId}`);","typeGuard":"function belongsToAgent(v: {agentId: string} | undefined, agentId: string): v is {agentId: string} {\n  return !!v && v.agentId === agentId;\n}","tryCatchPattern":"try {\n  await fetch(`/api/agents/${agentId}/versions/${versionId}`);\n} catch (e) {\n  if (isHttpError(e) && e.status === 404 && e.message.includes('not found for agent')) {\n    // re-pair agentId and versionId in client state\n  } else throw e;\n}","preventionTips":["Store (agentId, versionId) pairs together in client state","Never mix versionIds across agent contexts","Re-fetch both agent and version lists after agent recreation","Add UI assertions that the selected version belongs to the selected agent"],"tags":["http-404","not-found","versions","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}