HKUDS/Vibe-Trading · error · ValueError

{name} is too long ({len(value)} chars; max {_MAX_STRING_PAR

Error message

{name} is too long ({len(value)} chars; max {_MAX_STRING_PARAM_CHARS})

What it means

strategy_discovery_tool._coerce_opt_str enforces a maximum length (_MAX_STRING_PARAM_CHARS) on every string parameter to prevent oversized payloads from reaching downstream processing. Strings longer than the cap raise ValueError reporting actual length and the limit; this fires before stripping/truncation.

Source

Thrown at agent/src/tools/strategy_discovery_tool.py:103

    if isinstance(value, bool):
        raise ValueError(f"{name} must be a number, got {value!r}")
    try:
        result = float(value)
    except (TypeError, ValueError, OverflowError) as exc:
        raise ValueError(f"{name} must be a number, got {value!r}") from exc
    if result != result or result in (float("inf"), float("-inf")):
        raise ValueError(f"{name} must be a finite number, got {value!r}")
    return result


def _coerce_opt_str(value: Any, name: str) -> str | None:
    """Coerce an optional string parameter; blank/None become ``None``."""
    if value is None:
        return None
    if not isinstance(value, str):
        raise ValueError(f"{name} must be a string, got {value!r}")
    if len(value) > _MAX_STRING_PARAM_CHARS:
        raise ValueError(
            f"{name} is too long ({len(value)} chars; "
            f"max {_MAX_STRING_PARAM_CHARS})"
        )
    text = value.strip()
    return text or None


def _coerce_bool(value: Any, name: str, default: bool) -> bool:
    """Coerce a boolean parameter, tolerating common LLM string forms."""
    if value is None:
        return default
    if isinstance(value, bool):
        return value
    if isinstance(value, str):
        lowered = value.strip().lower()
        if lowered in {"true", "1", "yes"}:
            return True
        if lowered in {"false", "0", "no"}:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Shorten the string below the limit (check _MAX_STRING_PARAM_CHARS in strategy_discovery_tool.py for the exact cap)
  2. Move large payloads out of tool kwargs — pass a file path or reference ID instead of inline text
  3. Split the input across multiple calls if the API supports batching

Example fix

# before
tool.execute(notes=open('big_analysis.txt').read())
# after
tool.execute(notes=summary_text[:500])  # keep under _MAX_STRING_PARAM_CHARS
Defensive patterns

Strategy: validation

Validate before calling

from agent.src.tools.strategy_discovery_tool import _MAX_STRING_PARAM_CHARS
if value is not None and len(value) > _MAX_STRING_PARAM_CHARS:
    raise ValueError(f"{name} too long; write payload to a file and pass a path")
tool.execute(**{name: value})

Type guard

def within_str_limit(v, limit=_MAX_STRING_PARAM_CHARS) -> bool:
    return v is None or (isinstance(v, str) and len(v) <= limit)

Prevention

When it happens

Trigger: Passing a very long string (longer than _MAX_STRING_PARAM_CHARS, defined at module top) for any string kwarg, e.g. a multi-megabyte description, prompt, or concatenated ticker list.

Common situations: LLMs pasting entire documents into a filter/description field; concatenating thousands of symbols into one comma-separated string; log/history blobs accidentally forwarded as parameters.

Related errors


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