polybot

Operations

Risk controls for autonomous trading agents

You don't hope an autonomous agent respects risk limits. You enforce them. How polybot's risk service works, and the defence-in-depth design that keeps agents honest.

Published Apr 16, 2026


Every serious failure of “AI trading” in the public record has the same shape: the model did something unhinged, and the system had no gate to stop it. Not a model-quality problem. An architecture problem. polybot’s risk service is designed assuming the agent is adversarial — not because it is, but because that assumption produces better invariants.

Three layers

polybot enforces risk in three places:

  1. Pre-submission checks. Every Signal is validated against global and strategy-local limits before it becomes an order.
  2. In-flight monitoring. While orders are working, exposure is recalculated and limits re-checked on every fill.
  3. Post-fill invariants. Reconciliation runs on a schedule and triggers auto-halts if the on-venue state disagrees with the local model.

Layers 1 and 2 are preventive. Layer 3 is the tripwire.

Pre-submission checks

Before a signal becomes an order, the risk service validates:

CheckDefault
Per-market position cap (USD)$500
Per-category exposure cap$2,000
Per-venue exposure cap$5,000
Global net exposure cap$10,000
Per-strategy daily loss stop$300
Global daily loss stop$1,000
Cooldown after loss stop trigger24h
Max concurrent positions per strategy20
Max USD per single order$1,000

All of these are configurable. Defaults are conservative so new operators don’t blow up on day one.

polybot risk show
polybot risk set --per-market-usd 300 --global-net-usd 8000
polybot risk show --strategy momentum    # per-strategy overrides

The risk service subscribes to the signal stream via NNG. Strategies can’t bypass it — there is no direct path from strategy to executor.

In-flight monitoring

Orders can take seconds to fill on Polymarket (on-chain latency) and milliseconds on Kalshi. Between submission and fill, market conditions change. The in-flight monitor:

This is the reason polybot uses async services instead of a monolithic strategy runner — the risk service operates on a separate event loop and can always act on the exchange, regardless of what the strategy is doing.

Post-fill reconciliation

Every 60 seconds, the reconciler fetches canonical state from each venue (positions, balances) and diffs against the local model. Disagreements fall into three buckets:

Reconciliation is paranoid by design. A silent disagreement between your local position state and the venue’s state is how losses compound unnoticed.

Agent-specific controls

When the MCP server is enabled, two more gates kick in:

Approval gates on place_order

In live mode, the MCP place_order tool doesn’t submit directly. It creates an approval request, optionally routing through:

polybot mcp approve --threshold 100 --strategy ai_model --markets "politics"
polybot mcp audit approvals --pending

No pre-auth is transitive: if you approve $100 autos in ai_model, momentum doesn’t inherit it.

Token budgets

Agents that call LLM-backed tools can burn tokens. polybot’s risk service tracks token spend per MCP client and enforces per-day caps.

polybot mcp budget set --client claude --usd-per-day 5.00

Exceeded budget: tool calls from that client return a structured BudgetExceededError. No silent failures.

What polybot explicitly does not defend

Honest list:

Lessons from the design

If you’re building an autonomous agent platform — for trading or anything else — steal this layout. A single risk service, orthogonal to the strategy/agent logic, treating all actors (human, agent, automation) uniformly. That’s the shape.

Need an agent system built like this?

Cryptuon builds production AI agents, MCP integrations, and trading systems. polybot is our open-source showcase.