Skip to main content

Overview

The AdvancedAgent is a baseline agent that performs evidence-based predictions by searching Google, scraping web content, and analyzing it with an LLM. It represents the most basic approach to making informed predictions.

Class: AdvancedAgent

A trading agent that combines web search, content scraping, and LLM analysis to generate probabilistic predictions.

Inheritance

Configuration Properties

int
default:"4"
Number of markets the agent will trade on per execution run

Methods

answer_binary_market

Generates a prediction for a binary market through a multi-step research process.
AgentMarket
The market to predict on
ProbabilisticAnswer | None
A probabilistic answer containing:
  • p_yes: Probability of the “yes” outcome (0.0 to 1.0)
  • confidence: Confidence in the prediction (0.0 to 1.0)
  • reasoning: “I asked Google and LLM to do it!”
Returns None if no research results are found or content cannot be scraped.

Prediction Workflow

The agent follows a systematic research process: Searches Google for content related to the market question:
  • Uses the Serper API for search results
  • Filters out Manifold Markets results to avoid copying answers
  • Returns None if no results are found

2. Web Scraping

Scrapes the top 5 search results:
  • Limits content to 10,000 characters per site
  • Converts web pages to markdown format
  • Returns None if no content can be extracted

3. LLM Analysis

Analyzes the scraped content using GPT-4o-mini:
  • Uses GPT-4o-mini with temperature 0.0 for consistent predictions
  • Provides current date context
  • Returns probability and confidence as float values

Helper Function: llm

Processes the research content and generates a prediction.
str
The market question to predict on
list[str]
List of scraped web content (markdown format)
tuple[float, float]
A tuple containing:
  • probability: Likelihood of the event occurring (0.0 to 1.0)
  • confidence: Confidence in the prediction (0.0 to 1.0)

LLM Configuration

  • Model: gpt-4o-mini
  • System Prompt: “You are professional prediction market trading agent.”
  • Temperature: 0.0 (deterministic)
  • Output Format: “probability confidence” (space-separated floats)

Usage Examples

Basic Deployment

Production Deployment

Custom Betting Strategy

Required API Keys

The AdvancedAgent requires the following API keys (configured via environment variables):
str
required
API key for Google search via Serper API
str
required
OpenAI API key for GPT-4o-mini model

Limitations

Content Filtering

  • Filters out Manifold Markets results to avoid copying existing predictions
  • You may want to filter other prediction market sites depending on your use case

Context Window

  • Truncates each scraped page to 10,000 characters
  • May miss important information at the end of long articles

Single LLM Call

  • Makes only one LLM call for prediction
  • No iterative refinement or multi-step reasoning

Error Handling

  • Returns None if search fails
  • Returns None if web scraping fails
  • No fallback mechanisms

Performance Considerations

Baseline Agent

This agent serves as a baseline for comparison:

Speed vs. Quality

  • Fast: Uses GPT-4o-mini (cheaper and faster)
  • Simple: Single-pass prediction without refinement
  • Basic: No advanced reasoning or multi-step analysis

Source Location