HKUDS/Vibe-Trading · error · ValueError

flows must be an array of {date, amount, kind} objects

Error message

flows must be an array of {date, amount, kind} objects

What it means

Raised when inline flows is present but not a Python list. The tool requires flows to be an array of {date, amount, kind} objects; dicts, strings, or single objects are rejected so parsing stays unambiguous.

Source

Thrown at agent/src/tools/cashflow_analytics_tool.py:373

    currency = kwargs.get("currency")

    if path:
        columns = kwargs.get("flows_columns")
        if columns is not None and not isinstance(columns, dict):
            raise ValueError("flows_columns must be an object mapping field to column name")
        return load_cashflows(
            str(path),
            columns=columns,
            currency=currency,
            default_kind=kwargs.get("flows_default_kind"),
            date_format=kwargs.get("flows_date_format"),
            invert_sign=bool(kwargs.get("flows_invert_sign", False)),
        )

    if not inline:
        return None
    if not isinstance(inline, list):
        raise ValueError("flows must be an array of {date, amount, kind} objects")
    if len(inline) > _MAX_INLINE_FLOWS:
        raise ValueError(f"flows may contain at most {_MAX_INLINE_FLOWS} entries")

    records: list[CashFlow] = []
    for index, item in enumerate(inline):
        if not isinstance(item, dict):
            raise ValueError(f"flows[{index}] must be an object")
        row_currency = item.get("currency") or currency
        if not row_currency:
            raise ValueError(
                f"flows[{index}] has no currency and no top-level currency was "
                "given; currency is never defaulted"
            )
        try:
            records.append(
                CashFlow(
                    date=item["date"],
                    amount=item["amount"],

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Wrap single records in a list: flows=[flow]
  2. Ensure JSON payloads use an array for the flows key

Example fix

# before
flows=flow_dict
# after
flows=[flow_dict]
Defensive patterns

Strategy: type-guard

Validate before calling

if "flows" in kwargs and not isinstance(kwargs["flows"], list):
    kwargs["flows"] = [kwargs["flows"]] if isinstance(kwargs["flows"], dict) else kwargs["flows"]

Type guard

from typing import TypeGuard

def is_flow_list(v: object) -> TypeGuard[list[dict]]:
    return isinstance(v, list)

Prevention

When it happens

Trigger: execute(flows={"date": "2024-01-01", ...}) — a single flow object instead of a one-element list; flows="2024-01-01,100,inflow"; flows=(flow1,) tuple.

Common situations: Wrapping logic that assumes a single record; JSON where the flows key holds an object instead of an array; passing a generator/tuple from Python code.

Related errors


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