Skip to main content
The runtime is the long-running process that watches active intents and executes authorized workflows. It is the bridge between an analyst writing intents (CLI / API / agent) and orders actually leaving for Kalshi or Polymarket. For automated execution, prefer intents + runtime over raw sf buy / sf sell. Intents are persisted, replayable, race-free, and reviewable before execution.

Two ways to run it

Quick start (local)

What runtime watches

Each tick (every 30 seconds) the runtime:
  1. Reads your active intents from GET /api/intents?status=....
  2. For each intent, checks the trigger — hard price/time triggers locally, soft NL conditions if --smart is enabled.
  3. Marks newly-firing intents armedtriggeredexecuting.
  4. Places the order on the configured venue using your local exchange keys.
  5. Tracks fills against the intent (filledQuantity), retries partial fills on the next tick.
  6. Writes structured status / errors to ~/.sf/runtime.log.
Runtime state files live under ~/.sf/:

CLI

sf runtime start

Refuses to start if Kalshi credentials aren’t configured; the fix is sf setup --enable-trading.

sf runtime stop

Sends SIGTERM to the PID in ~/.sf/runtime.pid. Falls back to scanning for orphan runtime processes.

sf runtime status

Returns daemon liveness, last tick timestamp, count of intents per status, and a recent error trail.

Intents

An intent is a persisted instruction to do something on a venue when a trigger fires. Create them with the CLI or the HTTP API.

Create an intent (CLI)

Trigger forms Soft conditions (--soft) are evaluated by the configured LLM on every tick when --smart is enabled. Examples:

List + cancel

Lifecycle

Intents API

Auth: required.

POST /api/intents

Required body fields Optional body fields Errors

GET /api/intents

PATCH / DELETE

PATCH updates status, softCondition, expireAt, or triggerParams. DELETE cancels.

Smart mode

--smart enables three behaviors:
  1. Soft-condition evaluation. Each tick, if any active intent has a softCondition, the runtime calls the LLM with current market context and the condition. Only fires the order if the LLM returns a clear positive.
  2. Edge re-check before firing. Just before submitting the order, the runtime calls inspect_ticker on the market and aborts if the suggestion has flipped to avoid.
  3. Adaptive delay. Trades that look like they’d cross the spread are deferred until the spread is reasonable — implementation default is 8 cents.
Smart mode costs LLM tokens; budget with sf agent --budget-usd ... and / or per-thesis monthlyBudgetUsd on heartbeat.

Risk gates

The runtime calls the same risk-gate engine as the autopilot tick. Before any order is placed it checks:
  • per-trade max notional
  • per-market exposure cap
  • daily loss circuit breaker
  • max open positions
  • minimum balance
  • per-tick max orders
A rejected order writes a structured risk_gate_fail reason to the intent and stops there — the intent stays armed for the next tick. See Risk gates.

Cloud runtime (BYOK)

The cloud runner gives you “always on” without keeping a laptop awake. Treat this as an advanced operator surface: start locally, verify dry-run behavior, then connect cloud credentials only when you are ready for unattended automation.

Enable

sf setup --cloud connects encrypted exchange credentials for the cloud runner. The API never returns plaintext credentials; rotate or revoke them from the CLI when access should change. The cloud runner uses the same intent + tick + risk-gate code paths as the local runtime. The only difference is the host.

One-shot remote exec

Used by sf --remote <command>. Sends a single CLI invocation to the cloud runner, returns a runId, and lets you stream or poll output. Auth: Authorization: Bearer sf_live_.... This is not a long-running daemon — for that, use sf runtime start --remote.

Events

Runtime emits webhook events when configured: Configure receivers via Webhooks.

Operational tips

  • Run sf doctor before going live to catch missing keys, time-skew, or a stale CLI.
  • Use sf intent list --all --json to review what the runtime is watching before you start it in --smart mode (smart-mode runs LLM calls).
  • Soft conditions are tokens; over-broad conditions on many intents accumulate cost. Prefer hard triggers when the rule is mechanical.
  • Cloud runner respects executionModedry-run evaluates everything but skips placing orders. Flip to live only when you’re satisfied with dry-run output.
sf agent is for reasoning + tool use. sf telegram is for human-in-the-loop. The runtime is the worker that closes the loop.

See also

Trade intents

The intent-object model in depth.

Risk gates

Pre-trade safety rails.

Portfolio autopilot

Cloud-run portfolio loop with BYOK credential connection.

Webhooks

Signed delivery for runtime events.