All Use Cases

AI Agent Action Gating

Add sub-100ms guardrails to your AI agent's decision loop.

The Challenge

AI agents are becoming autonomous — booking flights, executing trades, sending emails, modifying code, managing infrastructure. But autonomy without guardrails is a liability.

The standard safety approach is to call another LLM to check whether an action is safe before executing it. This creates two problems:

  1. It's slow. Adding a 500-1500ms LLM safety check to every action in an agent loop turns a 10-step workflow into a 15-second ordeal. Agents need to think fast — not wait for a safety committee.

  2. It's circular. Using an LLM to check an LLM's decisions adds cost and complexity without fundamentally different reasoning. If the action-generating LLM thought the action was fine, a same-tier safety LLM might agree.

What you need is a fast, independent gate that evaluates actions in under 100ms — small enough to sit inside the agent loop without slowing it down, trained enough to catch genuinely dangerous actions.

How Sparkient Solves It

A compiled decision gate breaks the LLM-checking-LLM loop. The gate is a different model type (compiled model) trained specifically on action safety — it's fast, independent, and deterministic.

The Four Decisions

  • act — Safe to execute. The agent proceeds without interruption.
  • ask_user — Needs human confirmation. The agent pauses and asks before proceeding.
  • escalate — Potentially dangerous. Route to a supervisor agent or human reviewer.
  • block — Clearly unsafe. The action is stopped immediately.

What the Gate Evaluates

The gate sees the action the agent wants to take, along with context:

json
{
    "action": "send_email",
    "target": "all_customers@company.com",
    "description": "Send promotional email to entire customer list",
    "agent_id": "marketing-agent",
    "scope": "external",
    "reversible": false,
    "estimated_impact": "high"
}

CEL rules handle the deterministic checks: external actions with high impact always require confirmation. Irreversible actions on production systems always escalate. The compiled classifier handles the nuanced cases: is this email content appropriate? Does this code change look safe? Is this trade within normal parameters?

Code Example

python
import httpx

# Gate an agent action before execution
response = httpx.post(
    "https://api.sparkient.ai/api/v1/decide",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "decision_type_id": "agent-action-gate",
        "input": {
            "action": "delete_records",
            "target": "users_table",
            "description": "Delete inactive user accounts older than 2 years",
            "agent_id": "cleanup-agent",
            "scope": "internal",
            "reversible": false,
            "estimated_impact": "high"
        }
    }
)

result = response.json()
# {
#     "decision": "ask_user",
#     "confidence": 0.91,
#     "latency_ms": 34,
#     "stage": "classifier"
# }

Integration in an Agent Loop

python
async def execute_with_gate(action: dict) -> dict:
    gate_result = await sparkient_decide("agent-action-gate", action)

    if gate_result["decision"] == "act":
        return await execute_action(action)
    elif gate_result["decision"] == "ask_user":
        approved = await request_user_confirmation(action)
        return await execute_action(action) if approved else {"status": "cancelled"}
    elif gate_result["decision"] == "escalate":
        return await route_to_supervisor(action)
    else:  # block
        log_blocked_action(action, gate_result)
        return {"status": "blocked", "reason": "Safety gate triggered"}

The gate adds under 100ms to each action — imperceptible in a workflow that already involves LLM calls, API requests, and user interactions.

MCP Integration

For agents built with MCP, the gate integrates directly:

json
{
  "mcpServers": {
    "sparkient": {
      "type": "streamable-http",
      "url": "https://mcp.sparkient.ai",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

Your agent's MCP client can call Sparkient's make_decision tool before executing any action, adding a safety layer without modifying the agent's core logic.

Why a Compiled Gate

| Approach | Latency | Cost per check | Independent reasoning | |----------|---------|---------------|----------------------| | LLM safety check | 500-1500ms | ~$0.003-0.01 | No (same model family) | | Rules only | <1ms | ~$0 | Yes, but rigid | | Compiled gate | <100ms | Fixed monthly | Yes (different model type) |

A compiled gate is fast enough for the agent loop, cheap enough for every action, and independent enough to catch mistakes the action-generating LLM wouldn't.

Get Started

Define your agent's action space, set safety rules, and train a compiled gate. Start with the free tier — 5,000 credits, no credit card required.

Import this template

Get started in minutes. Import a pre-built decision type and customise it for your use case.

Import Template