@spfunctions/agent when your TypeScript app owns the agent loop and needs SimpleFunctions market context, strict tools, watch inputs, policy hooks, trace, replay, and guarded execution.
1. Install
2. Set keys
SF_API_KEY is for SimpleFunctions data and user-scoped reads. OPENROUTER_API_KEY is only needed for model-backed runs.
3. Run the first agent
4. Restrict tools and cost
canUseTool to shrink expensive searches, deny unexpected tickers, or require human confirmation before side effects.
5. Add watch inputs
6. Keep execution policy-gated
Live execution is not mounted by default. Use the low-levelSimpleFunctionsAgent with explicit side-effect, cost, venue, ticker/token, quantity, price, runtime, jurisdiction, and confirm-token guardrails when you need it.
Next steps
Agent SDK
Full Agent SDK surface and boundaries.
Agent market monitor cookbook
Build a read-only monitoring agent.
Agent trader loop cookbook
Combine quant gates, model notes, and execution policy.
Contract tools
Strict SDK and Agent tool manifest.