Skip to main content

Overview

PredictionMarket lets agents bet on candidate answers instead of voting on them or debating them. Each agent first solves independently. Equal answers are grouped, and those reached by at least min_attempts attempts become tradable assets whose opening prices follow how many attempts reached them. Each agent then reads one solution per answer, bets chips without seeing the others, and may trade once more after seeing the updated prices. The answer with the highest closing price wins. An answer few attempts reached is cheap, so a correct minority answer pays more than a popular one and following the majority pays little. That is the whole incentive: the market rewards being right when the others are wrong. Based on Betting Against the Majority: Multi-Agent Prediction Market Reduces Conformity by Justin Chih-Yao Chen, Zaid Khan, Joykirat Singh, Runchu Tian, Hyunji Lee, Elias Stengel-Eskin and Mohit Bansal (2026).

Installation

Architecture

Key Concepts

  • Attempts: Independent solutions from agents worth attempts_per_agent each. Every attempt ends with a final_answer.
  • Listed answers: Answers reached at least min_attempts times. When only one is listed, it is returned directly without opening a market. When none reaches min_attempts, every answer is listed.
  • LMSR market maker: Prices follow price / total where each price is exp(q / b). liquidity (b, default 10) controls how much a chip moves the price.
  • Chips: Every agent may spend chips_per_agent per round. Chips reset every run.
  • Structured outputs: Solving returns SolverOutput and trading returns TraderOutput through response_format. Set use_structured_outputs=False to read formatted lines instead.

Attributes

Optional[str]
default:"None"
Unique identifier for the market. When omitted, one is generated as prediction-market-<32 hex characters>.
str
default:"PredictionMarket"
Name of the market.
str
Description of the market.
List[Agent]
required
The agents that solve and trade. Each needs a unique agent_name.
int
default:"3"
Independent solutions each agent writes before trading.
int
default:"2"
Fewest attempts an answer needs to be listed. When no answer reaches it, every answer is listed.
float
default:"10.0"
Chips each agent may spend in one trading round.
float
default:"10.0"
The market maker liquidity parameter b. A larger value makes prices move less per chip.
int
default:"2"
1 for a sealed round only, or 2 to let agents trade again after seeing the prices. The second round runs only when first choices differ.
int
default:"2000"
Longest solution shown to a trader. Longer solutions are truncated.
Callable[[str], str]
default:"normalize_answer"
Maps an answer to the grouping key. The default unwraps boxed answers, drops markup and a trailing period, collapses whitespace, and lowercases.
Optional[int]
default:"None"
Seed for shuffling, for repeatable runs.
bool
default:"False"
When True, each run writes the conversation to the workspace directory.
bool
default:"False"
Whether to enable verbose logging.
OutputType
default:"dict"
How run formats the conversation, for example "dict", "list", "str", or "final".
bool
default:"True"
Ask for SolverOutput while solving and TraderOutput while trading through response_format. When False, the market reads FINAL ANSWER, BELIEF and BUY lines instead.
The constructor raises ValueError for empty agents, out-of-range settings, or repeated agent names. When use_structured_outputs is True, it also rejects agents with max_loops="auto", which structured outputs do not support. Give agents a number or set use_structured_outputs=False. The market also restores each agent’s original output_schema when a run ends.

Methods

run()

Open a market on the task and return the winning answer.
Parameters:
  • task (str): The question to answer.
  • img (Optional[str]): Image sent to every agent with the task.
  • possible_answers (Optional[List[str]]): Known options to trade on. Without them the market lists only answers reached by several attempts. With them the market lists these strings, using attempt counts for opening prices.
  • solve_attempts (bool): Solve before trading when True. When False with possible_answers set, trade on the list directly without solving.
Returns: The conversation formatted according to output_type. Its last message holds the winning answer and the closing prices. Raises:
  • RuntimeError: If no attempt produced a final answer and no possible_answers were given.
  • ValueError: If possible_answers is empty or duplicated, or if solving is off without possible_answers.
Every agent is reset before each call, so it must carry the system prompt and settings it should always use. When possible_answers is given but solving produces no matching attempts, the market still opens on the list instead of raising. The structured outcome is kept on market.result as a MarketResult with winner, market_opened, attempt_counts, opening_prices, closing_prices, trades, and beliefs.

batch_run()

Run one market per task, one after another. possible_answers and solve_attempts are shared by every market.

usage

Provider token usage summed over every agent in the market, with input_tokens, output_tokens, cached_tokens, reasoning_tokens, and total_tokens.

Examples

Market on an open-ended question

Market on a known list with search tools

Source Code

View the source code on GitHub