Hmbown/CodeWhale · error · ValueError

max_turns must be between 1 and 10000

Error message

max_turns must be between 1 and 10000

What it means

_validate_config enforces that the optional max_turns cap is between 1 and 10000 inclusive. max_turns limits the model-step count passed to the CLI as --max-turns, and zero, negative, or absurdly large values would be meaningless or rejected by the binary.

Solutions

  1. Pass max_turns=None to leave rollouts unlimited (the default)
  2. Set max_turns to an integer in 1..10000, e.g. max_turns=50
  3. If the intent was 'no limit', delete the max_turns field rather than using 0

Example fix

// before
CodewhaleHarnessConfig(max_turns=0)
// after
CodewhaleHarnessConfig(max_turns=None)  # unlimited
# or
CodewhaleHarnessConfig(max_turns=100)
Defensive patterns

Strategy: validation

Validate before calling

if cfg.max_turns is not None and not (1 <= cfg.max_turns <= 10_000):
    raise ValueError("max_turns must be between 1 and 10000")

Try / catch

try:
    await harness.setup(runtime)
except ValueError as e:
    if "max_turns" in str(e):
        cfg.max_turns = None  # fall back to unlimited
    else:
        raise

Prevention

When it happens

Trigger: Constructing CodewhaleHarnessConfig with max_turns=0, a negative integer, or an integer above 10000, then calling setup() or launch().

Common situations: Attempting to disable the turn cap with max_turns=0 instead of None; off-by-one when computing a budget; forgetting the upper bound of 10000.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

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

    sandbox: Literal["auto", "read-only", "workspace-write", "external-sandbox"] = (
        "auto"
    )
    """`auto` keeps subprocess runs workspace-bound and trusts isolated runtimes."""


class CodewhaleHarness(Harness[CodewhaleHarnessConfig]):
    APPENDS_SYSTEM_PROMPT = True
    SUPPORTS_MCP = True
    SUPPORTS_USER_SIM = False

    def _validate_config(self) -> None:
        if not _VERSION.fullmatch(self.config.version):
            raise ValueError("version must be a semantic release identifier")
        if (
            self.config.max_turns is not None
            and not 1 <= self.config.max_turns <= 10_000
        ):
            raise ValueError("max_turns must be between 1 and 10000")
        invalid = [
            tool
            for tool in self.config.disabled_tools or []
            if not _TOOL.fullmatch(tool)
        ]
        if invalid:
            raise ValueError(
                "disabled_tools must use Codewhale catalog identifiers: "
                + ", ".join(repr(tool) for tool in invalid)
            )

    @property
    def binary(self) -> str:
        configured = (self.config.binary_path or "").strip()
        return configured or DEFAULT_BINARY

    async def setup(self, runtime: Runtime) -> None:
        self._validate_config()

View on GitHub (pinned to 433685b202)