HKUDS/Vibe-Trading · error · ValueError
valuations must be an array of at least two {date, value} ob
Error message
valuations must be an array of at least two {date, value} objects What it means
_coerce_valuations in cashflow_analytics_tool requires the valuations argument to be a JSON array with at least two {date, value} entries; a single point, a non-list, or a missing value cannot define a return series.
Source
Thrown at agent/src/tools/cashflow_analytics_tool.py:317
}
return json.dumps(payload, ensure_ascii=False, allow_nan=False)
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
View on GitHub (pinned to 80ffdda44c)
Solutions
- Pass at least two {date, value} dicts in an actual list
- json.loads the payload first if it arrives as a string
- Enforce minItems:2 in the tool's JSON schema
Example fix
// before
valuations=[{'date': '2024-01-01', 'value': 100}]
// after
valuations=[{'date': '2024-01-01', 'value': 100}, {'date': '2024-06-30', 'value': 108}] Defensive patterns
Strategy: validation
Validate before calling
valuations = json.loads(valuations) if isinstance(valuations, str) else valuations assert isinstance(valuations, list) and len(valuations) >= 2
Type guard
def is_valuations_array(v: object) -> bool:
return isinstance(v, list) and len(v) >= 2 and all(isinstance(i, dict) for i in v) Try / catch
try:
tool.execute(valuations=valuations)
except ValueError as e:
if 'at least two' in str(e):
raise UserInputError('provide >= 2 valuation points') Prevention
- Set minItems:2 and type:array in the tool schema
- Parse JSON strings before passing them as arrays
When it happens
Trigger: Calling execute with valuations=[{...}] (one point), a dict, a JSON string of an array, or omitting the argument.
Common situations: LLM emitting a bare object instead of an array; JSON-encoded strings passed unparsed; test fixtures with a single sample point.
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
- alpha_id and zoo are mutually exclusive
- valuations may contain at most {_MAX_VALUATIONS} entries
- valuations[{index}] must be an object with date and value
- invalid alpha_id
- alpha_id not found
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/4e5d36f0baff716f.
Report an issue: GitHub.