Safety
This page is for the human who lets an agent trade, and for anyone reviewing that setup. It says what the venue enforces today and what the agent, or you, must still enforce.
The delegate-key pattern
Your master key never goes to an agent.
- Keep the master key offline.
hardbasis auth loginprints it once and stores only the delegate. - The agent runs on a
read,tradedelegate. A stolen delegate can lose you a position; it cannot move your balance off the venue. See Authentication. - Revoke a delegate with
hardbasis auth revoke(it needs your master key, by design) or from the web app.
Never withdraw from an agent key
An agent key never carries withdraw. hardbasis auth login --scopes warns when you add it, and the paper and co-pilot levels stop when they see it. Withdrawals are something you do, with your own key.
One exception to know about: a USDhb redemption currently needs the withdraw scope even though the sats never leave the venue. Do not grant withdraw to an agent to make redemptions work; redeem yourself.
Cancel-all-after discipline
Before any unattended loop, arm the dead-man switch and keep re-arming it:
hardbasis cancel-all-after create --timeout-ms 60000If the agent stops re-arming (crash, hang, lost network), the venue cancels every resting order when the timer runs out. hardbasis mcp --autopilot arms it at start, re-arms it every 30 s and disarms it on clean shutdown. The hardbasis-emergency-flatten skill is the manual stop: cancel every order, close every position reduce-only, revoke the key, in that order.
Dry-run first, retry with the same key
- Every write, funds and credential command takes
--dry-run(MCP:dryRun: true), which validates and prints the exact request without sending it. - Every non-GET request carries an idempotency key. A timeout on a write may mean it landed: retry only with the
--idempotency-keythe error names, never a fresh one.
The cli_* error codes
Route on code, never on the prose.
| code | exit | sent? | do |
|---|---|---|---|
cli_validation | 2 | no | fix the input |
cli_no_mainnet | 2 | no | stay on testnet |
cli_ack_required (MCP) | n/a | no | ask the human; retry with acknowledged: true only then |
cli_user_declined (MCP) | n/a | no | the human said no; do not retry unless they ask again |
cli_confirm_not_rendered (MCP) | n/a | no | the client answered without showing a prompt; tell the user, suggest --confirm ack |
cli_autopilot_requires_limits | 2 | no | run without --autopilot |
cli_network (timeout) | 3 | maybe | retry only with the named idempotencyKey |
API {code, error} | 1 | yes | look the code up in Errors |
What the venue enforces today, and what it does not
| Enforced by the venue today | The agent must enforce itself |
|---|---|
Key scopes: a read,trade key cannot withdraw or mint keys | Position size, order size and daily turnover per key (venue limits are planned, R-AP-10) |
| Margin, liquidation and the account's own risk limits | Which markets the agent may trade |
| Rate limits per key and per account (Rate limits) | When to stop: drawdown, loss, time of day |
cancel-all-after, once armed | Arming and re-arming cancel-all-after |
| Idempotency on every write | Using the same key on retry |
| A cap on live keys per account | Never asking for, storing or printing a master key |
The MCP gates (the agent's acknowledged and your confirm prompt) run inside the CLI on your machine, not at the venue. They protect you from an agent acting on its own say; they do not protect a key that has leaked, which is why the key's scope is the boundary that matters.