A write gate is a service that sits between AI agents and the systems of record they change. The agent asks for a business action. The gate decides whether that action may happen, holds it for a person if needed, performs it with its own credentials, recovers if it fails partway, and keeps a record that can be checked later.

The term matters because reading and writing carry different risks. An agent that reads the wrong record gives a wrong answer, and a person can ignore it. An agent that writes the wrong record has changed the business. A vendor now exists, a payment has left, or a customer has been refunded. Those facts stay true after the conversation ends.

We describe Sefra as The Write gate for AI agents. This article explains the idea in general, then says how Sefra applies it.

Why the agent should not hold the keys

The simplest way to give an agent write access is to hand it an API key. It is also the arrangement that makes every other control optional.

If the agent’s process holds a credential for the payment system, then any check inside that process is advisory. A bug, a changed prompt or a manipulated instruction can route around the check and call the API directly. The check and the thing it guards live on the same side of the boundary.

A write gate moves the boundary. The gate holds the write credentials, and the agent holds a credential only for the gate. Once the agent’s own access to the system of record is revoked, the gate is the only route to a write. That last step matters: until the old credentials are gone, the agent can still go around it.

The five jobs of a write gate

Decide. Each request is checked before anything changes. A useful decision looks at more than the shape of the request. Whether an order fits the budget depends on the budget today, so the gate has to read current facts from the system of record and evaluate a rule against them. The rule should be deterministic: the same input, facts and policy version should always give the same answer.

Hold. Some actions are allowed only with a person’s agreement. The gate pauses that action and shows a person what will happen. The approval has to apply to the exact content that was shown, or it approves a description and not an action.

Execute. The gate makes the call with its own scoped credentials. It handles retries so that a network failure does not turn one payment into two.

Recover. Business actions often come in sequences: create a vendor, raise an order, pay a deposit. When the third step fails, the first two are already real. A write gate knows how each step is undone and runs those undo operations in reverse order. When it cannot know what happened, it stops and asks a person.

Prove. Afterwards, somebody will ask who approved this, under which rule, and what ran. The record should answer that, and it should be possible to check the record without trusting the service that wrote it.

What a write gate is not

The category is easy to overstate, so the limits are worth stating.

A write gate is not an agent framework. It does not run models, plan tasks or hold conversation state. Your agents stay as they are.

It is not a guarantee that an agent is right. A wrong request that policy allows will execute. The gate limits the damage to what the rules permit, which is why the rules matter.

It is not a prompt-injection filter. It judges the typed request and does not inspect the text that led to it. That is a useful property, and we cover it in a separate article, but it does not stop an agent from being misled.

It is not a database transaction. Undoing a business action means calling a real operation, such as deactivating a vendor. Other users of the system may see the intermediate state, and some actions cannot be reversed at all.

How it differs from a tool-call gateway

A tool-call gateway usually answers one question: may this caller use this tool? That is valuable, particularly for managing many tools across many agents. It treats each call as the unit of control.

A write gate treats a business operation as the unit and follows it to its outcome. It cares about the live budget behind a purchase order, the approver who released it, the refund that undoes it, and the state where nobody knows whether it happened. Many organisations will want both, because they solve different problems.

When you need one

Not every agent does. If an agent only reads, you do not need a write gate. If its writes are easy to repair by hand, or it touches one system in one step, checks in your own code may be enough. Those checks are cheaper to start with and fit your system exactly.

The case gets stronger when several of these are true:

  • The agent writes to a system that moves money or holds official records.
  • One business action spans several steps or systems, so a partial failure leaves a mess.
  • Some actions need a named person’s approval.
  • Someone outside the team that runs the agent has to verify what happened.
  • You do not want each team to write its own undo logic, retries and failure handling.

How Sefra applies it

In Sefra, agents submit typed intents over MCP or REST. An intent is a named business operation with a schema, such as creating a purchase order. Policy written in Rego runs on embedded Open Policy Agent, against facts read from the system of record at decision time and again before execution. Risky requests are held for a person. Sefra executes with its own credentials, undoes completed steps when a later one fails, and writes every decision to a hash-chained trail in PostgreSQL before any write reaches a system of record.

It runs in your network, and it sends nothing to us. The product pages explain each part, and the status page says what is shipped and what is still planned.