{"record":{"id":"6753d80ec180065d","repo":"deepseek-ai/deepseek-harness","slug":"ralph-workflow-returned-a-malformed-terminal-resul","errorCode":null,"errorMessage":"Ralph workflow returned a malformed terminal result","messagePattern":"Ralph workflow returned a malformed terminal result","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/workflow/tool-ralph/src/index.ts","lineNumber":289,"sourceCode":"  }\n  if (expectedStatus === 'blocked' && !normalizedText(report.blocker)) {\n    throw new Error('Ralph workflow returned an invalid blocked report')\n  }\n  const chars = JSON.stringify(report).length\n  if (chars > maxChars) {\n    throw new Error(`Ralph workflow returned an oversized handoff (${chars} > ${maxChars})`)\n  }\n  return report\n}\n\n/** Defensively decode the fixed script's terminal value. */\nfunction readRunResult(value: unknown, maxRounds: number, maxHandoffChars: number): RalphTerminalResult {\n  if (!isRecord(value)\n    || typeof value['roundsStarted'] !== 'number'\n    || !Number.isSafeInteger(value['roundsStarted'])\n    || value['roundsStarted'] < 1\n    || value['roundsStarted'] > maxRounds) {\n    throw new Error('Ralph workflow returned a malformed terminal result')\n  }\n  const roundsStarted = value['roundsStarted']\n  switch (value['status']) {\n    case 'complete':\n      if (Object.keys(value).sort().join(',') !== 'report,roundsStarted,status') {\n        throw new Error('Ralph workflow returned a malformed terminal result')\n      }\n      return { status: 'complete', roundsStarted, report: readReport(value['report'], 'complete', maxHandoffChars) }\n    case 'blocked':\n      if (Object.keys(value).sort().join(',') !== 'report,roundsStarted,status') {\n        throw new Error('Ralph workflow returned a malformed terminal result')\n      }\n      return { status: 'blocked', roundsStarted, report: readReport(value['report'], 'blocked', maxHandoffChars) }\n    case 'budget-limited':\n      if (Object.keys(value).sort().join(',') !== 'report,roundsStarted,status') {\n        throw new Error('Ralph workflow returned a malformed terminal result')\n      }\n      if (roundsStarted !== maxRounds) {","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/workflow/tool-ralph/src/index.ts#L271-L307","documentation":"Error \"Ralph workflow returned a malformed terminal result\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/workflow/tool-ralph/src/index.ts:289 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the Ralph workflow's terminal result so it matches the expected status/result contract; inspect the returned value in the session log."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}