/api/agent/* is the agent loop surface: every endpoint is shaped for an LLM context window — fewer fields than the raw /api/public/* reads, with nextActions links so the agent can chain calls. Auth is optional; an authenticated request adds a portfolio overlay where supported.
The canonical loop is:
World snapshot
portfolio.positions, portfolio.exposureByCategory) and stamps each opportunity with alreadyPositioned, currentPositionSize, currentPositionDirection.
Query parameters
| Parameter | Type | Default | Notes |
|---|---|---|---|
format | markdown | json | markdown | Markdown is compact prose for agent context. JSON is structured. |
compact | true | false | false | Tighter payload — drops verbose narration. |
limit | int | implementation default | Cap on opportunity count. |
World delta
| Parameter | Type | Required | Notes |
|---|---|---|---|
since | string | yes | Relative duration (1h, 6h, 24h) or ISO-8601 timestamp. |
format | markdown | json | optional | Default markdown. |
- SimpleFunctions Index changes (
indexDelta) - New / dropped market movers (
movers.added,movers.dropped) - Position-level alerts when authenticated
- Resolutions or settlements that occurred in the window
Inspect a ticker
get_world_state (or any Kalshi ticker / Polymarket conditionId). The dossier returns a recommended action and pre-filled nextActions so the agent can chain into intent creation, alert setup, or related-market drill-down without composing URLs by hand.
Auth: none required for the core read. Authenticated callers see position-aware overlays.
Path parameters
| Parameter | Type | Notes |
|---|---|---|
ticker | string | Kalshi ticker (e.g. KXRATECUT-26DEC31) or Polymarket conditionId. |
| Parameter | Type | Default | Values | Notes |
|---|---|---|---|---|
format | string | json | json, markdown | json is structured; markdown is a human-readable dossier. |
contagion | string | true | true, false | Include cross-market contagion candidates. |
diff | string | true | true, false | Include the 24h price/indicator diff block. |
trend | string | true | true, false | Include the 7d trend block. |
suggestion.action is the agent-actionable primitive — five values:
| Value | Meaning |
|---|---|
consider_long | Buy the YES contract; the model thinks the implied probability is too low. |
consider_short | Sell or buy NO; the model thinks the implied probability is too high. |
wait | Setup is unclear; revisit on next loop. |
avoid | Don’t trade — low liquidity, settlement risk, or no edge. |
monitor | Worth tracking but not actionable now; subscribe to deltas. |
| Status | Body | Cause |
|---|---|---|
400 | { "error": "ticker required" } | Empty path segment. |
404 | { "error": "Market not found" } | Unknown ticker / conditionId. |
502 | { "error": "Upstream venue error" } | Kalshi or Polymarket upstream failure. |
Topic feed
fed_rates, ukraine).
Path parameters
| Parameter | Type | Notes |
|---|---|---|
topic | string | Topic slug. Use GET /api/public/glossary to list topics. |
| Parameter | Type | Default | Notes |
|---|---|---|---|
since | string | optional | Filter to events after this timestamp / duration. |
limit | int | 50 | Cap on returned items. |
format | string | markdown | markdown or json. |
Sub-path routing
sf world <path>:
world shape filtered to the matched scope.
Why /api/agent/* instead of /api/public/*
Same data, different shape:
/api/public/* | /api/agent/* |
|---|---|
| Raw JSON, full fields. | Compact, drops fields agents don’t read. |
No nextActions. | nextActions[] for chained calls. |
| One topic per endpoint. | Multi-topic in one call (world, delta, inspect). |
| Best for dashboards / data integrations. | Best for LLM-driven flows — saves tokens. |
Token budget guidance
For a 200k-context model running a long loop:- Boot:
get_world_state(full snapshot once) - Loop tick:
get_world_delta?since=1h(30-50 tokens) - Drill:
get_inspect_ticker/{ticker}only when scoring requires depth
sf agent command runs locally.
See also
World model guide
The agent loop pattern and example flows.
World state API
Full parameter list for the
/api/agent/world* family.Direct API access
Auth, base URLs, language examples.
MCP tools
get_world_state, inspect_ticker, get_world_delta over MCP.