Hmbown/CodeWhale · error · RuntimeError

Codewhale terminal receipt sandbox did not match launch

Error message

Codewhale terminal receipt sandbox did not match launch

What it means

config.sandbox resolves 'auto' to 'workspace-write' on subprocess runtimes and 'external-sandbox' otherwise, passes the result as --sandbox, and requires the receipt to echo the identical sandbox_posture. A mismatch means the binary actually ran under a different sandbox than requested — a safety and attribution break, not a formatting issue.

Source

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

            argv.extend(["--max-turns", str(self.config.max_turns)])
        if self.config.disabled_tools:
            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. Set sandbox explicitly (e.g. 'read-only') instead of 'auto' when receipt predictability matters
  2. Make facades echo the --sandbox argument verbatim as sandbox_posture
  3. Verify the pinned release honors --sandbox on the target runtime

Example fix

# before
config = CodewhaleHarnessConfig(version='0.9.1', sandbox='auto')
# after
config = CodewhaleHarnessConfig(version='0.9.1', sandbox='workspace-write')
Defensive patterns

Strategy: try-catch

Validate before calling

sandbox = 'workspace-write' if runtime.type == 'subprocess' else 'external-sandbox'
config = CodewhaleHarnessConfig(version='0.9.1', sandbox=sandbox)  # pin explicitly instead of 'auto'

Try / catch

try:
    result = await harness.launch(ctx, trace, runtime, endpoint, secret, mcp_urls)
except RuntimeError as e:
    if 'sandbox did not match' in str(e):
        compare_requested_vs_echoed_sandbox(config.sandbox, e)
    raise

Prevention

When it happens

Trigger: A binary escalating or downgrading the sandbox relative to its --sandbox argument; facades omitting sandbox_posture; runtime.type changing the 'auto' resolution so the echoed posture differs from the computed one.

Common situations: Container runtimes ignoring sandbox flags they do not implement; facades with placeholder postures; switching the harness between subprocess and sandboxed runtimes without pinning sandbox explicitly.

Related errors


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