{"record":{"id":"c1b162724d1c8d5d","repo":"mastra-ai/mastra","slug":"responses-route-could-not-determine-the-effective","errorCode":null,"errorMessage":"Responses route could not determine the effective model for this request","messagePattern":"Responses route could not determine the effective model for this request","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/responses.ts","lineNumber":713,"sourceCode":"  const resolvedModel = await agent.getModel({\n    requestContext,\n    modelConfig: body.model,\n  });\n  const responseModel =\n    body.model ??\n    (() => {\n      if (resolvedModel.provider && resolvedModel.modelId) {\n        const publicProviderId = resolvedModel.provider.includes('.')\n          ? resolvedModel.provider.split('.')[0]!\n          : resolvedModel.provider;\n        return `${publicProviderId}/${resolvedModel.modelId}`;\n      }\n\n      if (resolvedModel.modelId) {\n        return resolvedModel.modelId;\n      }\n\n      throw new HTTPException(500, {\n        message: 'Responses route could not determine the effective model for this request',\n      });\n    })();\n  const shouldStore = body.store ?? false;\n  const needsMemoryStore = shouldStore || Boolean(body.conversation_id) || Boolean(body.previous_response_id);\n  const agentMemoryStore = needsMemoryStore\n    ? await resolveAgentMemoryStore({\n        agent,\n        requestContext,\n        errorMessage: body.previous_response_id\n          ? 'previous_response_id requires the target agent to have memory storage configured'\n          : shouldStore\n            ? 'Stored responses require the target agent to have memory storage configured'\n            : 'conversation_id requires the target agent to have memory storage configured',\n      })\n    : null;\n  const configuredTools = mapMastraToolsToResponseTools(\n    (await Promise.resolve(agent.listTools({ requestContext }))) as Record<string, unknown>,","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/responses.ts#L695-L731","documentation":"prepareCreateResponseRequest resolves the effective model for the responses route and requires it to expose a modelId. When the resolved model has no modelId (model resolution returned a partial/unknown descriptor), the route throws HTTP 500 rather than dispatch to a model it cannot identify.","triggerScenarios":"POST to the responses route where the agent's model resolution produces an object whose modelId is falsy — e.g. an agent configured with a provider that did not fully resolve, or a model specified via config/context that the route's resolution step cannot turn into a concrete model id.","commonSituations":"Agent configured with an unsupported or dynamic model entry (e.g. string gateway alias that failed to resolve); version mismatch where the core model resolution API changed shape; custom model wrapper omitting modelId; environment variables for the provider missing so resolution falls back to an unresolvable placeholder.","solutions":["Fix the agent's model configuration so it resolves to a concrete model (e.g. 'openai/gpt-4o') and required provider env vars are set.","Log/inspect the resolvedModel object returned by the agent's resolution path to see why modelId is empty.","Upgrade or align @mastra/core and @mastra/server versions so model resolution APIs match.","Use an explicitly constructed MastraLanguageModel (provider constructor) instead of an unresolvable string alias."],"exampleFix":"// before\nnew Agent({ name: 'a', instructions: '...', model: 'my-alias' }) // alias not resolvable\n// after\nnew Agent({ name: 'a', instructions: '...', model: 'openai/gpt-4o' })","handlingStrategy":"validation","validationCode":"// before calling the route, ensure the agent resolves a concrete model\nconst model = await agent.getModels?.() ?? agent.model;\nconst modelId = typeof model === 'string' ? model : model?.modelId;\nif (!modelId) throw new Error(`Agent ${agentId} has no resolvable model id`);","typeGuard":"function hasModelId(m: unknown): m is { modelId: string } {\n  return typeof m === 'object' && m !== null && 'modelId' in m && typeof (m as any).modelId === 'string' && (m as any).modelId.length > 0;\n}","tryCatchPattern":"try {\n  const res = await client.createResponse(body);\n} catch (e) {\n  if (isHttpError(e, 500) && /effective model/.test(e.message)) {\n    throw new Error(`Agent model misconfigured: ${e.message}`); // fix model config server-side\n  }\n  throw e;\n}","preventionTips":["Configure agents with concrete model ids like 'openai/gpt-4o'.","Set all provider env vars (OPENAI_API_KEY etc.) before starting the server.","Keep @mastra/core and @mastra/server versions aligned.","Avoid custom model wrappers unless they expose a non-empty modelId."],"tags":["http-500","model-resolution","responses-api","configuration"],"backgroundTag":"model-id-unresolved","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}