How an AI Agent Can Reconcile Orders, Fills, and Positions
Practical guidance for AI trading agents to reconcile orders, fills, and positions, manage mismatches, handle timeouts, and enforce risk limits.
Produced with automation, then checked by deterministic quality rules and an independent source-grounded review before publication.
- 01Order‑submission and fill reports must be matched against the authoritative account state.
- 02Timeouts do not prove failure; agents should query the runtime status before assuming an outcome.
- 03Explicit error handling and durable mutation identifiers prevent duplicate trades.
- 04Owner‑signed limits and separate withdrawal authority protect against unintended capital loss.
- 05Regular reconciliation cycles reduce deviation caused by missed messages or stale market data.
An AI trading agent reconciles orders, fills, and positions by continuously comparing its internal ledger with the authoritative account state provided by the trading platform. Each order submission, fill notification, and position update is treated as a durable mutation that must be verified before the agent proceeds. When a discrepancy appears, the agent pauses, logs the issue, and alerts the owner for manual review. This disciplined approach prevents the agent from acting on incomplete or inaccurate information, which is essential for maintaining financial integrity.
Why is Reconciliation Critical?
Without reliable reconciliation, an agent may assume a trade succeeded when it actually failed, or vice‑versa, leading to unintended exposure. Market data can be delayed, out of sync, or contain gaps, and treating missing values as zero can cause the agent to over‑ or under‑estimate its position. Reconciliation also ensures that owner‑authorized limits on order size, daily notional, and loss thresholds are respected at every step. By anchoring decisions to the authoritative state, the agent reduces the risk of cascading errors that could deplete allocated capital.
In practice, reconciliation acts as a safety net for asynchronous events. For example, a fill may be reported on a websocket after the order request has already timed out. If the agent does not later verify the actual fill, it may submit a duplicate order, violating idempotency and potentially breaching limits. Regular reconciliation therefore safeguards against both network glitches and logical oversights.
How Does an Agent Detect a Mismatch?
- 01The agent records a unique identifier for each order request and the expected fill quantity.
- 02After a configurable wait, it queries the runtime status endpoint to retrieve the actual fill and position data.
- 03If the returned data does not match the recorded expectation, the agent flags a mismatch.
- 04The agent then checks for known error states such as timeout, network glitch, or data staleness before deciding to retry or pause.
The detection logic must be deterministic. The unique identifier, often a UUID, is stored alongside the intended trade parameters. When the status endpoint returns a snapshot, the agent compares the snapshot’s order list, fill amounts, and position balances against the stored expectations. Any deviation-whether a missing fill, an unexpected partial fill, or a position size that does not align with the sum of fills-triggers the mismatch workflow.
To avoid false positives, the agent also validates the freshness of market data. Each data point includes a source tag, timestamp, and any warning flags. If the timestamp is older than a predefined threshold, the agent treats the data as stale and postpones further actions until a fresh snapshot is obtained.
What Controls Reduce Reconciliation Risk?
- Owner‑signed limits that cap order size, daily notional, and daily loss provide a hard ceiling on exposure.
- Separate withdrawal authority ensures that a trade‑scoped key cannot move funds without explicit owner consent.
- An emergency stop can revoke the agent key, halting further activity while leaving existing positions untouched for owner review.
These controls are enforced by the platform’s runtime and cannot be overridden by the agent. Owner‑signed limits are encoded in policy fields that the platform checks on every order request. If a request would exceed a limit, the platform rejects it and returns a clear error code, which the agent must handle as a mismatch.
The separation of trade and withdrawal keys means that even if an agent were compromised, the attacker could not withdraw funds without the owner’s explicit signature. This architectural boundary is a core component of risk mitigation.
When Should the Agent Pause for Manual Review?
The agent should pause whenever it encounters an explicit error state, a persistent mismatch after a retry, or when a limit breach is detected. Pausing prevents the cascade of further trades that could amplify a mistake. The pause also gives the owner time to verify market data freshness and to confirm that any missing money is not silently treated as zero. For related context, see When Should an AI Trading Agent Pause After Repeated Errors?.
During a pause, the agent records the full context of the issue: the order identifier, the expected versus actual fill, the timestamp of the last status query, and any limit violation details. This log is presented to the owner through a dashboard or alert system, enabling a quick assessment and corrective action.
How to Implement Safe Retries Without Duplicating Trades?
Safe retries rely on durable mutation identifiers and idempotent order submission. Before retrying, the agent re‑queries the authoritative state to see if the original order was already filled. If a fill is present, the retry is aborted. If no fill exists, the agent may resend the order with a new identifier, ensuring the platform can distinguish it from the prior attempt.
The retry policy should include a back‑off strategy and a maximum number of attempts. After each attempt, the agent validates the state again. If after the final attempt the mismatch persists, the agent escalates to a manual pause. This approach prevents infinite loops and respects the owner‑defined limits on order frequency.
“A timeout is not proof of failure; always verify the final state before acting.”
Frequently asked questions
Treat the data as uncertain, pause new order submission, and request a fresh snapshot before proceeding.
No. An emergency stop revokes the calling key but does not automatically close positions; the owner must review and act separately.
Reconciliation should occur after every order event and on a regular interval (e.g., every few seconds) to catch asynchronous updates.
They define the maximum exposure the agent may take; any breach detected during reconciliation triggers a pause and owner alert.
See the article [How an AI Agent Should Respond When an Order Request Times Out](/blog/ai-agent-response-order-timeout).
Read the guide [How an AI Agent Can Verify Market Data Before Placing an Order](/blog/verify-market-data-ai-agent).
Sources and verification
Product claims in this article were checked against these first-party references. Runtime status remains authoritative for current availability.
- Felix documentationfirst party
- Felix machine referencefirst party
Build with Felix now.
Felix infrastructure is live through MCP and the API. The full trading app launches September 17.
When an order request times out, the outcome is uncertain. This article outlines a disciplined response process for AI agents, covering status checks, data validation, error handling, and safe recovery.
AI agents can automate the research and management of options strategies by integrating market data, applying risk controls, and handling execution nuances. This article explains the process, key considerations, and practical steps.