{"record":{"id":"317b0d35e08ad31a","repo":"HKUDS/Vibe-Trading","slug":"name-is-too-long-len-value-chars-max-max","errorCode":null,"errorMessage":"{name} is too long ({len(value)} chars; max {_MAX_STRING_PARAM_CHARS})","messagePattern":"(.+?) is too long \\((.+?) chars; max (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/strategy_discovery_tool.py","lineNumber":103,"sourceCode":"    if isinstance(value, bool):\n        raise ValueError(f\"{name} must be a number, got {value!r}\")\n    try:\n        result = float(value)\n    except (TypeError, ValueError, OverflowError) as exc:\n        raise ValueError(f\"{name} must be a number, got {value!r}\") from exc\n    if result != result or result in (float(\"inf\"), float(\"-inf\")):\n        raise ValueError(f\"{name} must be a finite number, got {value!r}\")\n    return result\n\n\ndef _coerce_opt_str(value: Any, name: str) -> str | None:\n    \"\"\"Coerce an optional string parameter; blank/None become ``None``.\"\"\"\n    if value is None:\n        return None\n    if not isinstance(value, str):\n        raise ValueError(f\"{name} must be a string, got {value!r}\")\n    if len(value) > _MAX_STRING_PARAM_CHARS:\n        raise ValueError(\n            f\"{name} is too long ({len(value)} chars; \"\n            f\"max {_MAX_STRING_PARAM_CHARS})\"\n        )\n    text = value.strip()\n    return text or None\n\n\ndef _coerce_bool(value: Any, name: str, default: bool) -> bool:\n    \"\"\"Coerce a boolean parameter, tolerating common LLM string forms.\"\"\"\n    if value is None:\n        return default\n    if isinstance(value, bool):\n        return value\n    if isinstance(value, str):\n        lowered = value.strip().lower()\n        if lowered in {\"true\", \"1\", \"yes\"}:\n            return True\n        if lowered in {\"false\", \"0\", \"no\"}:","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/strategy_discovery_tool.py#L85-L121","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Shorten the string below the limit (check _MAX_STRING_PARAM_CHARS in strategy_discovery_tool.py for the exact cap)","Move large payloads out of tool kwargs — pass a file path or reference ID instead of inline text","Split the input across multiple calls if the API supports batching"],"exampleFix":"# before\ntool.execute(notes=open('big_analysis.txt').read())\n# after\ntool.execute(notes=summary_text[:500])  # keep under _MAX_STRING_PARAM_CHARS","handlingStrategy":"validation","validationCode":"from agent.src.tools.strategy_discovery_tool import _MAX_STRING_PARAM_CHARS\nif value is not None and len(value) > _MAX_STRING_PARAM_CHARS:\n    raise ValueError(f\"{name} too long; write payload to a file and pass a path\")\ntool.execute(**{name: value})","typeGuard":"def within_str_limit(v, limit=_MAX_STRING_PARAM_CHARS) -> bool:\n    return v is None or (isinstance(v, str) and len(v) <= limit)","tryCatchPattern":null,"preventionTips":["Cap free-text inputs at the UI/agent boundary","Pass file paths or IDs instead of inline large text"],"tags":["strategy-discovery","input-length","string-args","validation"],"backgroundTag":"input-too-long","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}