Mintplex-Labs/anything-llm · error · Error
Failed to create thread
Error message
Failed to create thread
What it means
Thrown by continueInThread when WorkspaceThread.new(workspace) returns a non-null threadError (returned as `message`). The fallback fires only if that message is empty. This means a thread could not be created for the resolved 'Scheduled Jobs' workspace, blocking the run from being recorded as a chat.
Source
Thrown at server/models/scheduledJobRun.js:332
const result = safeJsonParse(run.result, {});
const responseText = result?.text || "No response was generated.";
// Get or create the "Scheduled Jobs" workspace
const { workspace, error: workspaceError } = await Workspace.upsert(
{ slug: "scheduled-jobs" },
{
name: "Scheduled Jobs",
slug: "scheduled-jobs",
chatMode: "automatic",
}
);
if (workspaceError)
throw new Error(workspaceError || "Failed to create workspace");
const { thread, message: threadError } =
await WorkspaceThread.new(workspace);
if (threadError)
throw new Error(threadError || "Failed to create thread");
await WorkspaceChats.new({
workspaceId: workspace.id,
prompt: run.job.prompt,
response: {
text: responseText,
sources: result.sources || [],
outputs: result.outputs || [],
type: "chat",
},
threadId: thread.id,
include: true,
});
return {
workspace,
thread,
error: null,View on GitHub (pinned to 526360e320)
Solutions
- Inspect the propagated threadError string in the returned { error }.
- Verify the workspace_threads table schema matches WorkspaceThread.new's insert.
- Run pending migrations.
- Check DB logs for the failed INSERT.
Defensive patterns
Strategy: try-catch
Try / catch
const { thread, error } = await ScheduledJobRun.continueInThread(runId);
if (error && /create thread/i.test(error)) {
logger.error('Thread creation for scheduled run failed', { runId, error });
return res.status(503).json({ error: 'Could not create a thread for the run.' });
} Prevention
- Ensure workspace_threads schema matches WorkspaceThread.new's insert.
- Apply pending migrations before relying on continueInThread.
- Log the propagated threadError for diagnosis.
When it happens
Trigger: WorkspaceThread.new failed internally — DB write error, missing required workspace field, or a thread-limit/validation inside the helper. The workspace was created/found but thread creation is the failing step.
Common situations: Database connectivity issue isolated to the write; the workspace object passed in was missing expected fields; a schema change to workspace_threads introduced a required column not supplied by WorkspaceThread.new.
Related errors
- Run not found
- Failed to create workspace
- Internal Server Error
- Failed to update default system prompt.
- System prompt variable not found
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/21516fa17e33d1d9.
Report an issue: GitHub.