TL;DR: AI agent deployments fail most often when retrievers overexpose internal knowledge rather than when models take unapproved actions, according to Visiq Labs. The article argues that retrieval governance must operate before context injection, because once restricted material enters the context window, output filtering cannot undo the exposure or its downstream effects.
At a glance
What this is: This is a retrieval-governance analysis showing that the real control point for AI agents is what they are allowed to see, not only what they are allowed to do.
Why it matters: It matters because IAM, NHI, and AI governance teams need to treat retrieval as an authorization surface, with document-level decisions, masking, and recorded approval.
By the numbers:
- 64% of valid secrets leaked in 2022 are still valid and exploitable today, proving that detection alone is not enough without automated revocation.
- AI-related credential leaks surged 81.5% year-over-year in 2025, with the surrounding AI infrastructure leaking 5x faster than core LLM providers.
- 28.65 million new hardcoded secrets were detected in public GitHub commits in 2025 alone, a 34% year-over-year increase and the largest single-year jump ever recorded.
👉 Read Visiq Labs' whitepaper on sensitive knowledge and retrieval governance
Context
AI agent governance fails when organisations treat retrieval as a neutral plumbing layer rather than an authorization decision point. In practice, the problem is not only what an agent may do after it has context, but what it is allowed to see before it reasons, selects tools, or writes output. That makes retrieval governance a core part of AI agent identity and access management, not a separate content-filtering problem.
The boundary failure is simple: if restricted documents, secrets, or internal records enter the context window, the application has already crossed the intended data boundary. Output filtering can suppress some visible text after the fact, but it cannot erase reasoning that already happened over prohibited content or undo downstream tool decisions shaped by that exposure.
Key questions
Q: How should security teams handle AI agent visibility?
A: Security teams must conduct an exhaustive discovery process to identify all deployed AI agents, both sanctioned and unsanctioned, across the organization. This visibility is foundational for effective governance and enables timely interventions against potential threats.
Q: Why do AI agents create a different access problem from human developers?
A: AI agents create a different access problem because they can parallelise work, retrieve context on demand, and initiate actions without the pauses that human workflows naturally create. That changes the control objective from managing interactive users to governing high-volume machine actions. Identity teams need to account for speed, chaining, and fan-out, not just login events.
Q: What breaks when retrieval is governed only by output filters?
A: Output filters can hide text after generation, but they cannot undo prior exposure. If the model already saw restricted records, credentials, or legal material, that information may have influenced the answer or tool selection. The missing control is upstream decision-making at retrieval time, where the exposure actually happens.
Q: Who should approve exceptional access to restricted documents in agent workflows?
A: A designated human approver should handle exceptional access when the request is genuinely outside normal need-to-know boundaries. The approval should be recorded with the document identity, policy outcome, and reason for access. That gives audit, security, and governance teams a verifiable trail instead of an untracked exception.
Technical breakdown
Why retrieval is an authorization surface
Retrieval systems decide which documents, snippets, and metadata are admitted into an agent session. That makes them part of the access-control path, because the model can only reason over what the retriever surfaces. If a search index, vector store, or document-returning API returns restricted material, the model has effectively received unauthorised context even if the final answer is later filtered. The security boundary is therefore upstream of generation, not downstream of it.
Practical implication: Treat retrievers as governed access points and apply document-level policy before any content reaches the model.
How per-document allow, redact, and deny decisions work
Per-document governance evaluates each retrieved item against content, metadata, and trust tier before injection. Allow means the document enters context unchanged. Redact means sensitive fields are replaced with placeholders while the permitted structure remains visible. Deny means the document is suppressed entirely, with empty results treated as a valid policy outcome. This is materially different from prompt filtering because it preserves control over the information set the agent can reason over.
Practical implication: Implement policy evaluation at retrieval time so restricted values never become part of the model's working context.
Why output filtering cannot fix upstream exposure
Output filters only inspect what the model is about to say, not what it already read. If the model has seen unreleased financials, personnel records, legal strategy, or secrets embedded in retrieved text, that information may already have influenced the response or tool choice. The operational issue is provenance: teams need evidence of what was exposed, when, and under which policy decision. Without that, post-generation controls remain partial and hard to audit.
Practical implication: Use signed retrieval decisions and audit records to prove which content entered context and which content was blocked.
NHI Mgmt Group analysis
Retrieval governance is the missing authorization layer in AI agent architectures. Most enterprises still think about model output as the primary risk surface, but the real boundary failure happens earlier, at document admission. Once sensitive material enters context, the agent has already been authorised to see more than its task requires, even if no prohibited action follows. The implication is that identity governance for AI agents must control exposure, not just execution.
Need-to-know should be applied to agent context with the same discipline used for human access. The article's strongest contribution is the translation of an existing governance principle into machine-readable policy: business function plus trust tier determines what an agent may read, redact, or never see. That is a practical governance model because it avoids the false choice between broad retrieval and unusable answers. Practitioners should treat context scope as an access entitlement, not a retrieval convenience.
Context overexposure creates downstream identity risk even when no action is taken. If a coding agent sees PII, credentials, or board material, the damage is already in the reasoning layer. That exposure can influence tool choice, prompt chaining, and future outputs, which means the control failure is not limited to one response. This is why output-only protection is structurally too late for AI agent governance.
Per-document governance creates a named control pattern: context-window authorization. This is the point where retrieval policy, redaction, and recorded approval converge before the model sees the content. The value of the concept is that it separates governing knowledge exposure from governing model behaviour. For IAM and NHI teams, that distinction is essential because the boundary now sits inside the application runtime, not only in the source system.
Recorded exception handling is what turns retrieval governance from theory into audit-ready control. Deliberate human approval for exceptional access matters because not every sensitive lookup can be flattened into a static policy rule. However, the exception must be explicit, documented, and reproducible. Without that evidence, teams cannot prove whether a sensitive document was withheld, redacted, or intentionally exposed under approved conditions.
From our research:
- 64% of valid secrets leaked in 2022 are still valid and exploitable today, according to The State of Secrets Sprawl 2026.
- The same research found that AI-related credential leaks surged 81.5% year-over-year in 2025, with surrounding AI infrastructure leaking 5x faster than core LLM providers.
- That pattern strengthens the case for The State of Secrets Sprawl 2026 as a reference point for retrieval governance, because exposure is now a runtime control problem, not only a secret-management problem.
What this signals
Context-window authorization: this should become a distinct control concept in AI governance programmes, because the point of failure is the moment data is admitted for reasoning, not the moment text is displayed. Teams that already manage human need-to-know can extend the same principle to agents by governing retrieval outcomes, masking, and exception handling.
With 28.65 million new hardcoded secrets detected in public GitHub commits in 2025 alone, the broader lesson is that sensitive content is already present in the places AI systems are most likely to query. Retrieval governance, not just content scanning, is what prevents that material from becoming operationally available to an agent.
For IAM, PAM, and NHI teams, the next step is to align source-system permissions, retrieval policy, and audit evidence so the same entitlement logic applies before context injection and after the fact review. That is the difference between managing access on paper and governing what an agent can actually consume.
For practitioners
- Map retrievers as access points Inventory every vector store, search tool, memory lookup, and document-returning API that can feed an agent. Classify each source by sensitivity tier, then define which agents may read, redact, or never see each class of content.
- Apply need-to-know at document level Build policy so each returned document is evaluated before injection, with allow, redact, or deny as the only outcomes. Use business function and operator trust tier together so the same document can be handled differently for support, HR, finance, and engineering agents.
- Record every retrieval decision Preserve signed evidence for the matched policy, the document identity, the outcome, and any masked fields. That record is what lets security, audit, and incident response teams prove exactly what reached the context window.
- Route exceptional access through approval Use deliberate human approval for genuinely unusual document requests, especially for restricted materials such as personnel records, credentials, incident reports, and board content. Keep the approval record tied to the retrieval event so later review can reconstruct the decision path.
Key takeaways
- AI agent risk often starts with overexposure of internal knowledge, not with an unapproved action.
- Retrieval must be governed before context injection, because output filtering cannot reverse what the model has already seen.
- Document-level allow, redact, and deny decisions turn internal knowledge into a controlled production surface.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10 and OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST Zero Trust (SP 800-207) and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | Retrieval and context exposure are central agentic application risks. | |
| OWASP Non-Human Identity Top 10 | NHI-03 | This article focuses on controlling sensitive data exposure to non-human identities. |
| NIST CSF 2.0 | PR.AC-4 | Least-privilege access principles map directly to agent context governance. |
| NIST Zero Trust (SP 800-207) | Zero trust supports continuous verification before information is admitted to context. | |
| NIST SP 800-53 Rev 5 | AC-3 | Access enforcement is the core control for retrieval admission and denial. |
Enforce document access decisions before context injection and log every denied or redacted result.
Key terms
- Retrieval governance: Retrieval governance is the policy layer that decides which documents, snippets, and records an AI agent can see before they enter context. It turns search and knowledge access into a controlled authorization step, with allow, redact, deny, and approval outcomes based on sensitivity and need-to-know.
- Context-window authorization: Context-window authorization is the practice of controlling what information is admitted into an agent's working memory before reasoning begins. It matters because once restricted data enters the context window, the model may act on it even if later output filters hide the visible text.
- Need-to-know matrix: A need-to-know matrix maps business function and trust tier to the exact data an agent may access. It lets organisations apply different outcomes to the same document depending on the agent's task, so the same record can be allowed, masked, or denied without weakening the overall governance model.
- Per-document policy decision: A per-document policy decision evaluates each retrieved item separately instead of treating a whole source or repository as uniformly accessible. That approach is essential for AI systems because sensitive and non-sensitive content often coexist in the same document set, requiring field-level controls and verifiable outcomes.
What's in the full article
Visiq Labs' full whitepaper covers the operational detail this post intentionally leaves for the source:
- A worked policy example showing how document metadata, trust tier, and function combine into per-document decisions.
- The four-phase rollout model for moving from observation mode to enforced redaction and denial.
- Specific scenario breakdowns for finance, HR, support, and engineering assistants.
- The evidence model for signed retrieval decisions, including what auditors can verify later.
Deepen your knowledge
NHI governance, agentic AI identity, and machine identity security are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are building or maturing an IAM, IGA, or security programme, it is worth exploring.
Published by the NHIMG editorial team on August 16, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org