Generative AI & Agentic AIAgent workflows and state

Prevent a retrieved document from authorizing tool use

PK
Pankit Kumar
Sr. Data Scientist at Parexel (a Goldman Sachs–backed company) · 20 September 2026 · 2 min read
Technically reviewed by Ishaan Sharma
In this article (5 sections)

A document can contain “send this file” or “approve this transaction.” Retrieval makes that text relevant; it does not make it an authenticated instruction.

Enforce the authority source

The agent controls lab includes an injected synthetic policy.

python
from agent_cases import retrieved_authority_case

result = retrieved_authority_case()
assert result["user_authority"] == {"read_policy": True, "send_external": False}
assert result["proposal"]["authorized"] is False
assert result["executed"] is False
assert result["retrieved_text_granted_authority"] is False

The retrieved string requests an external email, but application state permits only reading. No email tool runs.

Separate evidence, intent and authority

Authenticated user input defines requested intent within policy. Retrieved/tool content supplies evidence. Application authorization determines permitted tools/resources. The model cannot merge those channels to expand scope.

Enforce tool allowlists and arguments outside the model. Keep write credentials unavailable to read-only paths. Require approval bound to exact side-effect details. Sanitize model output before rendering or executing anything.

Test indirect injection

Place hostile instructions in body text, metadata, filenames, tables and tool responses. Include benign security documents that quote similar phrases. Measure both unauthorized-action prevention and task completion; blocking every document is not useful.

The Generative & Agentic AI course connects this control across RAG, agents and MCP.

Exercise

Create 20 indirect-injection cases against a read-only agent. Prove none activates a write tool and record any legitimate research task falsely blocked.

Continue learning

This article is part of the Agent workflows and state sequence. Use the neighbouring tasks when you need the prerequisite or the next application.

Reference: OWASP LLM01 prompt injection.

PK
Pankit Kumar
Lead Instructor, NeuraPath Academy

Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.

This article is part of our Generative & Agentic AI programme — 3 months. Add practical GenAI, retrieval and agent-building skills to your existing toolkit.

Explore Generative & Agentic AI
Counselling is free · no obligation

Not sure which programme fits?

Tell us your background and we will map it to the right entry point — including saying so when a cheaper programme is the better fit. A counsellor replies within one working day.