{"record":{"id":"cb73bb6a534fb06d","repo":"HKUDS/Vibe-Trading","slug":"scenario-iv-values-may-contain-at-most-max-iv-sc","errorCode":null,"errorMessage":"scenario_iv_values may contain at most {_MAX_IV_SCENARIOS} entries","messagePattern":"scenario_iv_values may contain at most (.+?) entries","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/options_payoff_tool.py","lineNumber":331,"sourceCode":"        raise ValueError(\"spot_max must be greater than spot_min\")\n    return spot_min, spot_max\n\n\ndef _scenario_ivs(raw: Any, entry_iv: float) -> np.ndarray:\n    \"\"\"Resolve bounded explicit IV scenarios or the skill's five defaults.\"\"\"\n    if raw is None:\n        values = [\n            entry_iv * 0.5,\n            entry_iv * 0.75,\n            entry_iv,\n            entry_iv * 1.25,\n            entry_iv * 1.5,\n        ]\n    else:\n        if not isinstance(raw, list) or not raw:\n            raise ValueError(\"scenario_iv_values must be a non-empty array\")\n        if len(raw) > _MAX_IV_SCENARIOS:\n            raise ValueError(f\"scenario_iv_values may contain at most {_MAX_IV_SCENARIOS} entries\")\n        try:\n            values = [float(value) for value in raw]\n        except (TypeError, ValueError, OverflowError) as exc:\n            raise ValueError(\"scenario_iv_values must contain numbers\") from exc\n    array = np.asarray(values, dtype=float)\n    if not np.isfinite(array).all() or (array <= 0).any():\n        raise ValueError(\"scenario_iv_values must contain positive finite values\")\n    return array\n\n\ndef _rounded(value: float) -> float:\n    \"\"\"Round a finite scalar for stable, compact JSON.\"\"\"\n    return round(float(value), 6)\n\n\ndef _rounded_array(values: np.ndarray) -> list[float]:\n    \"\"\"Round a numeric array for stable, compact JSON.\"\"\"\n    return [round(float(value), 6) for value in np.asarray(values).tolist()]","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/options_payoff_tool.py#L313-L349","documentation":"Thrown by _scenario_ivs when the supplied scenario_iv_values list exceeds _MAX_IV_SCENARIOS entries. The cap keeps the scenario matrix output bounded; it fires after the non-empty array check and before numeric conversion.","triggerScenarios":"Passing a finely grained IV grid (e.g. np.linspace(0.1, 0.9, 50).tolist()) as scenario values.","commonSituations":"Reusing plotting grids as scenario inputs; sensitivity-sweep scripts; LLMs over-generating scenario lists.","solutions":["Downsample to at most _MAX_IV_SCENARIOS representative IVs","Pick key scenarios: [0.5, 0.75, 1.0, 1.25, 1.5] * entry_iv","Check the constant at the top of options_payoff_tool.py for the exact cap"],"exampleFix":"// before\nexecute({..., \"scenario_iv_values\": np.linspace(0.1, 0.9, 50).tolist()})\n// after\nexecute({..., \"scenario_iv_values\": [0.15, 0.20, 0.25, 0.30, 0.35]})","handlingStrategy":"validation","validationCode":"from agent.src.tools.options_payoff_tool import _MAX_IV_SCENARIOS\nivs = kwargs.get(\"scenario_iv_values\")\nif ivs and len(ivs) > _MAX_IV_SCENARIOS:\n    step = len(ivs) / _MAX_IV_SCENARIOS\n    kwargs[\"scenario_iv_values\"] = [ivs[int(i*step)] for i in range(_MAX_IV_SCENARIOS)]","typeGuard":"def iv_count_ok(ivs) -> bool:\n    return ivs is None or 0 < len(ivs) <= _MAX_IV_SCENARIOS","tryCatchPattern":"try:\n    execute(kwargs)\nexcept ValueError as e:\n    if \"at most\" in str(e) and \"scenario_iv\" in str(e):\n        downsample_and_retry(kwargs)","preventionTips":["Don't reuse dense plotting grids as scenario inputs","Pick 3-5 representative IV levels","Read _MAX_IV_SCENARIOS from the module"],"tags":["validation","limits","options"],"backgroundTag":"input-limit-exceeded","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}