Skip to main content
boxmining
Menu

The Trade an AI Agent Must Refuse: Seven Safety Gates Before Execution

Michael GuMichael Gu
10 min read
Trading
Automated order track passing through a row of seven mechanical safety gates before a sealed execution chamber
Contents

Most trading demos focus on the moment a system says “buy.” A safer test starts with the opposite question: when must the system refuse?

An AI agent can assemble evidence, interpret a chart, and draft an order. It should not decide whether its own output complies with risk policy. “All checks passed” is text, not a control.

These gates belong in deterministic software between the agent and the signing interface. Each must receive defined inputs, return pass or reject, and log the reason. Missing required information means rejection.

This guide assumes you understand the basic architecture in What Is an AI Trading Agent?. For signal foundations, see our technical analysis library, bullish chart patterns, and bearish chart patterns.

Why refusal is a core trading skill

A trading strategy is not only an entry rule. It is a boundary around the situations in which the rule is valid. A textbook breakout may be irrelevant when the price feed is delayed, the spread has widened, the instrument is wrong, or the position is already over its limit.

Agents may process untrusted text. News, social posts, or market descriptions can contain indirect prompt injection: instructions that try to redirect the model. OWASP’s Excessive Agency guidance recommends minimizing functionality, permissions, and autonomy, requiring approval for high-impact actions, and enforcing authorization downstream.

These gates cannot promise safety or profitability. They limit preventable failures.

Gate 1: Data provenance and freshness

Question: Is the decision based on identifiable, timely, internally consistent data?

Every market input should include source, instrument, venue, timestamp, and units. The gate should reject a proposal when:

  • the latest price or order book is older than its configured maximum age;
  • sources disagree beyond a defined tolerance;
  • a candle is incomplete but the strategy requires a close;
  • the symbol, quote currency, contract type, or decimal precision is ambiguous;
  • required inputs are missing or came only from untrusted free-form text.

Freshness limits depend on the strategy. A five-minute-old source may be acceptable for a weekly research report and unusable for an order-book strategy. The limit must be configured in code, not improvised by the model.

Evidence to log: source IDs, retrieval times, raw-data hashes, derived values, and the freshness threshold applied.

Gate 2: Instrument and market-rule validity

Question: Does the system understand exactly what will be traded and how the outcome is determined?

For spot or derivatives, confirm venue, symbol, settlement asset, tick size, minimum size, leverage mode, expiry, and trading status. For prediction markets, archive the title, resolution criteria, end date, resolution source, and any edge-case wording.

A chart can be technically bullish while the proposed instrument is unsuitable. A prediction-market price can move sharply because traders interpret a clause differently. The agent should never infer settlement rules from a headline.

Polymarket’s current CLOB V2 overview describes offchain matching and onchain settlement of signed orders. That infrastructure explains how orders move; the individual market rules still define what a position means. This gate should reject closed, paused, expired, unsupported, or materially ambiguous markets.

Evidence to log: canonical market ID, versioned rule snapshot, venue status, contract metadata, and the exact rule checks passed.

Gate 3: Liquidity and executable price

Question: Can the proposed size plausibly trade within the allowed cost?

The last traded price is not necessarily available now. A pre-trade check should use the current order book to estimate average fill price, spread, market impact, and unfilled quantity. Reject the proposal when:

  • spread exceeds the configured limit;
  • available depth is insufficient;
  • expected slippage exceeds the limit;
  • the limit price is outside a sanity band;
  • price or size violates venue increments;
  • a market order is requested where only bounded limit orders are permitted.

Polymarket exposes public read endpoints for books, prices, and spreads, according to its authentication docs. Public access does not guarantee that a snapshot remains current while the order is being prepared, so the gate should re-check near execution.

Evidence to log: timestamped book, intended size, simulated fill, spread, slippage estimate, price band, and order expiry.

Gate 4: Portfolio exposure and loss state

Question: Is the trade permitted given the whole portfolio, not just this setup?

An individually small order can be dangerous when it increases a correlated position. The gate should calculate current balances, open orders, filled positions, leverage, concentration, and realized and unrealized losses from authoritative account data.

Reject when the trade would breach:

  • per-instrument or per-venue exposure;
  • correlated-theme exposure;
  • gross or net leverage;
  • daily or rolling loss limit;
  • maximum open-order count;
  • a post-loss cooldown or manual incident hold.

The model should not supply the account state it is being checked against. Pull it independently from the venue and internal ledger, then reconcile differences.

Evidence to log: pre-trade portfolio snapshot, pending orders, exposure calculation, applicable caps, and resulting headroom.

Gate 5: Position sizing and bounded downside

Question: Is the order size derived from an approved, deterministic rule?

“Small position” is not a sizing rule. Define the maximum notional, risk budget, and any stop or invalidation assumptions explicitly. If a stop is used in sizing, model slippage through the stop; do not assume the exit will occur at one exact price.

Prediction-market positions need a different view of downside: the full amount paid may be at risk. Leveraged crypto positions can lose quickly and may be liquidated. The gate should choose the smaller of strategy size, available risk budget, and hard account cap.

Reject zero, negative, non-finite, incorrectly rounded, or unexpectedly large values. Also reject any proposal whose computed size changes materially when recalculated from authoritative inputs.

Evidence to log: sizing formula, inputs, maximum loss assumption, rounded order size, and remaining risk budget.

Gate 6: Authorization and human approval

Question: Is this action within the agent’s granted authority, and has any required human approved the real payload?

Authority should be narrow: allowed venue, account, action, instrument, destination, network, order size, and time window. High-impact actions should require approval from an authenticated person or separate service.

The approval interface must display fields reconstructed from the transaction or order payload. Do not ask a user to approve an LLM-written summary that could omit a destination or show a different amount. OWASP’s Lies-in-the-Loop analysis explains how attacker-controlled context can manipulate human-approval dialogs.

Coinbase’s Policy Engine provides an example of policies that accept or reject wallet operations based on parameters such as destination, value, and network, with rejection when no rule matches. The exact service is optional; the external enforcement pattern is essential.

Evidence to log: policy version, authenticated actor, payload hash shown for approval, decision, timestamp, and expiry.

Gate 7: Signing, submission, and kill-switch health

Question: Can the system authorize and monitor this exact order without exceeding its operational limits?

Before signing, verify chain, verifying contract, nonce or replay protection, order expiry, destination, and credential state. EIP-712 makes structured signing possible but explicitly notes that replay protection is application-specific. A correct signature proves authorization by a key; it does not prove that the proposal passed legitimate risk review.

After submission, require a valid venue response and reconcile open, partial, filled, cancelled, or rejected state. Rate-limit retries and use idempotency where supported. A timeout must not trigger an unbounded second order.

The kill switch must live outside the model. It should be able to block new signing, revoke or disable credentials, cancel open orders, and alert an operator. “Agent, please stop trading” is not a kill switch.

Evidence to log: signed-payload hash, key identifier, venue response, order ID, fills, retries, cancellations, and kill-switch status.

Hypothetical refusal: a Polymarket headline trade

Hypothetical example—not a recommendation or claim of testing: An agent reads a viral post saying a political candidate has withdrawn. It proposes buying 2,000 shares in a related prediction market at 0.71.

  • Gate 1 rejects: the post is the only source, and its publication time cannot be verified.
  • Gate 2 rejects: the market resolves on formal nomination, not withdrawal reporting.
  • Gate 3 rejects: only 180 shares are offered near 0.71; the modeled average fill breaches the slippage cap.
  • Gate 4 rejects: the account already has correlated exposure to the same candidate.
  • Gate 5 rejects: the proposed amount exceeds the per-market cap.
  • Gate 6 rejects: political-event trades above the threshold require approval, and none exists.
  • Gate 7 never runs: no signing request should be created after an earlier rejection.

One rejection is enough. Logging all detected failures can improve diagnosis, but the system must not let the agent negotiate with a hard gate or keep rephrasing the same order until it passes.

A compact pre-execution checklist

  • All required data has approved provenance and is fresh.
  • Instrument, venue, rules, and trading status are unambiguous.
  • Current depth supports the size within spread and slippage limits.
  • Account state is reconciled and portfolio caps remain intact.
  • Size is deterministically calculated and downside is bounded.
  • Authority is valid; required approval covers the real payload.
  • Signing, submission, monitoring, and kill-switch services are healthy.

FINRA’s algorithmic-trading guidance and ESMA’s 2026 algorithmic-trading briefing are written for regulated firms, but their focus on governance, testing, supervision, and pre-trade controls reinforces the same point: controls must be engineered and reviewed, not inferred from a strategy’s good intentions.

Test the rejection path before the trading path

Test that prohibited orders cannot reach signing. Include stale timestamps, wrong symbols, ambiguous rules, empty books, extreme decimals, duplicated requests, conflicting account states, expired approvals, unavailable policy services, and revoked credentials.

Then read our wallet-permission guide to make sure a failure in the agent cannot bypass the gates by reaching a broader signing key.

The safest trade an AI agent makes may be the one it never submits. Refusal is not a fallback. It is a feature that deserves the same design attention as the signal.

AI trading safety gates FAQ

What is a safety gate for an AI trading agent?

A safety gate is a deterministic external control that checks a proposed trade against defined data, market, risk and authorization rules before it can reach signing or execution.

Should the AI model decide whether its own trade passes?

No. The model may propose an action, but separate software should fetch authoritative inputs, apply policy and return pass or reject without letting the model negotiate the rule.

What does fail closed mean in trading automation?

Fail closed means missing, stale, conflicting or unavailable required information causes rejection. A broken policy or data service must not default to allowing an order.

What are the seven pre-trade safety gates?

They cover data provenance, instrument validity, liquidity, portfolio exposure, position sizing, authorization and human approval, and the health of signing, submission and kill-switch systems.

Why is last traded price insufficient for execution?

The last price may no longer be available for the proposed size. The system must inspect current spread and depth, estimate average fill and slippage, and reject an order outside its limits.

Why must portfolio exposure come from an independent source?

An agent should not supply the account state used to approve its proposal. Venue data and an internal ledger should be reconciled independently to catch open orders, leverage and correlated exposure.

When should an AI trade require human approval?

Approval should be required for actions outside narrow automation limits, including higher notional, sensitive instruments, unusual destinations, new contracts or policy exceptions.

What should a trade approval screen display?

It should decode the real order or transaction payload and show account, instrument, side, price, size, destination, chain, contract and expiry—not rely on an AI-written summary.

What is a real kill switch?

A kill switch is an independently authenticated control that can block new signing, disable credentials, cancel open orders and alert an operator without the model's cooperation.

Do seven safety gates make AI trading safe or profitable?

No. They reduce specific preventable failures, but models, data, software, markets and controls can still fail together, and losses can exceed assumptions during gaps or liquidations.

Sources and further reading

Risk disclosure: Safety gates reduce specific operational risks but cannot make an AI system, trading strategy, exchange, wallet, or market safe or profitable. Models and data can fail simultaneously, controls can be misconfigured, and liquidations or market gaps may exceed planned losses. This article is general education, not investment, legal, tax, or security advice. Use simulation first, obtain qualified review for production systems, confirm jurisdictional restrictions, and never risk funds you cannot afford to lose.

Share

Found this useful?

Share it with someone who'd want to read it.

Related