HKUDS/Vibe-Trading · error · ValueError
outcome has no matching CLOB token
Error message
outcome has no matching CLOB token
What it means
Raised by prediction_market_tool._resolve_history_token when the selected outcome index has no corresponding entry in the market's clobTokenIds list — the outcomes and clobTokenIds arrays are misaligned in length. Even a valid outcome name fails if the token array is shorter than the outcomes array.
Source
Thrown at agent/src/tools/prediction_market_tool.py:817
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],
}
def _fetch_history(
identifier: str, *, interval: str, outcome: str | None, max_points: int
) -> dict[str, Any]:
"""Fetch one outcome's implied-probability time series.
Args:
identifier: CLOB token id, condition id, or gamma market id.
interval: One of ``1h``, ``6h``, ``1d``, ``1w``, ``1m`` (one month) orView on GitHub (pinned to 80ffdda44c)
Solutions
- Select an earlier outcome (index < len(tokens)), typically 'Yes'/index 0, which is usually tokenized first
- Inspect both outcomes and clobTokenIds arrays for the market to see the misalignment
- Retry later if the market is still deploying tokens
- Report/skip the market — a misaligned payload is upstream data corruption, not caller error
Example fix
# before outcome='No' # market has 2 outcomes but only 1 clobTokenId # after outcome='Yes' # index 0 always within token range when any token exists
Defensive patterns
Strategy: fallback
Type guard
def outcome_has_token(index: int, tokens: list[str]) -> bool:
return 0 <= index < len(tokens) Try / catch
try:
token, meta = _resolve_history_token(identifier, outcome)
except ValueError as e:
if "no matching CLOB token" in str(e):
token, meta = _resolve_history_token(identifier, None) # fall back to index 0 Prevention
- Prefer index-0 outcomes ('Yes') which are almost always tokenized
- Check len(clobTokenIds) >= len(outcomes) before selecting a later outcome
- Treat misaligned markets as bad upstream data: skip and report rather than retry
When it happens
Trigger: A market whose outcomes list has more entries than clobTokenIds (e.g. 3 outcomes but 2 tokens), selecting any outcome at or beyond len(tokens); the default index 0 with a completely empty token list is caught earlier by the 'no CLOB outcome tokens' check, so this fires for partial misalignment.
Common situations: Markets mid-deployment where tokens are only partially created; Gamma payloads with optional/cleared token entries for some outcomes; schema drift between the two arrays.
Related errors
- market exposes no CLOB outcome tokens
- unexpected market payload shape
- outcome '{outcome}' not in {names}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/54542b7e03632ca8.
Report an issue: GitHub.