豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Add cookbook: Building World-Aware Agents with Prediction Market Data#2577

Open
patrickliu0077 wants to merge 3 commits intoopenai:mainfrom
patrickliu0077:feat/world-aware-agents
Open

Add cookbook: Building World-Aware Agents with Prediction Market Data#2577
patrickliu0077 wants to merge 3 commits intoopenai:mainfrom
patrickliu0077:feat/world-aware-agents

Conversation

@patrickliu0077
Copy link
Copy Markdown

Summary

Adds a cookbook showing how to build agents that have real-time world awareness using calibrated prediction market data. The cookbook uses the OpenAI Agents SDK and demonstrates:

  1. Dynamic instructions — agent fetches fresh world state (~800 tokens) before each run
  2. Depth tools — focused topic drilling (?focus=energy,geo) and incremental updates (/delta?since=1h for ~30-50 tokens)
  3. Multi-agent consistency — shared world context so all agents cite the same probabilities

The data source (SimpleFunctions) aggregates 9,706 prediction market contracts from Kalshi (CFTC-regulated) and Polymarket into a markdown snapshot optimized for LLM context windows. No API key needed — the endpoint is free and public.

Motivation

A recurring problem in agent development: LLMs have a knowledge cutoff and don't know what's happening today. Web search returns narratives ("tensions remain elevated"), not data. This cookbook shows a different approach — injecting calibrated probabilities backed by real money into the agent's context.

The prediction market insight: a price of 53c on "Iran invasion" encodes the aggregate judgment of everyone with money at risk on that question. This is fundamentally more useful for agent reasoning than news headlines or search results.

Checklist

  • I've added an entry to registry.yaml
  • I've added an entry to authors.yaml
  • I've included a requirements.txt

Self-review

  • Relevance: 4 — Uses OpenAI Agents SDK (function_tool, Agent, Runner, handoffs)
  • Uniqueness: 4 — No existing cookbook covers real-time world state injection for agents
  • Spelling/Grammar: 4
  • Clarity: 4 — Step-by-step with runnable code
  • Correctness: 4 — All code cells execute (endpoints are live and public)
  • Completeness: 4 — Covers single agent, tools, and multi-agent patterns

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 804fd34feb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

"researcher = Agent(\n",
" name=\"researcher\",\n",
" instructions=SHARED_CONTEXT + \"\\nYou are a macro researcher. Analyze geopolitical and economic developments. Hand off to the risk analyst when you identify concerning data.\",\n",
" handoffs=[\"risk_analyst\"],\n",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use Agent objects in handoffs

The multi-agent example configures handoffs with a string name ("risk_analyst") instead of an Agent/handoff object, so the handoff target is not actually wired into the SDK graph. In practice this breaks the intended transfer behavior (and can raise a validation/runtime error when Runner.run_sync executes), so the cookbook’s core “shared multi-agent” pattern will fail for readers following it verbatim.

Useful? React with 👍 / 👎.

patrickliu0077 and others added 2 commits April 2, 2026 13:34
The multi-agent example referenced risk_analyst in researcher's handoffs
before it was defined, causing a NameError. Reordered the agent
definitions so risk_analyst is created first.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@patrickliu0077
Copy link
Copy Markdown
Author

Hi — the handoff issue flagged by the automated review has been fixed in the follow-up commits (Agent objects instead of string names, correct definition order). Everything should be in good shape now. Happy to address any other feedback. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant