{"record":{"id":"8532f1ad87088ea4","repo":"mastra-ai/mastra","slug":"schedules-threadless-options","errorCode":"SCHEDULES_THREADLESS_OPTIONS","errorMessage":"schedules.create: ${offenders.join(', ')} require a threadId.","messagePattern":"schedules\\.create: (.+?) require a threadId\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":400,"severity":"error","filePath":"packages/core/src/schedules/schedules.ts","lineNumber":300,"sourceCode":"    }\n\n    if (input.threadId && !input.resourceId) {\n      throw new MastraError({\n        id: 'SCHEDULES_MISSING_RESOURCE_ID',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        details: { status: 400 },\n        text: 'schedules.create requires `resourceId` when `threadId` is set.',\n      });\n    }\n    if (!input.threadId) {\n      const offenders: string[] = [];\n      if (input.signalType !== undefined) offenders.push('signalType');\n      if (input.ifActive !== undefined) offenders.push('ifActive');\n      if (input.ifIdle !== undefined) offenders.push('ifIdle');\n      if (input.resourceId !== undefined) offenders.push('resourceId');\n      if (offenders.length > 0) {\n        throw new MastraError({\n          id: 'SCHEDULES_THREADLESS_OPTIONS',\n          domain: ErrorDomain.AGENT,\n          category: ErrorCategory.USER,\n          details: { status: 400 },\n          text: `schedules.create: ${offenders.join(', ')} require a threadId.`,\n        });\n      }\n    }\n\n    const store = await this.#getStore();\n    // Make sure the scheduler + agent-schedule worker are running. Boot-time\n    // detection covers existing rows; imperative creates after\n    // startWorkers() need to flip the request flag and lazily inject.\n    await this.#mastra.__ensureScheduleRuntimeReady();\n\n    const id =\n      input.id !== undefined\n        ? normalizeScheduleId(input.id, AGENT_SCHEDULE_PREFIX)","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/schedules/schedules.ts#L282-L318","documentation":"Schedules.create was called with agent-schedule options (signalType, ifActive, ifIdle, resourceId) but without a threadId. These options are thread-scoped and only meaningful for agent schedules, so the library rejects the combination up front with a 400-class user error naming each offending key.","triggerScenarios":"Calling schedules.create() (via createAgentSchedule) where any of input.signalType, input.ifActive, input.ifIdle, or input.resourceId is !== undefined while input.threadId is undefined.","commonSituations":"Copying a workflow-schedule config into an agent schedule; adding ifActive/ifIdle collision options without wiring the schedule to a memory thread; passing resourceId because of confusion with agent resourceId vs schedule threadId.","solutions":["Provide a threadId in the create input so the options become valid.","Remove signalType/ifActive/ifIdle/resourceId from the input if you did not intend thread-scoped behavior.","If you meant a workflow schedule, remove agent-only options entirely (they are meaningless there)."],"exampleFix":"// before\nawait schedules.create({ id: 'daily', cron: '0 9 * * *', ifActive: 'skip' });\n// after\nawait schedules.create({ id: 'daily', cron: '0 9 * * *', threadId: 'thread-1', ifActive: 'skip' });","handlingStrategy":"validation","validationCode":"const agentOnlyKeys = ['signalType', 'ifActive', 'ifIdle', 'resourceId'];\nconst hasAgentOnly = agentOnlyKeys.some(k => input[k] !== undefined);\nif (hasAgentOnly && !input.threadId) {\n  throw new Error('agent-schedule options require a threadId');\n}\nawait schedules.create(input);","typeGuard":"function canCreateAgentSchedule(input: CreateScheduleInput): input is CreateScheduleInput & { threadId: string } {\n  const hasAgentOnly = ['signalType', 'ifActive', 'ifIdle', 'resourceId'].some(k => (input as any)[k] !== undefined);\n  return !hasAgentOnly || typeof input.threadId === 'string';\n}","tryCatchPattern":null,"preventionTips":["Always define threadId when creating agent schedules with collision/signal options.","Keep separate input types for agent vs workflow schedules so invalid keys fail typecheck.","Centralize schedule creation in one helper that validates the options combination."],"tags":["schedules","validation","agent"],"backgroundTag":"missing-required-option","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}