Hmbown/CodeWhale · error · RuntimeError

Codewhale terminal receipt was not resolved

Error message

Codewhale terminal receipt was not resolved

What it means

The harness requires the terminal receipt's termination_reason to be exactly 'resolved'. This RuntimeError fires when status was 'completed' but termination_reason was something else (e.g. 'max_turns', 'interrupted', 'user_exit'). The harness throws it because only 'resolved' proves the task actually finished, not merely that the process stopped cleanly.

Solutions

  1. Log or dump receipt['terminal']['termination_reason'] to see why the run ended
  2. Increase max_turns in CodewhaleHarnessConfig so the agent has room to resolve the task
  3. Check the task prompt for clarity issues causing the agent to stop early
  4. Verify the binary version matches the pinned 0.9.1 receipt vocabulary
  5. If termination_reason is legitimately 'max_turns', treat the rollout as failed rather than bypassing the check

Example fix

# before
CodewhaleHarnessConfig(model="...", max_turns=3)
# after
CodewhaleHarnessConfig(model="...", max_turns=100)
Defensive patterns

Strategy: validation

Validate before calling

def validate_resolution(terminal: dict) -> None:
    reason = terminal.get("termination_reason")
    assert reason == "resolved", f"run ended with termination_reason={reason!r}"

Type guard

def is_resolved(terminal: dict) -> bool:
    return terminal.get("termination_reason") == "resolved"

Try / catch

try:
    result = await harness.launch(ctx, trace, runtime, endpoint, secret, mcp_urls)
except RuntimeError as e:
    if "was not resolved" in str(e):
        reason = (trace.info.get("codewhale") or {}).get("terminal", {}).get("termination_reason")
        logger.warning("unresolved rollout (reason=%s)", reason)
    raise

Prevention

When it happens

Trigger: launch() got a zero exit code, a valid terminal receipt with status 'completed', but meta['termination_reason'] != 'resolved' — typically a run stopped by the --max-turns ceiling or an early agent self-exit.

Common situations: max_turns configured too low for the task; agent giving up / ending the conversation early; newer binary versions that changed termination_reason strings; ambiguous tasks that the model stops without resolving.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/34720d487c43b72d. Report an issue: GitHub.

Appendix: source

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

        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
    )


def _bounded_terminal(meta: dict[str, Any]) -> dict[str, Any]:
    terminal: dict[str, Any] = {}
    for key in _TERMINAL_FIELDS:
        if key not in meta or meta[key] is None:

View on GitHub (pinned to 433685b202)