{"record":{"id":"dbaa4eee1225af16","repo":"moeru-ai/airi","slug":"failed-to-resolve-chat-provider-providerid","errorCode":null,"errorMessage":"Failed to resolve chat provider \"${providerId}\"","messagePattern":"Failed to resolve chat provider \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-ui/src/stores/chat.ts","lineNumber":424,"sourceCode":"    chatSession.appendSessionMessage(sessionId, {\n      role: 'error',\n      content: errorMessageFrom(error) ?? 'Unknown chat operation failure',\n    })\n  }\n\n  async function executeSend(payload: ChatSendPayload): Promise<ChatSendResult> {\n    const providerId = activeProvider.value\n    const modelId = activeModel.value\n    if (!providerId || !modelId)\n      throw new Error('No active chat provider or model configured')\n\n    if (!await chatSession.loadSession(payload.sessionId))\n      throw new Error('Failed to load the target chat session')\n\n    const messageCount = chatSession.getSessionMessages(payload.sessionId).length\n    const chatProvider = await consciousnessStore.getChatProviderInstance(providerId)\n    if (!chatProvider)\n      throw new Error(`Failed to resolve chat provider \"${providerId}\"`)\n\n    await runtime.ingest(payload.text, {\n      model: modelId,\n      chatProvider,\n      attachments: payload.attachments,\n      input: payload.input,\n      replyToMessageId: payload.replyToMessageId,\n      toolReferences: payload.tools,\n      temperature: payload.temperature ?? consciousnessStore.activeTemperature,\n      topP: payload.topP ?? consciousnessStore.activeTopP,\n      // Resolve this function after the request reaches the per-session queue.\n      // The history then contains tool names from every earlier queued turn.\n      tools: async () => {\n        const references = collectToolReferences(payload.sessionId, payload.tools)\n        return llmToolsStore.getToolsByNames(...references.map(tool => tool.name))\n      },\n    }, payload.sessionId)\n","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/moeru-ai/airi/blob/438a067dde47aa0bdb46c2323d1fe293dc805218/packages/stage-ui/src/stores/chat.ts#L406-L442","documentation":"After passing the provider/model precondition, executeSend asks providerStore.getProviderInstance<ChatProvider>(providerId) for a live provider instance and throws when it cannot produce one. This means the id is 'active' in settings but no configured, instantiable provider exists behind it — removed, incompletely configured, or the providers store not yet initialized.","triggerScenarios":"activeProvider references a provider deleted from settings without resetting chat settings; provider record exists but its config lacks credentials so instantiation returns nothing; send fires before the providers store finished initialization; provider definition no longer registered (paired with error 142's registry).","commonSituations":"Deleting or resetting a provider in settings then immediately sending from a still-open chat; storage partial restore that kept chat settings but lost provider records; version changes renaming provider definitions.","solutions":["Open provider settings and reconfigure/re-add the chat provider referenced by the error message.","Re-select the active provider and model in chat settings after changing providers.","Await providers store initialization before enabling the send action.","When a provider is removed, clear activeProvider/activeModel so users hit the clearer error 147 instead."],"exampleFix":"// before\nawait chatStore.send({ sessionId, text })\n\n// after\nconst provider = providersStore.providers[activeProvider.value]\nif (!provider || provider.status !== 'configured') {\n  toast.info('Configure the active chat provider before sending')\n  return\n}\nawait chatStore.send({ sessionId, text })","handlingStrategy":"validation","validationCode":"const provider = providersStore.providers[activeProvider.value]\nif (!provider || (provider.status !== 'configured' && provider.status !== 'bypassed')) {\n  openProviderSettings()\n  return\n}\nawait chatStore.send({ sessionId, text })","typeGuard":"function isResolvableChatProvider(providerId: string | undefined, providers: Record<string, InferenceServiceProvider>): boolean {\n  if (!providerId) return false\n  const p = providers[providerId]\n  return Boolean(p && (p.status === 'configured' || p.status === 'bypassed'))\n}","tryCatchPattern":"try {\n  await chatStore.send({ sessionId, text })\n}\ncatch (error) {\n  const message = errorMessageFrom(error) ?? ''\n  if (message.startsWith('Failed to resolve chat provider')) {\n    openProviderSettings(message.slice(message.indexOf('\"'))) // includes the id\n    return\n  }\n  throw error\n}","preventionTips":["Await providers store initialization before enabling the composer.","Reset activeProvider/activeModel inside the provider-removal flow.","Show provider status in chat settings so unconfigured states are visible.","On startup, cross-check activeProvider against the providers registry and self-heal."],"tags":["chat","provider","configuration","dependency-injection"],"backgroundTag":"provider-instance-not-found","analyzedSha":"438a067dde47aa0bdb46c2323d1fe293dc805218","analyzedAt":"2026-08-28T13:11:01.995Z","contentChangedAt":"2026-08-28T13:11:01.995Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}