Hmbown/CodeWhale · error · RuntimeError

Codewhale successful run contained an error event

Error message

Codewhale successful run contained an error event

What it means

The parsed event counter must show zero 'error' events for a run that exited 0. Codewhale finished cleanly but emitted at least one error event mid-run, so the harness invalidates the rollout: the trajectory is no longer clean even though the exit code says success.

Source

Thrown at integrations/verifiers-codewhale/codewhale_harness/harness.py:236

            argv.extend(["--disallowed-tools", ",".join(self.config.disabled_tools)])
        if system:
            argv.extend(["--append-system-prompt", system])
        argv.extend(["--", str(prompt or "")])

        result = await runtime.run_program(argv, env)
        if result.exit_code == 0:
            receipt = _parse_stream_receipt(result.stdout)
            terminal = receipt["terminal"]
            if terminal.get("provider") != "openai":
                raise RuntimeError("Codewhale terminal receipt did not use provider openai")
            if terminal.get("model") != ctx.model:
                raise RuntimeError("Codewhale terminal receipt model did not match rollout")
            if terminal.get("approval_posture") != "auto_tools":
                raise RuntimeError("Codewhale terminal receipt did not confirm auto tools")
            if terminal.get("sandbox_posture") != sandbox:
                raise RuntimeError("Codewhale terminal receipt sandbox did not match launch")
            if receipt["events"].get("error", 0) != 0:
                raise RuntimeError("Codewhale successful run contained an error event")
            if terminal.get("status") != "completed":
                raise RuntimeError("Codewhale terminal receipt did not report completion")
            if terminal.get("termination_reason") != "resolved":
                raise RuntimeError("Codewhale terminal receipt was not resolved")
            trace.info["codewhale"] = receipt
        return result


def _has_version(output: str, version: str) -> bool:
    return (
        re.search(
            rf"(?<![0-9A-Za-z.+-]){re.escape(version)}(?![0-9A-Za-z.+-])",
            output,
        )
        is not None
    )

View on GitHub (pinned to 8880682c63)

Solutions

  1. Check the events summary the harness attaches to the trace (trace.info['codewhale']['events']) and rerun; transient causes usually clear
  2. Stabilize the failing dependency seen in the error events (restart the flaky MCP server, fix endpoint reliability)
  3. Filter expected noise at its source so the binary never classifies it as an error event
Defensive patterns

Strategy: retry

Try / catch

for attempt in range(2):
    try:
        result = await harness.launch(ctx, trace, runtime, endpoint, secret, mcp_urls)
        break
    except RuntimeError as e:
        if 'contained an error event' not in str(e) or attempt == 1:
            raise
        restart_flaky_dependency()  # e.g. the MCP server behind mcp_urls

Prevention

When it happens

Trigger: A tool call fails once and the run recovers; the interception endpoint returns a transient 5xx that the binary logs as an error event before retrying; internal failures classified as error events by the binary.

Common situations: Flaky MCP servers behind mcp_urls; unstable local interception endpoints; network blips during long rollouts.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/9c34dbec26cf466b. Report an issue: GitHub.