EnterpriseSim: PostgreSQL Multi-Hazard Gym for Transactional Agents

EnterpriseSim (arXiv:2612.01881) is an open-source PostgreSQL gym of 83 tasks (53 multi-hazard) across six enterprise departments. Across 3,619 episodes, unguided 55-tool consoles and live background contention drop frontier models by 10–30 percentage points, while a pre-PostgreSQL commit gate blocks all single-agent unsafe writes at 0% false blocking and <10 ms p99 latency.
EnterpriseSim: PostgreSQL Multi-Hazard Gym for Transactional Agents: EnterpriseSim (arXiv:2612.01881) is an open-source PostgreSQL gym of 83 tasks (53 multi-hazard) across six enterprise departments. Across 3,619 episodes, unguided 55-tool consoles and live background contention drop frontier models by 10–30 percentage points, while a pre-PostgreSQL commit gate blocks all single-agent unsafe writes at 0% false blocking and <10 ms p99 latency. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- Deterministic SQL State Grading: Evaluates declarative PostgreSQL invariants (double-entry GL debits=credits, stock conservation, refund caps) with zero LLM-judge drift.
- Real Production Hazards: Injects ambiguous HTTP 504 timeouts after committed writes, 409 optimistic lock races from 4 live background worker bots, and indirect prompt injections.
- Reveals Unguided Drops (10–30 pp): Moving from guided queues to vague inbox alerts and 55-tool consoles drops the top model from 95% down to 65%.
- <10 ms p99 Commit Gate: Across 7 runtime safety layers, a deterministic pre-SQL commit gate blocks 100% of observed single-agent unsafe writes with 0% false blocking.
import { createAgent } from '@smoke-monkey/harness';// Transactional enterprise agent wrapped with deterministic pre-SQL commit gate checksconst agent = createAgent({agentId: 'enterprisesim-oltp-guard',provider: 'anthropic',model: 'claude-sonnet-4-5',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},});interface RefundInvariantInput {paymentSettledCents: number;priorRefundsCents: number;requestedRefundCents: number;rowVersionExpected: number;rowVersionActual: number;}function preCommitInvariantGate(tx: RefundInvariantInput): { allowed: boolean; reason: string } {if (tx.rowVersionExpected !== tx.rowVersionActual) {return { allowed: false, reason: '409_VERSION_CONFLICT: concurrent worker updated row' };}if (tx.priorRefundsCents + tx.requestedRefundCents > tx.paymentSettledCents) {return { allowed: false, reason: 'INV-FIN-001_VIOLATION: refund exceeds settled payment' };}return { allowed: true, reason: 'OK' };}async function main() {const verdict = preCommitInvariantGate({paymentSettledCents: 12000,priorRefundsCents: 12000,requestedRefundCents: 12000,rowVersionExpected: 3,rowVersionActual: 3,});const res = await agent.run(`HTTP 504 occurred during refund tool call. Commit gate returned ${JSON.stringify(verdict)}. Reconcile idempotency key safely.`);console.log(res.summary);}main().catch(console.error);
Watch: Related Video Guides
AI Agent Evaluation Explained: Metrics, Trajectories & Reliability
AI Agent Evaluation Metrics: What It Says vs What It Does?
Why Single-Actor Benchmarks Miss Production Enterprise Agent Failures
EnterpriseSim (arXiv:2612.01881) is an open-source PostgreSQL-based evaluation gym containing 83 tasks—30 single-incident and 53 multi-hazard tasks spanning six departments—designed to test write-capable AI agents under real database contention. Unlike function-calling suites that grade final chat messages with an LLM judge, EnterpriseSim grades exact SQL table invariants after deterministic replay.
Across 3,619 evaluation episodes, the authors show that passing a ticket in a single-actor sandbox hides severe database corruption risks: agents duplicate refunds after ambiguous HTTP 504 timeouts, overwrite concurrent security patches (0/7 models passed task CF03 unguarded), and lose 10 to 30 percentage points when moved to vague inbox alerts and 55-tool consoles.
| Model (53 Multi-Hazard Tasks, B1-Concise) | Strict Safe Pass | Core-18 | Held-Out + Res. (25) | Avg Calls | Avg Tokens | Latency |
|---|---|---|---|---|---|---|
| Gemini 4 Argon | 98.1% (52/53) | 94.4% | 96.0% | 21.7 | 129.1k | 70.8 s |
| Gemini 4 Carbon | 92.5% (49/53) | 94.4% | 88.0% | 26.4 | 163.1k | 99.9 s |
| Gemini 3.8 Flash | 88.7% (47/53) | 88.9% | 92.0% | 18.4 | 156.4k | 49.4 s |
| Claude Sonnet 5.5 | 83.0% (44/53) | 88.9% | 76.0% | 19.7 | 239.6k | 70.6 s |
| Qwen 3.8 27B (Local Ollama) | 79.2% (42/53) | 83.3% | 76.0% | 21.1 | 102.1k | 190.6 s |
| GPT-6.2 Sol | 66.0% (35/53) | 61.1% | 64.0% | 24.2 | 152.7k | 106.2 s |
| GPT-6 Luna | 47.2% (25/53) | 38.9% | 36.0% | 23.9 | 148.4k | 60.7 s |
Declarative PostgreSQL Invariants and Sub-10ms Pre-SQL Commit Gates
Every EnterpriseSim episode checks domain-specific declarative SQL invariants that cannot be bypassed by polite natural-language summaries:
- Financial & Double-Entry Rules (`INV-FIN-001..003`): Total settled refunds cannot exceed settled payment amounts or role caps, voided invoices require zero balance, and general-ledger debits must equal credits.
- Inventory Conservation (`INV-INV-001..002`): On-hand, reserved, allocated, and available stock remain non-negative and conserved within warehouse capacity across concurrent worker updates.
- Why Prompt Safety Fails vs Commit Gates: Long safety prompts push agents into repetitive read loops, whereas a deterministic commit gate placed immediately in front of PostgreSQL catches 100% of observed single-agent unsafe writes at <10 ms p99 with 0% false blocking (while multi-writer budget caps still require row-level
SELECT ... FOR UPDATEdatabase locks).
Do Not Rely on Prompt Instructions Alone for Concurrency Safety
Even Gemini 4 Argon (98.1% overall) failed concurrent security-patch race CF03 unguarded. Pair agent harnesses with optimistic row versions and pre-SQL invariant gates.
Verifying Agent Writes With PostgreSQL Check Constraints & Advisory Locks
You can mirror EnterpriseSim's invariant pattern in any production PostgreSQL database backing an AI agent tool layer by combining optimistic version checks with double-entry ledger assertions.
# Run deterministic PostgreSQL invariant verification against an agent staging schema
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -c "
SELECT 'INV-FIN-003_GL_IMBALANCE' AS violation, COUNT(*)
FROM gl_entries
HAVING COALESCE(SUM(debit_cents), 0) <> COALESCE(SUM(credit_cents), 0);
"Frequently Asked Questions
Q:How does EnterpriseSim grade agents without using LLM judges?
EnterpriseSim executes deterministic PostgreSQL invariant queries against the database state after every episode, checking exact conservation rules for inventory, refunds, double-entry general ledger balances, and access controls.
Q:Why do agent scores drop 10–30 percentage points in unguided EnterpriseSim runs?
Unguided runs replace explicit instructions with vague inbox alerts, expand the tool surface to 55 tools, add distraction tickets, and activate four background worker bots mutating shared rows.
Q:Does a pre-SQL commit gate replace PostgreSQL row locks for parallel agents?
No. EnterpriseSim shows that a <10 ms p99 commit gate stops all observed single-agent unsafe writes with 0% false blocking, but parallel multi-writer budget caps still require database-level locks.
Q:How did local Qwen 3.8 27B perform compared to cloud models on EnterpriseSim?
Running locally via Ollama, Qwen 3.8 27B achieved 79.2% strict safe pass (42/53 tasks), outperforming GPT-6.2 Sol (66.0%) and GPT-6 Luna (47.2%) while using fewer tokens (102.1k average).
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.