AI agents that can search files, query databases, or take actions need boundaries that prevent unnecessary access and unsafe changes. This guide shows how to define those boundaries, enforce them in the systems around the agent, and test them before rollout. Start with an inventory of the data and tools the agent will use, plus an accountable owner from security, IT, or data governance.
What You’ll Need
- A written use case: who will use the agent, what tasks it may perform, and what it must not do.
- An inventory of relevant data sources, sensitivity labels, existing access controls, and data owners.
- A supported agent platform and identity system that can enforce permissions and record activity.
- A test environment with representative, non-sensitive or synthetic data, and people responsible for security and business approval.
- A way to report incidents, revoke access, and review logs after launch.
Step-by-Step
- Define the agent’s job and boundaries. Write down its intended users, permitted tasks, expected outputs, and prohibited outcomes. Be specific: “find approved policy documents and summarize them” is more testable than “answer company questions.” Decide whether the agent may only read, or may also create, edit, send, or delete information. Treat each additional capability as a separate risk requiring justification.
- Classify the data it could reach. List the repositories, databases, and services connected to the agent. Identify sensitive categories such as personal information, credentials, customer records, confidential plans, and regulated data. Confirm the data owner, classification, retention rules, and existing access restrictions for each source. Exclude sources that are not necessary; a broad connection is not a substitute for a clear use case.
- Use a dedicated identity and least privilege. Give the agent or its service a distinct identity rather than a shared employee account. Grant only the minimum read or action permissions needed for its approved tasks, scoped to the smallest practical set of files, records, or endpoints. Keep user permissions separate: where appropriate, ensure the agent cannot retrieve information that the requesting user is not allowed to see. Do not place passwords, API keys, or tokens in prompts or documents; use a managed secrets store and rotate credentials under your normal process.
- Put policy checks outside the model. Do not rely on instructions in a prompt as the only barrier. Enforce access in the source system, identity provider, API gateway, or a tool broker that checks each request. Validate the user, agent identity, requested resource, and action before executing it. Deny access by default when an identity, permission, or policy check is missing or fails. Make controls apply to direct tool calls as well as natural-language requests.
- Reduce what enters prompts and outputs. Retrieve only the passages needed for the current task, and apply source permissions before retrieval rather than after the agent has seen the content. Mask or omit sensitive fields that are not needed. Set clear rules for what can appear in responses, logs, exports, and notifications. If users need source references, provide them in a way that does not expose restricted documents or information through previews.
- Require approval for consequential actions. Begin with read-only access where possible. For actions that affect customers, employees, finances, systems, or official records, require a person to review the proposed change before it is carried out. Show the reviewer the exact action and relevant context, and make approval specific to that action rather than granting open-ended authority. Add rate limits, confirmation steps, or reversible workflows where useful.
- Plan for prompt injection and untrusted content. Treat retrieved files, emails, web pages, and user inputs as data, not as trusted instructions. A document may contain text that tries to redirect the agent, request secrets, or trigger a tool call. Keep tool permissions narrow, prevent content from changing policy, and require explicit validation before acting on instructions found inside retrieved material. Test with hostile and misleading examples.
- Test access and failure cases before launch. In a non-production environment, try allowed and disallowed requests using users with different permissions. Check direct access to each connected tool, not just the agent’s final answer. Test requests for another person’s data, secret extraction, prompt injection, oversized queries, and unauthorized changes. Confirm that denials are reliable, understandable, and recorded, and that a failed policy service does not silently allow the request.
- Monitor, review, and improve. Log who initiated a request, which identity and tools were used, what resources were accessed, and whether an action was approved. Avoid putting sensitive content or secrets into logs unnecessarily; restrict log access and set retention according to company policy. Review unusual access patterns and user reports. Assign an owner to recheck permissions and tests when the model, connected sources, tools, or business purpose changes.
- Prepare a stop and recovery process. Document how to disable the agent, revoke its credentials, disconnect a source, and stop queued actions. Define who makes that decision and how incidents are escalated. For an unintended disclosure or change, preserve relevant logs, contain access, notify the appropriate internal response team, and follow the company’s incident process. Do not wait for a routine review to remove a permission that is actively causing harm.
Common Mistakes
- Giving the agent a person’s broad account. This obscures accountability and can grant access far beyond the task. Use a dedicated, attributable identity.
- Trusting prompt wording as a security control. Instructions can be ignored or overridden by hostile content. Enforce authorization in systems that control data and tools.
- Connecting everything “for convenience.” More sources increase exposure and make testing harder. Add a source only when the use case requires it.
- Allowing write access too early. A correct summary does not prove an agent can safely edit records. Start read-only and add reviewed actions incrementally.
- Logging full prompts and retrieved documents by default. Logs can become another sensitive repository. Minimize captured content and control retention and access.
- Testing only normal questions. Check denial paths, conflicting instructions, user permission differences, and tool failures as well as successful tasks.
Tips
- Turn each policy into a testable statement, such as “this role cannot retrieve payroll records,” then keep a test case for it.
- Separate read, create, update, send, and delete permissions; do not bundle them into a single broad tool grant.
- Make permission changes traceable, approved by a data owner, and easy to roll back.
- Use synthetic or sanitized data for development and demonstrations whenever realistic sensitive data is unnecessary.
- Reassess the controls after changes to connected tools, identity mappings, data classification, or agent behavior.
Troubleshooting
- The agent returns restricted information. Disable the affected connection or revoke its access while investigating. Check the source system’s permissions, retrieval filters, identity mapping, cached results, and any secondary index. Test as both an authorized and unauthorized user; fixing the final response alone may leave the underlying access open.
- Legitimate requests are denied. Check whether the user identity is being passed correctly and whether the specific resource permission is missing. Use a narrow, approved permission change rather than granting broad access. Retest both the intended request and a nearby prohibited one.
- The agent follows instructions inside a document. Treat this as a security test failure. Restrict the tools available during retrieval, strengthen separation between trusted policy and untrusted content, and verify that tool calls pass independent authorization checks.
- An action happens without the expected approval. Stop further actions and revoke the relevant write permission. Inspect the approval workflow, alternate tool paths, retries, and queued jobs. Restore access only after tests show that every route enforces the review requirement.
- Logs are missing or expose too much. Verify that relevant tool and identity events are captured, then limit log fields, permissions, and retention. Confirm that incident responders can still investigate without routinely collecting full sensitive content.
Frequently Asked Questions
Are system prompts enough to protect company data?
No. Prompts can guide behavior but cannot reliably enforce authorization. Use source-level permissions and checks on every tool request.
Should an AI agent use an employee’s account?
Usually not. A dedicated identity makes access easier to scope, attribute, monitor, and revoke. Pass the requesting user’s identity separately when user-specific permissions must apply.
Can an agent access confidential data?
Only when the use case requires it and the data owner approves the access. Apply the same classification, access, retention, and monitoring requirements used for other systems.
How do we test for prompt injection?
Use safe test data containing misleading instructions that request secrets or unauthorized actions. Confirm the agent treats that content as untrusted and that the tool layer blocks prohibited access regardless of its response.
What should we log?
Record the initiating user, agent identity, tool and resource accessed, decision, and approval outcome where relevant. Minimize sensitive content in logs and protect them with restricted access and an appropriate retention policy.
When should we review guardrails?
Review them on a regular schedule and whenever permissions, data sources, tools, model behavior, or the agent’s purpose changes. Investigate incidents and unexpected access immediately.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Immortals Fenyx Rising Co-op, Crossplay and Friends
- AI Inference Near the Device: When It Makes Sense
- Restore Default Settings on a Sons of the Forest Server
- Best Music Streaming Service in India: How to Choose
- How to Clean Gaming Headset Ear Pads Safely
- First Light Trophy List and How to Earn Them