moeru-ai/airi · error · Error
Failed to load the target chat session
Error message
Failed to load the target chat session
What it means
executeSend calls chatSession.loadSession(sessionId), which hydrates a session's messages from IndexedDB (plus cloud sync when needed) and intentionally swallows internal errors, returning false when hydration fails or the id is unknown. This error means 'no loadable session with that id exists right now'. It is a storage/state problem, not a network chat failure.
Source
Thrown at packages/stage-ui/src/stores/chat.ts:395
function appendSendError(sessionId: string, error: unknown) {
if (!chatSession.getSessionMessagesIfLoaded(sessionId))
return
chatSession.appendSessionMessage(sessionId, {
role: 'error',
content: errorMessageFrom(error) ?? 'Unknown chat operation failure',
})
}
async function executeSend(payload: ChatSendPayload): Promise<ChatSendResult> {
const providerId = activeProvider.value
const modelId = activeModel.value
if (!providerId || !modelId)
throw new Error('No active chat provider or model configured')
if (!await chatSession.loadSession(payload.sessionId))
throw new Error('Failed to load the target chat session')
const messageCount = chatSession.getSessionMessages(payload.sessionId).length
const chatProvider = await consciousnessStore.getChatProviderInstance(providerId)
if (!chatProvider)
throw new Error(`Failed to resolve chat provider "${providerId}"`)
await runtime.ingest(payload.text, {
model: modelId,
chatProvider,
attachments: payload.attachments,
input: payload.input,
toolReferences: payload.tools,
temperature: payload.temperature ?? consciousnessStore.activeTemperature,
topP: payload.topP ?? consciousnessStore.activeTopP,
// Resolve this function after the request reaches the per-session queue.
// The history then contains tool names from every earlier queued turn.
tools: async () => {
const references = collectToolReferences(payload.sessionId, payload.tools)View on GitHub (pinned to f679616c34)
Solutions
- Verify the session exists (check sessionMetas or the sessions list) and recreate it if the user expects it.
- Refresh the session list in the UI when this error occurs so stale ids disappear.
- Check browser storage health (quota, private-mode restrictions, IDB errors in devtools).
- Create sessions through the session store API first and keep the generated id as the single source of truth.
Example fix
// before
await chatStore.send({ sessionId, text })
// after
if (!chatSession.sessionMetas[sessionId]) {
sessionId = await chatSession.createSession(/* characterId, meta */)
}
await chatStore.send({ sessionId, text }) Defensive patterns
Strategy: validation
Validate before calling
// Ensure the session exists before sending
if (!chatSession.sessionMetas[sessionId]) {
sessionId = await createOrReselectSession()
}
if (!await chatSession.loadSession(sessionId))
throw new Error(`Chat session ${sessionId} is not available`)
await chatStore.send({ sessionId, text }) Try / catch
try {
await chatStore.send({ sessionId, text })
}
catch (error) {
if (errorMessageFrom(error) === 'Failed to load the target chat session') {
await refreshSessions()
toast.info('This chat is no longer available; pick a session')
return
}
throw error
} Prevention
- Always use session ids created by the session store; never fabricate them.
- Refresh the sessions drawer after deletions so stale ids cannot be sent to.
- When loadSession unexpectedly fails for an existing session, check IndexedDB health.
- Keep a single source of truth for the active sessionId in app state.
When it happens
Trigger: Sending to a sessionId that was deleted (drawer kept a stale id after deletion in another window); session never created before send; IndexedDB read failure (quota, corruption, blocked in restrictive browser modes); cloud hydration path failing for a cloud-backed session.
Common situations: Stale session ids persisted in UI state after the session was cleared elsewhere; browser storage eviction or corrupted IDB databases; multi-tab races where one tab clears sessions while another sends.
Related errors
- Failed to load the target chat session
- No active chat provider or model configured
- Chat session was removed before send completed
- Unknown extension session: ${sessionId}
- Unable to reload missing extension session: ${sessionId}
AI-assisted analysis of moeru-ai/airi@f679616c34 (2026-08-28).
Data as JSON: /api/errors/d9cf3f5acd6a094a.
Report an issue: GitHub.