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:- Reads your active intents from
GET /api/intents?status=.... - For each intent, checks the trigger — hard price/time triggers locally, soft NL conditions if
--smartis enabled. - Marks newly-firing intents
armed→triggered→executing. - Places the order on the configured venue using your local exchange keys.
- Tracks fills against the intent (
filledQuantity), retries partial fills on the next tick. - Writes structured status / errors to
~/.sf/runtime.log.
~/.sf/:
CLI
sf runtime start
Refuses to start if Kalshi credentials aren’t configured; the fix is
sf setup --enable-trading.
sf runtime stop
~/.sf/runtime.pid. Falls back to scanning for orphan runtime processes.
sf runtime status
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
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:
- 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. - Edge re-check before firing. Just before submitting the order, the runtime calls
inspect_tickeron the market and aborts if the suggestion has flipped toavoid. - Adaptive delay. Trades that look like they’d cross the spread are deferred until the spread is reasonable — implementation default is 8 cents.
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
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
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 doctorbefore going live to catch missing keys, time-skew, or a stale CLI. - Use
sf intent list --all --jsonto review what the runtime is watching before you start it in--smartmode (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
executionMode—dry-runevaluates everything but skips placing orders. Flip toliveonly when you’re satisfied with dry-run output.
Related
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.