What is Two-Phase Tool Enforcement?

1 min read Updated

An enforcement pattern where the proxy atomically reserves a budget or counter increment before forwarding a tool call, then commits on success or rolls back on upstream failure.

WHY IT MATTERS

Naive enforcement counts a tool call when it's made. But if the upstream server fails, you've consumed budget for nothing. Two-phase enforcement reserves the increment, forwards the call, then commits on success or rolls back on failure.

This is critical for accurate metering and budget enforcement. Without it, failed calls eat into budgets, and retries double-count.

HOW POLICYLAYER USES THIS

Intercept's engine uses reserve/commit/rollback semantics for all stateful enforcement (rate limits, budgets, counters), ensuring accurate state even under upstream failures.

FURTHER READING

Enforce policies on every tool call

Intercept is the open-source MCP proxy that enforces YAML policies on AI agent tool calls. No code changes needed.

npx -y @policylayer/intercept
github.com/policylayer/intercept →
// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.