HKUDS/Vibe-Trading · error · ValueError

market exposes no CLOB outcome tokens

Error message

market exposes no CLOB outcome tokens

What it means

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.

Source

Thrown at agent/src/tools/prediction_market_tool.py:808

    Raises:
        ValueError: The id cannot be resolved to an outcome token.
        requests.RequestException: Propagated from the HTTP layer.
    """
    if _is_clob_token_id(identifier):
        return identifier, {"clob_token_id": identifier}

    if identifier.lower().startswith("0x"):
        payload = _get_json(f"{_CLOB_MARKETS_URL}/{identifier}", host_key=_CLOB_HOST_KEY)
        raw = _clob_market_to_gamma_shape(payload) if isinstance(payload, dict) else {}
    else:
        raw = _get_json(f"{_GAMMA_MARKETS_URL}/{identifier}", host_key=_GAMMA_HOST_KEY)
        if not isinstance(raw, dict):
            raise ValueError("unexpected market payload shape")

    names = [str(n) for n in _json_list(raw.get("outcomes"))]
    tokens = [str(t) for t in _json_list(raw.get("clobTokenIds"))]
    if not tokens:
        raise ValueError("market exposes no CLOB outcome tokens")

    index = 0
    if outcome is not None:
        matches = [i for i, n in enumerate(names) if n.lower() == outcome.lower()]
        if not matches:
            raise ValueError(f"outcome '{outcome}' not in {names}")
        index = matches[0]
    if index >= len(tokens):
        raise ValueError("outcome has no matching CLOB token")

    return tokens[index], {
        "market_id": str(raw.get("id")) if raw.get("id") is not None else None,
        "question": raw.get("question"),
        "condition_id": raw.get("conditionId"),
        "outcome": names[index] if index < len(names) else None,
        "clob_token_id": tokens[index],
    }

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Verify the market actually trades on the Polymarket CLOB (check its page for an active order book)
  2. Retry later if the market is new and tokens may not be deployed yet
  3. Inspect raw.get('clobTokenIds') in the payload to confirm the field is genuinely empty vs malformed
  4. Use a different market or outcome that exposes tokens
Defensive patterns

Strategy: try-catch

Type guard

def has_clob_tokens(raw: dict) -> bool:
    return bool(raw.get("clobTokenIds"))

Try / catch

try:
    token, meta = _resolve_history_token(identifier, outcome)
except ValueError as e:
    if "no CLOB outcome tokens" in str(e):
        return None  # market not tradeable on CLOB; skip gracefully

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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