{"record":{"id":"6970e2535b8a48b3","repo":"mastra-ai/mastra","slug":"model-modelid-is-not-available-available-mod","errorCode":null,"errorMessage":"Model \"${modelId}\" 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":128,"sourceCode":"  }\n\n  get sessionId(): string | undefined {\n    return this.session?.sessionId;\n  }\n\n  async getAvailableModels(): Promise<ModelInfo[]> {\n    await this.ensureConnected();\n    return this.session?.models?.availableModels ?? [];\n  }\n\n  async setModel(modelId: string): Promise<void> {\n    await this.ensureConnected();\n\n    const available = this.session?.models?.availableModels;\n\n    if (available && !available.some(m => m.modelId === modelId)) {\n      const ids = available.map(m => m.modelId).join(', ') || '(none)';\n      throw new Error(`Model \"${modelId}\" is not available. Available models: ${ids}`);\n    }\n\n    await this.connection!.unstable_setSessionModel({\n      sessionId: this.session!.sessionId,\n      modelId,\n    });\n  }\n\n  async prompt(task: string, signal?: AbortSignal): Promise<string> {\n    const parts: string[] = [];\n\n    for await (const event of this.promptStream(task, signal)) {\n      if (event.type === 'text') {\n        parts.push(event.text);\n      }\n    }\n\n    return parts.join('');","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/agent-sdks/acp/src/connection.ts#L110-L146","documentation":"The handler looks up the agent by id in the agents store; when getById returns null the endpoint responds 404 with this message. It is a plain resource-not-found signal, not an infrastructure fault.","triggerScenarios":"GET/POST /api/agents/:agentId/versions... where :agentId does not exist in storage, or the agent record was deleted before this call.","commonSituations":"Stale client caches holding agent ids from a wiped database; typos in the agentId path param; pointing a client at a different environment (staging DB) than the one that registered the agent; agents created only in code (new Agent(...)) but never registered in the agents store.","solutions":["Verify the agentId exists via GET /api/agents (list) before calling version endpoints","Fix the path parameter value to the stored agent id","If the agent should exist, check you are connected to the intended storage (env DATABASE_URL etc.) and that data wasn't wiped/migrated","Re-register the agent in storage if the record was deleted"],"exampleFix":"// before\nfetch(`/api/agents/${agentId}/versions/${versionId}`)\n// after\nconst agents = await fetch('/api/agents').then(r => r.json());\nif (agents.some(a => a.id === agentId)) {\n  await fetch(`/api/agents/${agentId}/versions/${versionId}`);\n}","handlingStrategy":"validation","validationCode":"const agents = await fetch('/api/agents').then(r => r.json());\nif (!agents.some(a => a.id === agentId)) throw new Error(`Agent ${agentId} not present in storage`);","typeGuard":"function agentExists(agents: {id: string}[], id: string): boolean {\n  return agents.some(a => a.id === id);\n}","tryCatchPattern":"try {\n  await fetch(`/api/agents/${agentId}/versions/${versionId}`);\n} catch (e) {\n  if (isHttpError(e) && e.status === 404 && e.message.includes('Agent with id')) {\n    // refresh agent list / fix path param\n  } else throw e;\n}","preventionTips":["Resolve agentIds from a live list call, not hardcoded strings","Keep client and server pointed at the same storage environment","Avoid deleting agent records that clients still reference","Log the agentId on 404s to catch typos quickly"],"tags":["http-404","not-found","agents","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}