Demonstration

Inventory-to-Feed Integration: A Failure & Recovery Demo

By Michael E.Updated Sources checked

Short answer

This Agent Commerce Optimization demonstration simulates an ERP-to-store-to-product-feed inventory pipeline in your browser. You can inject webhook failures, delays, duplicates, and missed events, then watch exponential-backoff retries, idempotency keys, dead-letter replay, scheduled reconciliation, and checkout revalidation recover the system. It measures simulated freshness lag between a stock change and the feed showing it.

Key takeaways

  • Webhooks fail, arrive late, arrive twice, and arrive out of order, so the pipeline has to be safe under all four.
  • An idempotency key on every event makes retries and replays harmless, and a version number stops older updates from overwriting newer ones.
  • Reconciliation against the source of truth is the only thing that catches changes that never produced an event.
  • Checkout must revalidate stock against the source system. A feed is always somewhat behind.
  • We ran 16 automated checks on the simulation engine in this session, and all passed.

Can you show inventory reconciliation working?

Yes. The simulator below starts with three synthetic SKUs that agree across the ERP, the store, and the feed. To break sync, arm a fault and trigger a stock change, or choose a guided scenario. Then watch the audit trail as the system recovers. Bulk import to 0 (no event) followed by Run reconciliation shows drift being detected and repaired.

Simulated: synthetic SKUs, virtual clock

A deterministic in-browser simulation of an ERP → store → product-feed pipeline. Times are virtual milliseconds on a simulation clock, not measurements of any real system. No network calls are made, and this is not a client case study.

Sim clock00:00.0

Next feed batch in 15.0s · reconciliation in 120.0s
Stock per system for each synthetic SKU
SKUERP (truth)StoreFeed (agents see)Status
JKT-BLU-MRain jacket, blue M3 v13 v13 v1In sync
FUEL-230Fuel canister 230 g40 v140 v140 v1In sync
PAD-KITPad repair kit12 v112 v112 v1In sync
Source events
Inject failures (next event)

Arm a fault, then trigger a source event.

Recovery
Freshness lag p50 (simulated)
–
Freshness lag max (simulated)
–
Unpublished changes
0
In-flight deliveries
0
Retries
0
Duplicates ignored
0
Drift repaired
0
Checkouts blocked
0

Audit trail (newest first)

  1. 00:00.0erpSimulation started. ERP, store, and feed agree for all SKUs.

What happens when a product update fails?

Here, the dispatcher retries with exponential backoff. If every attempt fails, the event moves to a dead-letter queue, and the store keeps showing old stock until someone replays it or reconciliation repairs it. Meanwhile, checkout revalidation stops the stale number from turning into an oversold order.

Failure and recovery scenarios (tested 2026-11-29 with the simulation engine)
ScenarioFailure injectedRecovery mechanismObserved in testSimulated lag
Normal stock changeNoneWebhook applies, next feed batch publishesFeed shows new qty; all systems agree15.0 s
Webhook fails 3×HTTP 503 on attempts 1–3Retries after 1.03 s, 2.15 s, 4.03 s (backoff + jitter)3 retries, delivered once, converged15.0 s
Webhook delayed 20 sDelivery latency +20 sApplied on arrivalFeed caught up on the next batch after arrival30.0 s
Duplicate deliverySame event delivered twiceIdempotency key checkSecond copy ignored; stock decremented once (40 → 36)15.0 s
Retries exhaustedAll 5 attempts failDead-letter queue → operator replay from outbox5 failures, 1 dead letter, replay applied once30.0 s
Change with no eventBulk import bypasses the outboxReconciliation (ERP vs store)Drift detected and repaired (40 → 12)15.0 s
Agent checkout on stale stockWebhook down; feed shows 3, ERP has 0Checkout revalidation against ERPOrder blocked with STALE_STOCK before payment30.0 s
Out-of-order deliveryOlder event arrives after newerVersion checkOlder update ignored; final qty is the newest (9)15.0 s

We also checked these properties: a replay that arrives after reconciliation already repaired the SKU is ignored by the version check; all eight scenarios chained together produce an identical log on two runs (deterministic) and converge once the queues drain; and no stock level ever goes negative. The retry behavior is covered in more depth in our guide to inventory sync webhooks and retries.

How do you keep a product feed in sync with inventory?

Treat the source system as the truth, make every change an event with an identity and a version, deliver it in a way that is safe to repeat, and reconcile on a schedule for anything the events miss. This is the design the simulation implements:

Pipeline design (simulated)
  ERP (source of truth)
    │  stock change → row in OUTBOX (eventId, sku, qty, version)   ◄── replay log
    ▼
  Webhook dispatcher
    │  attempt 1 … 5   on 5xx: wait base·2^(n−1) + jitter   then → DEAD-LETTER
    ▼
  Store webhook handler
    │  1. eventId already processed?   → ignore (idempotency)
    │  2. event.version ≤ store.version? → ignore (out-of-order / stale)
    │  3. apply; mark SKU dirty
    ▼
  Feed publisher (batch every 15 s, simulated)
    │  dirty SKUs → product feed / agent channel     freshness lag = publish − ERP change
    ▼
  Product feed (what AI shopping surfaces read)

  Reconciliation job (every 120 s or on demand):  ERP vs store → repair drift → mark dirty
  Checkout revalidation:  agent order reads feed qty → re-check ERP before accepting
The two guards in the store handler (simplified from the demo engine)
// Store-side webhook handler: the two checks that make retries and replays safe
function applyToStore(ev: OutboxEvent) {
  if (processedKeys.has(ev.eventId)) return 'duplicate_ignored';   // idempotency key
  processedKeys.add(ev.eventId);
  const current = store[ev.sku];
  if (ev.version <= current.version) return 'stale_ignored';       // ordering guard
  store[ev.sku] = { qty: ev.qty, version: ev.version };
  dirtyForFeed.add(ev.sku);
  return 'applied';
}
Outbox
A table written in the same transaction as the stock change, so an event exists for every committed change. It also serves as the replay log.
Idempotency key
A unique id per event. The receiver records keys it has applied, so a retry or duplicate delivery has no further effect.
Version
A per-SKU counter that increases with every change. It lets the receiver reject an older update that arrives late.
Dead-letter queue
Where events go after their final retry fails. They are kept for inspection and replay instead of being dropped.
Reconciliation
A periodic comparison of the source of truth with downstream copies that repairs any difference, including changes that never produced an event.
Freshness lag
The time between a change in the source system and the change being visible in the feed that agents read.

Real platforms document the same failure modes. As of 2026-11-29, Shopify's webhook documentation says delivery isn't always guaranteed, recommends ignoring duplicates using the X-Shopify-Webhook-Id header, says ordering isn't guaranteed within a topic, and recommends reconciliation jobs. Stripe's API documentation describes idempotency keys for retrying requests without performing an operation twice. The demo applies those patterns to inventory, and the Next.js agentic commerce architecture guide shows where they sit in a headless stack.

How do you stop an AI agent from selling out-of-stock items?

Revalidate at checkout against the system that holds the real stock, and fail the order before payment if the number has changed. Feeds and caches will always lag a little, so they're fine for discovery but not for committing a sale.

In the Agent checkout on stale stock scenario, the jacket sells out in-store while the webhook is failing. The feed still says 3, so an agent could offer it, and the order would be accepted on the feed's word. Revalidation compares the request to the ERP's 0 and blocks it with STALE_STOCK. The same principle applies to the tool layer in our catalog shopping assistant demo, where prepare_cart re-checks stock rather than trusting earlier reads.

On the feed side, OpenAI's product feed specification (checked 2026-11-29) requires an availability value on every row, says to update it when an item becomes available or sells out, and notes that unknown does not mean in stock. A pipeline that can't confirm freshness should prefer an honest status over a stale "in stock".

What are the lessons for an inventory integration?

  1. Assume every delivery can repeat. Without idempotency, a retry policy creates double decrements. With it, retries are free.
  2. Order by version, not by arrival. A delayed update can be the oldest one, and arrival order tells you nothing.
  3. Write the event with the change. The drift scenario exists because one path (a bulk import) bypassed the outbox. Reconciliation catches it, but late.
  4. Keep dead letters and make replay a button. A replay needs to be safe to run twice, and the version check makes it safe even after a repair.
  5. Budget freshness explicitly. In this simulation, the batch interval caused most of the lag, more than the failures did. Measure your own lag before choosing an interval.
  6. Revalidate at the point of commitment. Discovery can tolerate a slightly stale feed. Checkout can't.

If your inventory lives in an ERP, WMS, or PIM that your storefront or feeds don't read directly, our inventory and pricing API integration service scopes this pipeline for your systems. Where agents need live stock through tools rather than a feed, it connects to MCP server development. See all demonstrations for other working artifacts.

Frequently asked questions

Is this based on a real client's system?

No. It's a simulation with synthetic SKUs and a virtual clock, built to demonstrate the design. No client data, results, or measurements are involved.

Are the freshness numbers real measurements?

They are measured inside the simulation, so they're real for the simulated settings: a 400 ms delivery latency, a 15-second feed batch, and 120-second reconciliation. They are not measurements of any platform. Your actual lag depends on your systems and on each destination's processing time.

Why use both webhooks and reconciliation?

Webhooks are fast but can be lost, delayed, or never produced, as when a bulk import skips the event path. Reconciliation is slower but compares the actual state, so it catches whatever the events missed. Together they give low lag most of the time and correctness eventually.

What does an idempotency key protect against?

It protects against the same event being applied twice, whether the cause is a retry after a timeout, a duplicate delivery from the sender, or an operator replay. The receiver records which keys it has processed and ignores repeats, so stock is decremented exactly once.

How long should retries continue before giving up?

Long enough to ride out typical outages, but bounded, so failures surface in a dead-letter queue that someone watches. The demo uses five attempts with doubling waits and jitter. In production, tune these to your endpoint's behavior and to any limits set by the platform you integrate with.

Does a fresh feed guarantee AI agents will show my products correctly?

No. Freshness only means the feed reflects your stock. Whether and how an AI surface shows a product depends on that platform's eligibility, processing, and ranking, none of which your feed controls.

Is your stock data drifting between systems?

Tell us where inventory and prices live today, which channels and feeds read them, and where they fall out of sync.

Sources

  1. Agent Commerce Optimization: inventory-sync simulation engine and test script (built and run 2026-11-29)
  2. Shopify Dev Docs: Webhooks — Duplicate deliveries (X-Shopify-Webhook-Id), no ordering guarantee, reconciliation jobs.
  3. Stripe API reference: Idempotent requests
  4. OpenAI Commerce: Product feed specification — Required availability field; unknown does not mean in stock.

Platform capabilities, eligibility, and specifications change. Sources were checked on 2026-11-29; confirm the current primary documentation before scoping an implementation. See our editorial policy and methodology.