{"record":{"id":"8261bd99868a8ca5","repo":"HKUDS/Vibe-Trading","slug":"outcome-outcome-not-in-names","errorCode":null,"errorMessage":"outcome '{outcome}' not in {names}","messagePattern":"outcome '(.+?)' not in (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/prediction_market_tool.py","lineNumber":814,"sourceCode":"\n    if identifier.lower().startswith(\"0x\"):\n        payload = _get_json(f\"{_CLOB_MARKETS_URL}/{identifier}\", host_key=_CLOB_HOST_KEY)\n        raw = _clob_market_to_gamma_shape(payload) if isinstance(payload, dict) else {}\n    else:\n        raw = _get_json(f\"{_GAMMA_MARKETS_URL}/{identifier}\", host_key=_GAMMA_HOST_KEY)\n        if not isinstance(raw, dict):\n            raise ValueError(\"unexpected market payload shape\")\n\n    names = [str(n) for n in _json_list(raw.get(\"outcomes\"))]\n    tokens = [str(t) for t in _json_list(raw.get(\"clobTokenIds\"))]\n    if not tokens:\n        raise ValueError(\"market exposes no CLOB outcome tokens\")\n\n    index = 0\n    if outcome is not None:\n        matches = [i for i, n in enumerate(names) if n.lower() == outcome.lower()]\n        if not matches:\n            raise ValueError(f\"outcome '{outcome}' not in {names}\")\n        index = matches[0]\n    if index >= len(tokens):\n        raise ValueError(\"outcome has no matching CLOB token\")\n\n    return tokens[index], {\n        \"market_id\": str(raw.get(\"id\")) if raw.get(\"id\") is not None else None,\n        \"question\": raw.get(\"question\"),\n        \"condition_id\": raw.get(\"conditionId\"),\n        \"outcome\": names[index] if index < len(names) else None,\n        \"clob_token_id\": tokens[index],\n    }\n\n\ndef _fetch_history(\n    identifier: str, *, interval: str, outcome: str | None, max_points: int\n) -> dict[str, Any]:\n    \"\"\"Fetch one outcome's implied-probability time series.\n","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/prediction_market_tool.py#L796-L832","documentation":"Raised by prediction_market_tool._resolve_history_token when the caller passes an outcome name that doesn't case-insensitively match any entry in the market's outcomes list. The exact valid names are echoed in the message so the caller can retry with a correct one.","triggerScenarios":"Passing outcome='yes' when outcomes are ['Yes','No'] works (case-insensitive) but outcome='Y' or 'up' fails; passing an outcome to a multi-outcome market with different labels like ['Democrat','Republican','Other']; extra whitespace in the outcome string.","commonSituations":"LLM tool calls guessing outcome labels; users abbreviating outcome names; copy-paste adding trailing spaces; markets whose outcome vocabulary changed after a rewrite.","solutions":["Use one of the exact names listed in the error message, matching case-insensitively","Strip whitespace from the outcome string before passing it","For binary markets, use the canonical 'Yes'/'No' labels","Omit the outcome argument to default to index 0 (the first outcome)"],"exampleFix":"# before\noutcome='yea'\n\n# after\noutcome='yes'","handlingStrategy":"validation","validationCode":"names = [str(n) for n in market.get(\"outcomes\", [])]\noutcome = outcome.strip()\nif outcome.lower() not in {n.lower() for n in names}:\n    outcome = names[0]  # or raise with the valid options for the user","typeGuard":"def valid_outcome(outcome: str | None, names: list[str]) -> bool:\n    return outcome is None or outcome.strip().lower() in {n.lower() for n in names}","tryCatchPattern":"try:\n    token, meta = _resolve_history_token(identifier, outcome)\nexcept ValueError as e:\n    if \"not in\" in str(e):\n        valid = ast.literal_eval(e.message.split(\"not in \")[1])\n        outcome = valid[0]  # fall back to first outcome and retry","preventionTips":["Fetch the market's outcomes list first and present it as the allowed choices","Normalize outcome strings (strip whitespace, casefold) before passing","For binary markets always use the canonical 'Yes'/'No' labels"],"tags":["prediction-market","outcome","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}