{"record":{"id":"9c34dbec26cf466b","repo":"Hmbown/CodeWhale","slug":"codewhale-successful-run-contained-an-error-event","errorCode":null,"errorMessage":"Codewhale successful run contained an error event","messagePattern":"Codewhale successful run contained an error event","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"integrations/verifiers-codewhale/codewhale_harness/harness.py","lineNumber":236,"sourceCode":"            argv.extend([\"--disallowed-tools\", \",\".join(self.config.disabled_tools)])\n        if system:\n            argv.extend([\"--append-system-prompt\", system])\n        argv.extend([\"--\", str(prompt or \"\")])\n\n        result = await runtime.run_program(argv, env)\n        if result.exit_code == 0:\n            receipt = _parse_stream_receipt(result.stdout)\n            terminal = receipt[\"terminal\"]\n            if terminal.get(\"provider\") != \"openai\":\n                raise RuntimeError(\"Codewhale terminal receipt did not use provider openai\")\n            if terminal.get(\"model\") != ctx.model:\n                raise RuntimeError(\"Codewhale terminal receipt model did not match rollout\")\n            if terminal.get(\"approval_posture\") != \"auto_tools\":\n                raise RuntimeError(\"Codewhale terminal receipt did not confirm auto tools\")\n            if terminal.get(\"sandbox_posture\") != sandbox:\n                raise RuntimeError(\"Codewhale terminal receipt sandbox did not match launch\")\n            if receipt[\"events\"].get(\"error\", 0) != 0:\n                raise RuntimeError(\"Codewhale successful run contained an error event\")\n            if terminal.get(\"status\") != \"completed\":\n                raise RuntimeError(\"Codewhale terminal receipt did not report completion\")\n            if terminal.get(\"termination_reason\") != \"resolved\":\n                raise RuntimeError(\"Codewhale terminal receipt was not resolved\")\n            trace.info[\"codewhale\"] = receipt\n        return result\n\n\ndef _has_version(output: str, version: str) -> bool:\n    return (\n        re.search(\n            rf\"(?<![0-9A-Za-z.+-]){re.escape(version)}(?![0-9A-Za-z.+-])\",\n            output,\n        )\n        is not None\n    )\n\n","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/integrations/verifiers-codewhale/codewhale_harness/harness.py#L218-L254","documentation":"Even when the process exits 0, the harness counts event types in the stream and rejects the rollout if any 'error' events were emitted. A successful exit with error events means the binary swallowed failures (e.g. tool errors, provider errors) internally, so the run is not treated as a clean rollout.","triggerScenarios":"The Codewhale run emitted one or more stream-json events of type 'error' but still terminated with exit code 0 and a resolved/completed terminal receipt, during launch().","commonSituations":"Transient provider/API errors retried internally; sandbox_denied or MCP tool failures logged as error events; flaky network to the interception endpoint.","solutions":["Inspect receipt['events']['error'] and the full stream output for the error category details","Check the interception endpoint/network stability and retry the rollout","Fix the underlying tool/MCP failure the error events report; verify MCP server URLs are reachable","If errors are expected for the task, capture them via trace info rather than relying on a clean receipt"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await harness.launch(ctx, trace, runtime, endpoint, secret, mcp_urls)\nexcept RuntimeError as e:\n    if \"contained an error event\" in str(e):\n        receipt = trace.info.get(\"codewhale\", {})\n        # inspect receipt['events']['error'] and raw stream for the failing category\n        ...\n    else:\n        raise","preventionTips":["Monitor receipt['events'] error counts across rollouts to catch flaky providers/tools","Ensure MCP server URLs are reachable from the runtime","Treat exit code 0 as insufficient; always review the stream receipt"],"tags":["receipt","stream","verification"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}