{"record":{"id":"2e2ed7997dd29b6b","repo":"HKUDS/Vibe-Trading","slug":"market-exposes-no-clob-outcome-tokens","errorCode":null,"errorMessage":"market exposes no CLOB outcome tokens","messagePattern":"market exposes no CLOB outcome tokens","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/prediction_market_tool.py","lineNumber":808,"sourceCode":"    Raises:\n        ValueError: The id cannot be resolved to an outcome token.\n        requests.RequestException: Propagated from the HTTP layer.\n    \"\"\"\n    if _is_clob_token_id(identifier):\n        return identifier, {\"clob_token_id\": identifier}\n\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","sourceCodeStart":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/prediction_market_tool.py#L790-L826","documentation":"Raised by prediction_market_tool._resolve_history_token when the resolved market object has an empty or missing clobTokenIds list. History is fetched per CLOB outcome token, so a market with no CLOB tokens (not yet deployed to the CLOB, or a negative/closed market migrated away) cannot serve trade history through this path.","triggerScenarios":"Looking up history for a brand-new market whose CLOB tokens haven't been minted/listed yet; a resolved/resolved-archived market whose clobTokenIds were cleared; a partially populated Gamma payload where the field exists but is empty.","commonSituations":"Scraping newly-created or draft markets; negative markets that never listed on the CLOB; relying on Gamma data for markets that only exist on another venue.","solutions":["Verify the market actually trades on the Polymarket CLOB (check its page for an active order book)","Retry later if the market is new and tokens may not be deployed yet","Inspect raw.get('clobTokenIds') in the payload to confirm the field is genuinely empty vs malformed","Use a different market or outcome that exposes tokens"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def has_clob_tokens(raw: dict) -> bool:\n    return bool(raw.get(\"clobTokenIds\"))","tryCatchPattern":"try:\n    token, meta = _resolve_history_token(identifier, outcome)\nexcept ValueError as e:\n    if \"no CLOB outcome tokens\" in str(e):\n        return None  # market not tradeable on CLOB; skip gracefully","preventionTips":["Filter markets to active/CLOB-listed status before requesting history","Treat missing clobTokenIds as 'not tradeable yet' and re-check later for new markets","Don't assume every Gamma market has CLOB tokens — resolved or negative markets may not"],"tags":["prediction-market","clob","market-data"],"backgroundTag":"empty-required-field","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}