Agentic tradingRiskGuardrails

How to evaluate guardrails for a trading agent step by step

Learn how to evaluate trading agent guardrails step by step, including what to check for scoped keys, spend limits, kill switches, and non-custodial protections.

By the Felix team10 min read
Key takeaways
  • 01Guardrails must be layered so that a single failure, whether a bug, leak, or hallucination, cannot bypass every control at once.
  • 02Non-custodial architecture means the agent can trade but never withdraw funds, and you should verify this by inspecting the key permissions directly.
  • 03Every limit you care about must be enforced by the trading infrastructure, not by the agent's own code or its prompt.
  • 04A kill switch is only effective if it flattens positions, cancels pending orders, and revokes the key without relying on the agent to cooperate.
  • 05Trading can lose money, including everything, so the purpose of guardrails is to bound the maximum loss to the limits you set and tested in advance.

Guardrails are the set of technical and policy controls that keep an autonomous trading agent within boundaries you set before it touches live capital. Evaluating them means inspecting each layer, from wallet permissions to order limits, to confirm that a bug, a bad prompt, or a sudden market move cannot cause unplanned losses. Safety comes from overlapping layers that each fail in a different way, so that no single point of failure can expose your entire account. The following steps give you a concrete way to inspect those layers before you authorize the agent to trade with real money.

What should guardrails actually prevent?

Guardrails exist to handle three broad categories of failure: agent error, infrastructure failure, and market disorder. Agent error includes model hallucinations that generate invalid orders, logic bugs that misprice entries, or prompt injection that tries to override your instructions. Infrastructure failure covers API downtime, stale data, or a key leak that lets someone else send commands on your behalf. Market disorder means flash crashes, liquidity gaps, or sudden volatility that could turn a small position into a large loss before any human notices.

A good guardrail system does not try to predict every possible failure. Instead, it limits the maximum damage any single failure can cause. That means capping the total capital at risk, restricting the types of instruments the agent can touch, and ensuring the owner can halt everything without asking the agent for permission. When you evaluate a system, you should map each claimed safety feature to one of these three failure categories. If a feature does not address a specific failure mode, it is probably marketing, not architecture. Ask the provider, or inspect the code and permissions, to see which failure mode each control is meant to stop. If you cannot get a clear answer, the control is not a guardrail. It is a suggestion.

How do you verify the non-custodial setup?

Non-custodial design means the trading agent never holds your funds in an account it controls. Your capital stays in a wallet or brokerage account that you own, and the agent receives only a scoped key that authorizes trading within limits. The agent should be able to place orders, modify open positions, and read balances, but it should not be able to withdraw funds to an external address or change the approved withdrawal destinations.

To verify this, inspect the permission model at the key level. If the API key can initiate a withdrawal, even to a pre-approved address, the setup is not truly non-custodial for trading purposes. The withdrawal whitelist should be controlled by you directly through the wallet or broker interface, not by the agent's key. You should also confirm that the key cannot revoke or modify its own permissions. If the agent can escalate its access, a compromised model or leaked credential can empty the account.

Test this by reviewing the key permissions in the dashboard or on-chain. If the interface shows a withdrawal permission attached to the agent's key, remove it before funding the account. If the system does not allow you to remove that permission while keeping trading active, the architecture is custodial by default. This layer is foundational. If the agent can take money out, no other guardrail matters, because the worst-case loss is the entire balance.

How do scoped keys limit the agent's surface area?

Scoped keys are the primary mechanism for enforcing least privilege. Instead of giving the agent a master key to your entire portfolio, you issue a key that is restricted by instrument type, market, maximum order size, and maximum position size. For example, you might scope a key so it can only trade stocks on a specific broker, or only crypto perps on a specific venue, with a per-order cap of one thousand dollars and a total position cap of five thousand dollars.

When evaluating scoped keys, ask what happens if the key is leaked. A properly scoped key should be useless to an attacker outside the allowed markets and size limits. You should also check whether the scope is enforced by the trading infrastructure itself or merely checked by the agent's own code. If the agent is responsible for rejecting oversized orders, a bug or a malicious prompt can bypass the check. The enforcement must happen at the API or contract level, where the agent cannot override it.

You should also verify that the scope includes read versus write permissions. The agent may need read access to market data and balances, but it should not need permission to change account settings, add sub-accounts, or generate new keys. Each extra permission is an attack surface. If the platform allows you to restrict the key to a single IP address or a single MCP session, enable that restriction. It adds another layer that limits the blast radius of a leaked credential. You can read more about designing these permissions in Scoped API Keys for Trading Agents.

How do spend caps and drawdown limits protect capital?

Spend caps and drawdown limits are the quantitative boundaries that translate your risk tolerance into hard numbers. A spend cap is a ceiling on the total notional value the agent can deploy over a given period, such as a day or a week. A drawdown limit is a threshold on unrealized losses, either per position or across the entire agent portfolio, that triggers an automatic flattening or a trading halt.

When you evaluate these controls, look for two properties: granularity and enforcement. Granularity means you can set different caps for different markets. An agent trading options might need a tighter cap than one trading stocks because of leverage and time decay. An agent trading prediction markets might need a different cap structure entirely because of binary payouts and expiration dates. Enforcement means the system stops the agent from opening new orders once the cap is hit, even if the model insists the next trade is a high-probability opportunity.

You should also check whether the drawdown limit is calculated in real time or batched. A batched calculation, even with a short interval, can miss a fast move. Real-time enforcement uses the current mark price to check the limit before every order. If the system only checks drawdown once per minute, a volatile market can breach your limit before the check runs. Test this during paper trading by imagining a scenario where the market drops ten percent in seconds. Does the system block the next order before it reaches the venue? For a deeper look at setting these values, see How to set spend caps and drawdown limits for trading agents.

What should a kill switch do under pressure?

A kill switch is an emergency control that lets you or an automated monitor halt the agent and flatten its positions immediately. Evaluating a kill switch means understanding both the trigger and the mechanical effect. The trigger can be manual, a dead man's switch, or an automated rule that fires when a metric breaches a threshold. The mechanical effect should be a forced revocation of the agent's key and a market order to close all open positions.

You should test whether the kill switch works when the agent is mid-order. If the agent has a pending order that has not yet filled, the kill switch should cancel that order before attempting to flatten. If the system tries to flatten without canceling open orders, you can end up with unintended new positions after the switch is thrown. You should also verify that the kill switch does not depend on the agent's cooperation. If the agent must acknowledge the command, a frozen process or a runaway loop will ignore it. The revocation must happen at the infrastructure level, below the agent.

Another detail to check is whether the kill switch leaves you with residual risk. Flattening into a thin market can cause slippage, but that is a known cost of an emergency exit. What you want to avoid is a switch that only halts new orders while leaving existing positions open. That is a pause button, not a kill switch. The true kill switch brings your exposure to zero and invalidates the key so the agent cannot restart on its own. For the mechanics of this layer, read How kill switches work from first principles for trading agents.

How do you confirm that limits are enforced by the system, not the agent?

This is the most critical distinction in guardrail evaluation. Soft limits live in the agent's prompt or internal logic. Hard limits live in the trading infrastructure, the API gateway, or the smart contract. A soft limit can be bypassed by a model that misinterprets the prompt, a jailbreak attempt, or a simple coding error. A hard limit returns an error when the agent tries to violate it, regardless of the agent's intent.

To confirm this, you should attempt to violate the limit intentionally during paper trading. Suppose you set a per-order cap of five hundred dollars. Try to send an order for five hundred and one dollars through the API. If the system accepts it, the limit is soft. If the system rejects it with a clear error, the limit is hard. You should perform this test for every limit you care about: position size, daily spend, allowed markets, and leverage. If any limit is enforced only by the agent's own code, treat it as unenforced.

You should also inspect the error messages. A hard limit should return a deterministic error that your monitoring can catch. If the system silently truncates the order to fit the limit, that is better than accepting it, but it is still a form of soft enforcement because the agent did not get a clear rejection. The ideal behavior is a flat error: order refused, no partial fill, no truncation. This gives you confidence that the boundary is real. You can find a full audit framework in How to audit your trading agent guardrails before going live.

What is a practical pre-flight checklist?

Before you move from paper trading to live capital, run through a checklist that covers each layer.

  1. 01Verify that the key cannot withdraw funds and cannot modify its own permissions.
  2. 02Confirm that every scope restriction is hard enforced by the infrastructure, not by the agent.
  3. 03Set and test spend caps and drawdown limits for each market type you plan to trade.
  4. 04Trigger the kill switch during paper trading and measure how long it takes to flatten and revoke.
  5. 05Set up independent monitoring that alerts you when the agent places an order, so you can catch anomalies even if the automated limits fail.

You should also document the failure modes you are willing to accept. No system prevents all losses. Trading can lose money, including everything. The goal of guardrails is to make sure that if the worst happens, the loss is bounded by the limits you chose in advance. Keep the checklist in a place you can reference after you go live, because guardrails can drift. API updates, key rotations, and new market integrations can all change the permission landscape. Re-audit quarterly or after any infrastructure change. If you add a new market, such as prediction markets or options, treat it as a full re-evaluation because the risk profile and margin rules differ from stocks or crypto.

Frequently asked questions

Can I rely on the agent's prompt to enforce risk limits?

No. Prompts are soft limits that a model can misinterpret, ignore, or bypass through coding errors or prompt injection. Hard limits must be enforced by the trading infrastructure or API layer below the agent.

How do I test a kill switch without causing real losses?

Use the paper trading environment to trigger the switch while the agent holds open positions. Measure whether the system cancels pending orders, flattens exposure, and revokes the key without requiring the agent to respond.

What is the difference between a spend cap and a drawdown limit?

A spend cap limits the total notional value the agent can deploy over a period. A drawdown limit triggers a halt when unrealized losses reach a threshold you define, regardless of how much capital was deployed.

Should I re-audit guardrails after updating the agent's strategy?

Yes. Any change to markets, leverage, or position sizing can invalidate previous assumptions. Treat strategy updates as a reason to re-run your full checklist and confirm that hard limits still match the new risk profile.

Is non-custodial design enough to protect my funds?

No. Non-custodial design prevents the agent from withdrawing funds, but it does not prevent bad trades or oversized positions within the account. You still need scoped keys, spend caps, and kill switches to limit trading risk.

Can one API really control stocks, crypto, perps, options, and prediction markets safely?

Yes, if the API enforces hard limits per market and normalizes order sizing in plain dollars. The safety comes from the infrastructure layer, not from the variety of markets, so you must scope and cap each market independently.

Give your agent a key.

One key to trade stocks, crypto, perps, options, and prediction markets. Live after owner authorization.

Keep reading

Not a brokerage, exchange, or investment adviser. Not investment advice. Trading involves risk, including total loss.