An AI agent can read messages, retrieve documents, call tools, and produce text that a person or another system acts on. Each connection adds a place where untrusted input, excessive permissions, or weak output handling can create risk. Prompt injection is one way input can steer a model toward behavior the workflow did not intend. It is not reliably solved by adding a warning to the system prompt.
Separate instructions from authorization
Treat text from users, retrieved pages, files, and tool results as untrusted data. Do not let the model create its own access rights or decide whether a consequential action is permitted. Enforce authorization in application code and the target service: check the signed-in user, record ownership, allowed fields, destination, and action type before a tool call runs.
Give each tool the narrowest practical permission. If an agent only needs to draft a CRM note, use an integration that cannot export all contacts or send messages. Keep secrets out of prompts and model-visible documents. Minimize data sent to model providers, and document which provider and endpoint handle each category of information.
Validate results before using them
Treat model output as untrusted too. Parse it against a strict schema, reject unknown fields, validate identifiers and ranges, and escape or encode content before rendering or executing it. A classifier or filter can catch some risky output, but it can miss cases; it should not replace access checks or application-level validation.
For external messages, financial or account changes, and other consequential actions, create a review step when the use case calls for one. The review should show the proposed action and its relevant source facts. Keep the authorization check in the service that performs the action so a prompt or reviewer interface cannot expand the agent's permissions.
Illustrative example: a support reply
Imagine a customer message that asks for an order update and includes instructions to reveal another account's details. The workflow treats the message as untrusted, verifies the current customer's identity through the order system, and gives the model only that customer's status fields. The model can draft a reply but has no tool for searching other accounts or sending the message. The backend validates the draft and checks that it contains no fields outside the approved response schema before placing it in a review queue.
If the order lookup fails or the output contains an extra field, the workflow stops without sending anything and records a request ID plus an error code. A support operator can inspect the event with the appropriate access, correct the underlying issue, and retry the draft. This is an illustrative design, not a client case or a guarantee that every attack will be detected.
Test the system and plan for incidents
Build tests around the workflow's actual data and tools: malicious instructions in user content, retrieved documents, unexpected model output, access to another user's records, provider timeouts, and duplicate retries. Use synthetic data where possible. Verify that failed checks stop the action and that logs contain enough metadata to investigate without routinely copying full prompts, secrets, or customer records.
Reassess the threat model when permissions, tools, models, prompts, or data sources change. The OWASP LLM guidance describes prompt injection, sensitive-information disclosure, insecure output handling, and excessive agency as distinct risk areas. NIST's AI Risk Management Framework calls for risk work across the AI system lifecycle rather than a one-time checklist. Neither source is a certification that a particular deployment is secure or legally compliant.
Conclusion
Reduce the consequences of model errors by limiting access, minimizing data, validating every boundary, testing failure paths, and monitoring the actions that matter. These measures can reduce defined risks, but cannot guarantee that an agent will never be manipulated or disclose information. Security and privacy reviews should match the specific system, provider terms, applicable rules, and people affected.