{"record":{"id":"4276737a6e75b968","repo":"HKUDS/Vibe-Trading","slug":"valuations-may-contain-at-most-max-valuations-e","errorCode":null,"errorMessage":"valuations may contain at most {_MAX_VALUATIONS} entries","messagePattern":"valuations may contain at most (.+?) entries","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/cashflow_analytics_tool.py","lineNumber":319,"sourceCode":"\n\ndef _coerce_valuations(raw: Any) -> list[tuple[date, float]]:\n    \"\"\"Parse the raw valuation array into ``(date, value)`` pairs.\n\n    Args:\n        raw: Value supplied for the ``valuations`` parameter.\n\n    Returns:\n        Pairs in the order supplied; the library sorts and validates them.\n\n    Raises:\n        ValueError: If the array is missing, wrongly shaped, over the size cap,\n            or an entry lacks a usable date or value.\n    \"\"\"\n    if not isinstance(raw, list) or len(raw) < 2:\n        raise ValueError(\"valuations must be an array of at least two {date, value} objects\")\n    if len(raw) > _MAX_VALUATIONS:\n        raise ValueError(f\"valuations may contain at most {_MAX_VALUATIONS} entries\")\n\n    pairs: list[tuple[date, float]] = []\n    for index, item in enumerate(raw):\n        if not isinstance(item, dict):\n            raise ValueError(f\"valuations[{index}] must be an object with date and value\")\n        if \"date\" not in item or \"value\" not in item:\n            raise ValueError(f\"valuations[{index}] needs both 'date' and 'value'\")\n        try:\n            value = float(item[\"value\"])\n        except (TypeError, ValueError) as exc:\n            raise ValueError(f\"valuations[{index}].value must be numeric\") from exc\n        if not math.isfinite(value):\n            raise ValueError(f\"valuations[{index}].value must be finite\")\n        pairs.append((item[\"date\"], value))\n    return pairs\n\n\ndef _resolve_flows(kwargs: dict[str, Any]) -> CashFlowSeries | None:","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/cashflow_analytics_tool.py#L301-L337","documentation":"_coerce_valuations caps the array at _MAX_VALUATIONS entries to bound compute and payload size. Exceeding the cap raises this ValueError even if every entry is individually well-formed.","triggerScenarios":"Passing daily valuation series (thousands of points) where the tool expects a bounded sample; bulk-importing full price history as valuations.","commonSituations":"Users dumping an entire NAV/price history instead of periodic valuations; LLM pasting large datasets into the tool call; batch jobs that never paginate.","solutions":["Downsample to at most _MAX_VALUATIONS points (e.g. weekly/monthly sampling or last-N)","Check the module constant _MAX_VALUATIONS before building the payload","Split the analysis across multiple calls if full resolution is truly needed"],"exampleFix":"// before\nvaluations = daily_nav_history  # 10k entries\n// after\nvaluations = daily_nav_history[::len(daily_nav_history)//_MAX_VALUATIONS + 1]","handlingStrategy":"validation","validationCode":"from src.tools.cashflow_analytics_tool import _MAX_VALUATIONS\nif len(valuations) > _MAX_VALUATIONS:\n    step = len(valuations) // _MAX_VALUATIONS + 1\n    valuations = valuations[::step]","typeGuard":"def within_cap(v: list, cap: int) -> bool:\n    return len(v) <= cap","tryCatchPattern":"try:\n    tool.execute(valuations=valuations)\nexcept ValueError as e:\n    if 'at most' in str(e):\n        valuations = downsample(valuations, _MAX_VALUATIONS); retry","preventionTips":["Downsample long series client-side","Read the documented cap before bulk imports"],"tags":["limits","validation","cashflow-analytics"],"backgroundTag":"payload-size-limit-exceeded","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}