Put a gateway beside your database, not the agent inside it. Each agent task gets a private copy of one customer’s rows and a token that opens only that task. What the agent changes reaches your database through a checked merge, inside rules you set, or after a person approves it. The agent never holds a database credential, and it never sees another customer’s data.
What goes wrong when an agent gets a database connection?
| With a database connection | With a gateway beside the database |
|---|---|
| The agent holds a database password | It holds a run token that opens one task, for one customer, for one hour |
| A prompt injection can read every tenant’s data | It only ever sees its tenant’s rows, whatever SQL it sends |
DELETE FROM leads runs on production | Deletes happen in a private copy; by default every delete waits for a person |
| A stale read overwrites someone’s edit | Each row is locked and compared with the database at write time; a changed row stops the merge |
| You learn what it did from the logs | You see “Remove lead ‘Hooli’” and approve it, or turn it down |
The second row is the one that matters most in a product with many customers. A filter the agent is asked to add (where org_id = 42) is a request. An agent that has been talked into something else will not add it.
What does one agent task look like?
- 01Start a runYour backend asks for a run for one tenant. The answer has a run token, shown once.
- 02The agent worksIt sends SQL or MCP tool calls with that token, in a private copy holding only its tenant’s rows.
- 03ProposeInside the rules the change is written at once. Outside them it is held, and nothing is written.
- 04ApproveYour team, or the customer in a widget in your product, approves or rejects a held change.
export KEY=cgk_... # your developer key: stays on your backend# 1. start a run for tenant 42curl -s localhost:7400/v1/runs -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \ -d '{"tenant": {"org_id": 42}, "intent": "remove the duplicate lead", "end_user": "user_7"}'export RUN=run_... # "id" from the answerexport RUN_TOKEN=cgr_... # "token" from the answer: this is all the agent gets# 2. the agent works, in its own copycurl -s localhost:7400/v1/runs/$RUN/sql -H "Authorization: Bearer $RUN_TOKEN" -H 'Content-Type: application/json' \ -d '{"sql": "delete from leads where id = 3"}'# 3. proposecurl -s localhost:7400/v1/runs/$RUN/propose -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{}'# 202 {"status": "held", "reasons": [...]}: the default rules allow no deletesHow is the agent kept to one customer?
By the engine, on every read and write, not by the agent’s good behavior. Every table that has your tenant column is filtered to the run’s tenant, whatever SQL arrives: joins and subqueries included.
- A table without the column but with a foreign key to one that has it, up to three hops away (
order_items.order_idtoorders.id), is held to the tenant through that key. - A table with neither is shared: every run can read it, and a run’s writes to it are refused, since every other tenant would see them.
- A run is held only by its own tenant’s rows. Another customer’s edits never block it.
What may land without a person?
By default, a change is written on its own only if it deletes no rows, changes at most 500, keeps its tenant under 5,000 changed rows an hour, was made in the last 15 minutes, and every row it read still matches the database:
max_rows = 500, max_deletes = 0, rows_per_hour = 5000, max_age = '15 minutes', check_reads = true, require_scope = trueAnything else is held for a person. That person can be on your team, in the console’s review queue, or your own end user, shown the change in plain words in an approval widget inside your product. A merged run can be undone for 30 days.
Does my app have to go through it?
No. Your app keeps reading and writing its database exactly as it does today. The gateway sits beside the database, never in front of it. If the gateway is down, agents cannot start runs or merge; your database and your app are not affected.
What does it not do?
- Judge your app’s own writes. The rules judge merges from agent runs.
- Take back effects outside the database. An undo puts rows back; an email already sent is listed, not unsent.
- Make shared tables safe to write. Give them the tenant column or a key to a table that has it, or change them outside runs.
More: Chronos Gateway, then Install and set up and Runs.
Questions
How do I let AI agents change customer data in a multi-tenant app safely?
Do not give the agent a database connection. Start a run for one tenant, hand the agent that run’s token, and let it work in a private copy of that tenant’s rows. Chronos Gateway writes its changes to your database only inside your rules, or after a person approves.
Can a prompt injection make the agent read another customer’s data?
Not through the gateway. The engine filters every read and write to the run’s tenant, including joins and subqueries, so the agent sees only its tenant’s rows whatever SQL it sends.
Does Chronos Gateway sit in front of my database?
No. Your application keeps talking to its database directly. The gateway runs beside it on your own servers, and if it is down only agent runs are affected.
