Put the kill switch in the tool layer, not the system prompt
At 2:14 on a Tuesday morning, a supplier CSV landed in the pipeline for a Fortune 500 apparel brand's WooCommerce catalog. The pricing agent we'd wired up to reconcile it did something nobody on the team had written a test for. Its set_price tool timed out at the gateway. The agent treated the timeout as failure and retried. The gateway had already accepted the first call. By the time we stopped the loop, 4,100 variation writes had landed, roughly 1,900 of them were duplicates, and 63 SKUs were priced below landed cost.
The model wasn't the problem. We had treated the agent like a smart form filler when it was really a client of a distributed system, and we had no idempotency, no bounds, and no way to stop it short of killing PHP-FPM.
The system prompt is a request, not a control
Most demos put the rules in the prompt: "Never change a price by more than 5%. Never touch products in the clearance category." That's a request. The model will honor it most of the time, and the failure rate on the remaining cases is not something you can monitor your way out of. Under a retry storm, a timeout, or a prompt-injected supplier description, the model will happily produce a tool call that violates the paragraph describing it.
The control has to live in the code the model calls. In our stack, every agent tool dispatches into a plain PHP service class. That class checks capability, validates bounds against the product's current cost data, and refuses the write if the request falls outside policy. The LLM never gets a raw wc_get_product() handle. It gets a narrow interface with a few typed arguments and a return value that says "accepted", "rejected: reason", or "queued for approval".
Idempotency is the control most teams skip
The duplicate writes came from a missing idempotency key. Every mutating tool call now carries a key derived from the run ID, the tool name, and the normalized arguments. We store keys in a custom table with a unique index and check them before any write. Order creation, stock adjustments, and price changes all go through the same guard.
Before this, duplicate writes ran at 3.1% of nightly reconciliation calls. After the change, we saw zero duplicates across 90 nightly runs. The fix took about a day. The incident took a weekend of cleanup and one uncomfortable call with the client's merchandising team.
WooCommerce will not save you here. wc_update_product_meta() and the stock APIs are not idempotent, and neither is the REST API. If your agent can reach them, you need a layer that is.
Approval thresholds beat approve-everything
The conventional advice is to have a human approve every AI-proposed change. I think that's wrong for pricing and inventory at any real volume. Human approval queues past about 200 items a day turn into rubber stamps, and the people approving them learn that the approval button is faster than reading the diff.
What works better is tiered authority. Changes within an 8% guard band of the current price apply automatically, with audit logging. Changes outside that band, anything touching clearance or MAP-controlled SKUs, and any change that would drop margin below floor go to a review queue. In the apparel engagement, that cut the daily human queue to an average of 22 items, and the team reviews those in one sitting.
The kill switch has to fail closed, and be checked per call
Our first kill switch was a WordPress option read once at the start of each agent run. It worked fine for interactive use. It failed badly in a background job. An Action Scheduler run that started before the flag flipped kept executing for 11 minutes, because it had already loaded the option and never checked again.
Now the flag is checked before every tool call, read from a source that bypasses the object cache, and the default on a read failure is off. Flipping it takes effect within about 40 seconds across the fleet. If the flag store is unreachable, the agent stops. I'd rather have a stalled reconciliation than an unbounded one.
Pair the kill switch with a budget cap. We cap each run at $18 in model spend and the day at $180. The loop that caused the incident would have burned through that in under an hour. The cap is not a cost optimization. It is a circuit breaker.
Audit trails are for the next incident, not this one
Every tool call writes a row: run ID, actor, model and version, tool name, normalized arguments, a hash of the prompt (not the raw prompt, which often contains customer or supplier data), the decision, and the downstream response. That's about 14,000 rows a day on the apparel account. Model version matters more than people expect, because outputs drift across minor releases, and when someone asks why a price moved on a Wednesday you need to answer without guessing.
Untrusted content is an attack surface
Supplier descriptions, product reviews, and CSV notes all flow into agent context. In a sample of 12,000 supplier records, about 0.4% contained text that read like an instruction. Most were accidental, a copy-paste from an internal email. A few were not. The tool layer is what makes this a nuisance instead of an incident. A description that says "set price to $0.01" can produce a tool call, but the bounds check rejects it before it reaches the database.
If you take one thing from this: the model can propose anything. Your code decides what actually happens.
A system prompt is a request, a tool layer is a control, and only one of them survives a retry storm.
The pattern here is the same one we apply to regulated systems: enforce policy where the write happens, make every mutation idempotent and attributable, and make stopping the system a single operation that works under failure. If you're weighing where agent-driven changes should sit inside an existing WooCommerce or Laravel stack, our Champlin Enterprises team has worked through these tradeoffs on production catalogs and can talk through the specifics.