HKUDS/Vibe-Trading · error · ValueError
valuations may contain at most {_MAX_VALUATIONS} entries
Error message
valuations may contain at most {_MAX_VALUATIONS} entries What it means
_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.
Source
Thrown at agent/src/tools/cashflow_analytics_tool.py:319
def _coerce_valuations(raw: Any) -> list[tuple[date, float]]:
"""Parse the raw valuation array into ``(date, value)`` pairs.
Args:
raw: Value supplied for the ``valuations`` parameter.
Returns:
Pairs in the order supplied; the library sorts and validates them.
Raises:
ValueError: If the array is missing, wrongly shaped, over the size cap,
or an entry lacks a usable date or value.
"""
if not isinstance(raw, list) or len(raw) < 2:
raise ValueError("valuations must be an array of at least two {date, value} objects")
if len(raw) > _MAX_VALUATIONS:
raise ValueError(f"valuations may contain at most {_MAX_VALUATIONS} entries")
pairs: list[tuple[date, float]] = []
for index, item in enumerate(raw):
if not isinstance(item, dict):
raise ValueError(f"valuations[{index}] must be an object with date and value")
if "date" not in item or "value" not in item:
raise ValueError(f"valuations[{index}] needs both 'date' and 'value'")
try:
value = float(item["value"])
except (TypeError, ValueError) as exc:
raise ValueError(f"valuations[{index}].value must be numeric") from exc
if not math.isfinite(value):
raise ValueError(f"valuations[{index}].value must be finite")
pairs.append((item["date"], value))
return pairs
def _resolve_flows(kwargs: dict[str, Any]) -> CashFlowSeries | None:View on GitHub (pinned to 80ffdda44c)
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
Example fix
// before valuations = daily_nav_history # 10k entries // after valuations = daily_nav_history[::len(daily_nav_history)//_MAX_VALUATIONS + 1]
Defensive patterns
Strategy: validation
Validate before calling
from src.tools.cashflow_analytics_tool import _MAX_VALUATIONS
if len(valuations) > _MAX_VALUATIONS:
step = len(valuations) // _MAX_VALUATIONS + 1
valuations = valuations[::step] Type guard
def within_cap(v: list, cap: int) -> bool:
return len(v) <= cap Try / catch
try:
tool.execute(valuations=valuations)
except ValueError as e:
if 'at most' in str(e):
valuations = downsample(valuations, _MAX_VALUATIONS); retry Prevention
- Downsample long series client-side
- Read the documented cap before bulk imports
When it happens
Trigger: Passing daily valuation series (thousands of points) where the tool expects a bounded sample; bulk-importing full price history as valuations.
Common situations: Users dumping an entire NAV/price history instead of periodic valuations; LLM pasting large datasets into the tool call; batch jobs that never paginate.
Related errors
- valuations must be an array of at least two {date, value} ob
- valuations[{index}] must be an object with date and value
- legs may contain at most {_MAX_LEGS} entries
- spot_points must be between {_MIN_SPOT_POINTS} and {_MAX_SPO
- scenario_iv_values may contain at most {_MAX_IV_SCENARIOS} e
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/4276737a6e75b968.
Report an issue: GitHub.