Coding agents like Claude Code, Codex, OpenCode, or PI, started through the ug launcher, and integrated with foundation models through Unity AI Gateway can run with whatever Databricks permissions the developer already has through MCPs that is native on Databricks such as AI Search MCP(s), or Genie MCP(s).
Basically this introduce risk to the company if you are trying to protect the data before the model for whatever the reason is AI governance, law, etc, ...
We have been adopting protective mechanism in layers, where each one catches what the one above it misses.
- The first layer is what you already have. Since the agent acts as the user, Unity Catalog row filters, column masks, ABAC tag policies and plain least-privilege grants still apply to whatever it reads. But usually, people have multiple permissions and we want to protect the coding agent from reading the PII from those who have such permissions.
- The second layer is Sensitive Data Detection policy on the model service, you can turn this on on the UI and set it at rank 1, with tags email_address and credit_card. The model gets a token such as [US_SSN] instead of the value. Everything else just allows or denies. Some limitations that we have experience, the REDACT mechanism can be sometime to strict and remove important information from the coding agent such as AWS account number, Databricks workspace id when it is trying to perform task on such environment and break the workflow.
- The third layer is for what the built-ins miss or you can replace it completely to match some of your workflow. A custom SQL policy is a function that takes the event and returns a decision. The body is converted to a small SQL subset, so no regexp, just things like CONTAINS, LIKE and STARTSWITH.
CREATE OR REPLACE FUNCTION main.governance.block_private_keys(
event VARIANT
)
RETURNS VARIANT
LANGUAGE SQL
RETURN
CASE
WHEN event:type::string = 'request'
AND CONTAINS(event:context.message::string, 'PRIVATE KEY-----')
THEN to_variant_object(named_struct('result', 'DENY', 'reason', 'Prompt contains a private key.'))
ELSE to_variant_object(named_struct('result', 'ALLOW', 'reason', ''))
END;