{"record":{"id":"66f8cbe087c7af2d","repo":"mastra-ai/mastra","slug":"processor-returned-messages-and-message-list","errorCode":"PROCESSOR_RETURNED_MESSAGES_AND_MESSAGE_LIST","errorMessage":"Processor ${processor.id} returned both messages and messageList. Only one of these is allowed.","messagePattern":"Processor (.+?) returned both messages and messageList\\. Only one of these is allowed\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/processors/runner.ts","lineNumber":2601,"sourceCode":"      }\n      return {\n        messageList: result,\n      };\n    } else if (Array.isArray(result)) {\n      return {\n        messages: result,\n      };\n    } else if (result) {\n      if (result.messageList && result.messageList !== messageList) {\n        throw new MastraError({\n          category: 'USER',\n          domain: 'AGENT',\n          id: 'PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST',\n          text: `Processor ${processor.id} returned a MessageList instance other than the one that was passed in as an argument. New external message list instances are not supported. Use the messageList argument instead.`,\n        });\n      }\n      if (result.messages && result.messageList) {\n        throw new MastraError({\n          category: 'USER',\n          domain: 'AGENT',\n          id: 'PROCESSOR_RETURNED_MESSAGES_AND_MESSAGE_LIST',\n          text: `Processor ${processor.id} returned both messages and messageList. Only one of these is allowed.`,\n        });\n      }\n      const { model: _model, ...rest } = result;\n      if (result.model) {\n        const resolvedModel = await resolveModelConfig(result.model);\n        const isSupported = isSupportedLanguageModel(resolvedModel);\n        if (!isSupported) {\n          throw new MastraError({\n            category: 'USER',\n            domain: 'AGENT',\n            id: 'PROCESSOR_RETURNED_UNSUPPORTED_MODEL',\n            text: `Processor ${processor.id} returned an unsupported model version ${resolvedModel.specificationVersion} in step ${stepNumber}. Only ${supportedLanguageModelSpecifications.join(', ')} models are supported in processInputStep.`,\n          });\n        }","sourceCodeStart":2583,"sourceCodeEnd":2619,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/processors/runner.ts#L2583-L2619","documentation":"Thrown when a processor's `processInputStep` returns a result object containing BOTH `messages` and `messageList`. These are alternative ways to convey the processed input, and providing both is ambiguous, so the runner rejects it with a USER-category MastraError.","triggerScenarios":"A processor returns `{ messages: [...], messageList: <instance> }` from `processInputStep` (or an input-step result object).","commonSituations":"Refactored processors where an old `messages` return was kept after adding `messageList`; spreading/merging result objects that accumulate both keys.","solutions":["Return either `messages` or `messageList`, not both — pick one representation.","Prefer returning the mutated `messageList` (or omit both keys if nothing changed).","Add a unit test asserting the processor's return shape."],"exampleFix":"// before\nreturn { messages, messageList };\n\n// after\nreturn { messageList }; // or { messages } — only one\n}","handlingStrategy":"validation","validationCode":"const keys = ['messages', 'messageList'].filter(k => result?.[k] != null);\nif (keys.length > 1) {\n  throw new Error(`Processor result must set only one of: ${keys.join(', ')}`);\n}","typeGuard":"function isExclusiveResult(\n  r: { messages?: unknown[]; messageList?: MessageList } | null | undefined,\n): r is { messages?: unknown[]; messageList?: MessageList } {\n  return !r || !(r.messages && r.messageList);\n}","tryCatchPattern":"try {\n  const res = await agent.generate(input);\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'PROCESSOR_RETURNED_MESSAGES_AND_MESSAGE_LIST') {\n    console.error('Processor returned both messages and messageList; strip one.');\n  }\n  throw e;\n}","preventionTips":["Define each processor's return type explicitly (messages XOR messageList).","Refactor legacy `messages` returns when adding messageList usage.","Unit-test processor return shapes."],"tags":["processors","input-step","return-shape","user-error"],"backgroundTag":"processor-invalid-return-shape","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}