Use the headless agent workflow when an external process needs SimpleFunctions market intelligence without opening the interactive terminal UI. There are two modes:Documentation Index
Fetch the complete documentation index at: https://docs.simplefunctions.dev/llms.txt
Use this file to discover all available pages before exploring further.
| Mode | Command | Who reasons? | Output | Use when |
|---|---|---|---|---|
| Plain one-shot | sf agent --plain --once "..." | SimpleFunctions agent | Plain text plus tool progress on stderr | You want one local agent run from cron, Claude Code, CI, or a script. |
| Headless tool server | sf agent --headless | Your external agent | NDJSON frames on stdin/stdout | Claude Code, Codex, or a custom harness wants to call SimpleFunctions tools itself. |
sf --plain, the copy-paste command you want is usually sf agent --plain. The --plain flag belongs to sf agent.
What it can do
The agent has the same market tools as the interactivesf agent session:
| Task | Useful commands or tools |
|---|---|
| Boot a market agent | sf status --json, sf doctor --agent --deep --json, sf me --json, sf brief --agent --json |
| Discover capabilities | sf describe --all --json, sf tools search "<task>" --json, sf tools plan "<task>" --json |
| Research a market | sf investigate "<topic>" --json, sf query "<question>" --json, sf inspect <ticker> --json |
| Work a thesis | sf thesis context <id> --json, sf thesis signal <id> "...", sf thesis evaluate <id> |
| Find opportunities | sf discover --quality --json, sf screen --json, sf edges --json, sf cross-venue --json --preset arb |
| Monitor state | sf world --delta --json --since 1h, sf feed --json --hours 6, sf portfolio history --json |
| Build audit trails | sf agent --record-trace <path>, sf agent --replay-trace <path>, sf trace receipt <path> |
--json commands for deterministic parsing. Use sf agent --plain --once when you want the SimpleFunctions agent to reason across those commands and return an analyst-style answer.
First run
Install and verify the local control plane:--once runs one turn and exits. --plain removes the TUI. --new avoids inheriting a stale local session. The --allow and --deny lists are enforced before tool execution.
Plain mode from cron
This pattern is useful for hourly thesis review or morning portfolio briefs:--record-trace for audit and regression replay:
Headless NDJSON server
Usesf agent --headless when your own LLM loop should decide which SimpleFunctions tool to call. In this mode SimpleFunctions does not run its own LLM loop; it exposes tools over newline-delimited JSON.
Start the server:
ready frame:
| Frame | Direction | Purpose |
|---|---|---|
ready | sf to host | Manifest loaded. Contains policy and callable tools. |
call | host to sf | Invoke { id, tool, params }. |
result | sf to host | Tool output for the call id. |
error | sf to host | Tool error for the call id. |
wake | sf to host | A scheduled wake fired and the host should process it. |
done | host to sf | Close the headless process. |
Minimal Node harness
Claude Code with sf agent --plain
Claude Code can run non-interactively with claude -p, the current programmatic CLI mode documented by Anthropic. That makes it a good host for SimpleFunctions CLI calls: Claude Code handles repository context and shell orchestration, while SimpleFunctions handles prediction-market tools and thesis state.
Use a narrow Bash-only prompt:
Claude Code with the NDJSON server
For a tighter integration, have Claude Code write or run a small harness that startssf agent --headless, reads the ready manifest, and sends only approved call frames.
Example prompt:
-p mode supports structured output with --output-format json and streaming with --output-format stream-json. Use that for the outer automation layer; use sf agent --headless NDJSON for the SimpleFunctions tool layer.
Safety model
Default automation policy:write only when the automation is allowed to mutate SimpleFunctions state, such as injecting a thesis signal or creating a watchlist item. Do not add trade or runtime to unattended Claude Code, cron, or CI jobs.
For execution workflows:
- Read first:
sf me portfolio --json,sf intent list --json,sf runtime status --json. - Propose the action in text.
- Ask a human to approve.
- Prefer
sf intent buy/sf intent sellover directsf buy/sf sell. - Record the run with
--record-trace.
Related docs
Agentic CLI
Full CLI control plane, permission categories, trace and replay.
Thesis lifecycle
Create, signal, evaluate, augment, heartbeat, and publish a thesis.
Agent runtime
Long-running execution daemon, intents, and cloud runtime.
Claude Code programmatic mode
Anthropic reference for
claude -p, JSON output, and scripted runs.