
AI Agent Workflow Exceeds 100-Unit ERP Limit Reaching 120 Due to Check-Then-Act Race Condition
A detailed case study demonstrates how an AI workflow authorized to order no more than 100 units of COMP-17 ended up creating 120 units across three suppliers. Each individual order of 40 units passed authorization checks returning ALLOW, yet the cumulative result violated the human-delegated mandate. The root cause was a classic check-then-act race condition where stateful permission tracking read the same initial balance concurrently before any updates occurred. Sequential stateful checks prevented the overrun, but concurrent execution allowed all three requests to read zero consumption and receive ALLOW. An improved design using PostgreSQL SELECT FOR UPDATE performs atomic reservation of the grant balance before calling the ERP system, ensuring only two orders succeed and the third is rejected with DENY_CAPACITY. The experiment used a deterministic planner without any LLM to isolate the authorization mechanism from model reasoning quality. Five key questions are provided for production deployments involving cumulative business limits delegated to agents.
HabrOct 17, 2026Translated from Russian



