Require Human Approval Before an AI Agent Runs Ad Hoc SQL on Customer Data
Place an enforcement point at the tool-call boundary, between the agent and the database tool. It classifies each SQL call before execution and decides to allow, redact, block, or escalate for human approval. Escalated calls are held and sent to a named approver who sees the exact SQL and its context. Denial, timeout, and approver unavailability all fail closed, and the request, decision, and executed statement are recorded as evidence.
Where the gate must sit to be enforceable
- 1
Tool-call interception
The gate sits in the agent's execution path and evaluates each call to the SQL tool before it is dispatched. It sees the full request, the agent identity, and the originating task, which makes policy conditions on query origin practical.
- 2
MCP server mediation
If the SQL tool is exposed through an MCP server, the gate can sit in front of or within that path. It covers every agent using that server, but only calls that go through it.
- 3
Database proxy
A proxy sees every statement reaching the database, including from non-agent clients. It usually has less context about the agent, the user request, or the reason the query was written, which weakens the approver's view.
Evaluation checklist before you rely on the gate
- The gate intercepts the SQL tool call before execution; it does not only record it afterward.
- The agent has no direct database credentials or alternate path around the gate.
- Policy separates pre-approved query patterns from ad hoc SQL, and routine patterns run without delay.
- The approver sees the exact SQL, target tables, data sensitivity, originating agent, and triggering request.
- Denial, timeout, and approver unavailability all result in no execution.
- The record links request, approver identity, decision, and the statement that ran, and is retained by policy.
Why approval belongs at the tool-call boundary
An agent with database access can write SQL from natural-language input and run it. Guidance from NIST on agentic security describes this as a risk: agents produce scripts or actions from prompts and may execute them without strong validation, and untrusted inputs or poisoned context can lead an agent to generate harmful commands. When the target tables hold customer data, one generated query can be consequential.
Each common control has a limit. Prompt instructions tell the agent what it should do, but the same NIST material advises not to trust prompt instructions, metadata, or artefacts from users or other agents. Database role permissions bound what the agent's credentials can reach, but they cannot distinguish a routine lookup from an unusual export when both fall inside the granted role. Reviewing query logs afterward gives you a record, but the query has already run. Telemetry is still necessary, since NIST advises against running agents without it, yet it is a different control from approval.
The workable pattern is to treat approval as a runtime enforcement decision. The gate acts on the individual tool call, before execution, and it works alongside least privilege and scoped tools rather than replacing them. A January 2026 federal request for information lists human oversight controls, such as approvals for consequential actions, among the controls organizations are considering for agents. It is a request for comment, not a requirement, but it supports aiming approval at consequential actions instead of every query.
Classify SQL tool calls and write the policy conditions
Start by separating routine patterns from ad hoc SQL. A routine pattern is a parameterized, pre-approved query template the agent fills with values. Ad hoc SQL is a free-form statement the agent composed. Matching an approved template should allow the call without human involvement, which keeps the gate from blocking normal work.
For everything else, evaluate conditions that can be read from the tool call itself. These attributes are design judgment and should be tuned to your data model: statement type (SELECT versus INSERT, UPDATE, DELETE, or DDL), target tables, the sensitivity classification of those tables and columns, query origin (which agent, which user request, whether the context included untrusted input), and scope, such as the absence of a row limit or filter.
A reasonable starting policy maps these conditions to four outcomes.
- Allow: Approved templates, or read-only statements on non-sensitive tables within a bounded scope.
- Redact: Reads that touch sensitive columns where the agent does not need raw values; mask the fields in the result.
- Block: Statements that should never run from an agent, such as schema changes or deletes on customer tables.
- Escalate: Ad hoc reads or writes on customer data that are legitimate in some cases but consequential, such as unbounded selects or any write.
Design the approver experience and fail-closed behavior
An approval is only as good as the information in front of the approver. Show the exact SQL as it would execute, not a summary written by the agent. Add the target tables and the sensitivity of the data, the statement type, the estimated scope where it can be determined, the originating agent, the user request or task that led to the call, and the policy condition that triggered escalation. Approvers who see only a natural-language description cannot catch a mismatch between what was asked and what was written.
Define who may approve. NIST AI RMF 1.0 calls for human roles and responsibilities in overseeing AI systems to be clearly defined and differentiated, and the Generative AI Profile includes documenting oversight roles. In practice that means a named approver group per data domain, authentication of the approver's identity, and a rule against self-approval by the person who triggered the request.
Then specify every outcome. On approval, execute exactly the statement that was reviewed; if the agent changes the SQL, it is a new request. On denial, return a clear refusal to the agent so it does not retry in a modified form without a new decision. On timeout, deny. If no approver is available, deny or queue to a secondary approver group, but never execute by default. A gate that fails open under load or outage is not an enforcement control.
Evidence and governance
Each escalation should produce one durable record linking four things: what was requested, who decided and when, the decision and any stated reason, and what ran, including the executed statement and its outcome. Include allow, redact, and block decisions as well, so the record shows the policy operating on routine traffic and not only on exceptions. The NIST Generative AI Profile includes monitoring and documenting instances where human operators override a system's decisions, and that practice maps directly to approver decisions. Retention and access to these records should follow your own policy.
Confirm which data-protection obligations apply to the tables in scope. For example, 16 CFR Part 314, which implements parts of the Gramm-Leach-Bliley Act, sets standards for reasonable administrative, technical, and physical safeguards for customer information. As of November 2026, whether it applies depends on whether you hold customer information it covers. NIST AI RMF material is general oversight guidance and does not prescribe an approval gate for SQL.
Trussed enforces policy in the execution path at the level of individual interactions and tool calls, with allow, redact, block, and escalate for human approval, and it generates audit-ready evidence from that enforcement. It is one way to implement the pattern described here; the design decisions above apply regardless of tooling.
Approval gate in the execution path
Detect
Classify the SQL tool call before it reaches the database.
Hold
Pause escalated calls so nothing runs while a decision is pending.
Decide
Route to an accountable approver with the exact statement and context.
Record
Keep the request, the decision, and what actually ran.
Put an approval gate in the execution path
See how policy enforcement and escalation for human approval work at the individual tool-call level, and what audit-ready evidence they produce.
Request a DemoHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.