HKUDS/Vibe-Trading · error · ValueError

scenario_iv_values must be a non-empty array

Error message

scenario_iv_values must be a non-empty array

What it means

Thrown by _scenario_ivs when the scenario_iv_values override is present but not a non-empty list. IV scenarios drive the volatility sensitivity rows; an empty array would produce an empty scenario table, so it is rejected. Omitting/null selects the five default scenarios (entry_iv multiples).

Source

Thrown at agent/src/tools/options_payoff_tool.py:329

        raise ValueError("spot_min must be non-negative")
    if spot_max <= spot_min:
        raise ValueError("spot_max must be greater than spot_min")
    return spot_min, spot_max


def _scenario_ivs(raw: Any, entry_iv: float) -> np.ndarray:
    """Resolve bounded explicit IV scenarios or the skill's five defaults."""
    if raw is None:
        values = [
            entry_iv * 0.5,
            entry_iv * 0.75,
            entry_iv,
            entry_iv * 1.25,
            entry_iv * 1.5,
        ]
    else:
        if not isinstance(raw, list) or not raw:
            raise ValueError("scenario_iv_values must be a non-empty array")
        if len(raw) > _MAX_IV_SCENARIOS:
            raise ValueError(f"scenario_iv_values may contain at most {_MAX_IV_SCENARIOS} entries")
        try:
            values = [float(value) for value in raw]
        except (TypeError, ValueError, OverflowError) as exc:
            raise ValueError("scenario_iv_values must contain numbers") from exc
    array = np.asarray(values, dtype=float)
    if not np.isfinite(array).all() or (array <= 0).any():
        raise ValueError("scenario_iv_values must contain positive finite values")
    return array


def _rounded(value: float) -> float:
    """Round a finite scalar for stable, compact JSON."""
    return round(float(value), 6)


def _rounded_array(values: np.ndarray) -> list[float]:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Pass a JSON array with at least one IV: [0.15, 0.25, 0.35]
  2. Split string inputs: [float(x) for x in raw.split(',')] if non-empty
  3. Omit the key to accept the default scenario ladder

Example fix

// before
execute({..., "scenario_iv_values": "0.2,0.3"})
// after
execute({..., "scenario_iv_values": [0.2, 0.3]})
Defensive patterns

Strategy: validation

Validate before calling

ivs = kwargs.get("scenario_iv_values")
if isinstance(ivs, str):
    ivs = [float(x) for x in ivs.split(",") if x.strip()]
if ivs is not None and (not isinstance(ivs, list) or not ivs):
    ivs = None
kwargs["scenario_iv_values"] = ivs

Type guard

def iv_scenarios_ok(raw) -> bool:
    return raw is None or (isinstance(raw, list) and len(raw) > 0)

Try / catch

try:
    execute(kwargs)
except ValueError as e:
    if "scenario_iv_values" in str(e):
        kwargs.pop("scenario_iv_values", None); execute(kwargs)

Prevention

When it happens

Trigger: scenario_iv_values=[] or a non-list such as "0.2,0.3" or {"ivs":[...]}. Only null/absence uses defaults.

Common situations: LLM passing comma strings instead of arrays; config templating producing empty lists when a filter removes all values; forwarding a dict from another schema.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/2f8eb112456eb99d. Report an issue: GitHub.