Observation masking: the right context for AI agents
Observation masking means that an AI agent does not see the full, raw system state but only the part that is necessary and safe for the current task. The agent with the most context does not work best – the one with the right context does.
What is observation masking?
Discussions about AI agents usually focus on capabilities: better planning, more autonomous execution, more productivity. Less often does anyone ask what an agent should actually be allowed to see – and what it should not. Observation masking answers this question: the agent receives only the observations that are necessary and safe for its task.
The term is used in two related senses. First, as a principle of access and visibility: sources and fields are filtered or redacted for the agent. Second, in context management: older tool outputs are hidden during an agent run so that the context does not grow uncontrollably. A study by Lindenbauer et al. (August 2025) found for software agents that this simple masking roughly halved costs compared with an unmodified agent while performing about as well as having a language model summarise the history. Both senses follow the same idea: targeted context instead of maximum context.
Why more context is not always better
Many teams start with the assumption that the more context a model gets, the better the result. That may hold for individual prompts; for production agents it is risky. An agent that sees everything can also misinterpret everything, leak it by accident or be influenced by injected content. The broader the observation, the larger the attack surface – technically, organisationally and from a regulatory standpoint.
- sensitive environment variables in logs or build output
- internal tickets containing personal data
- security reports unrelated to the current task
- unnecessarily broad visibility into production metrics or customer data
What observation masking solves
- Data minimisation by design
- The agent processes only task-relevant information. This supports data protection and compliance and reduces unintended data processing.
- More stable agent behaviour
- Less irrelevant noise leads to clearer decisions; agents get side-tracked less often.
- Smaller attack surface for prompt injection
- What never enters the observation space cannot steer the agent in the wrong direction.
- Better governance
- Visibility and permissions can be modelled cleanly: who may see what, when and why?
Relevance for agents in software development
Development agents often work with highly privileged sources: code repositories including their history, CI/CD systems, tickets and knowledge bases, runtime metrics and alerts. An agent that takes in everything can quote old secrets from the history, carry confidential architecture details into external contexts or propose wrong changes based on outdated artefacts.
In addition, agents often work in chains: the output of one becomes the input of the next. Without masking, errors and leaks propagate along the entire chain.
A practical architecture model
Observation masking is not a downstream filter but the first layer of the agent architecture. A three-stage observation logic has proven useful. This way, no agent works on a dump of the entire system but on a controlled, task-related view.
- Source gating
- Only approved data sources are reachable at all.
- Field-level masking
- Within a source, fields are redacted, hashed or omitted, such as tokens, email addresses or internal IDs.
- Task-scoped views
- For each task, the agent receives its own temporary view with minimal rights.
Common mistakes and measurable control
Many teams fail not for lack of technology but because of the wrong order. With agents that act autonomously or semi-autonomously, these mistakes multiply operational risk. Treat observation masking as a measurable quality attribute – for example via the share of masked sensitive fields per source, the average context size per task, the number of blocked unauthorised accesses and the time it takes to review an audit trail.
- Build first, secure later: retrofitted security is expensive and incomplete.
- Roles without a data model: role-based access is not enough if content within a role stays unmasked.
- No separation of observing and acting: agents see and act within the same, overly broad scope.
- Missing traceability: it remains unclear which data an agent saw and when.
Larger context windows do not replace targeted context
Model providers keep enlarging context windows. One example: in May 2026 the start-up Subquadratic introduced its model SubQ and cites, as a research result, processing of up to 12 million tokens; it is said to be based on an attention architecture whose compute grows linearly with context length. At the time of the announcement, a preview version with one million tokens was offered in a private beta. These are vendor claims that have not yet been independently confirmed.
Even if such windows prove themselves, the question of the right context remains. A larger window can simplify chunking and pre-selection, but it does not make data safe that the agent should not see, and it does not protect against injected instructions. Test long contexts on your own data and target metrics – not only on “needle in a haystack” retrieval tasks – and decide between retrieval and more in-prompt context based on data.
Observation masking and action rights
What an agent may see is closely tied to what it may do. Graduated action rights – prepare, recommend, execute with approval, act autonomously within defined limits – need an equally graduated view of data. In sales this concerns customer data in particular: an agent preparing a reply needs the case, not the entire database.
In AI-first coaching you clarify goals, mandate and your AI-first operating model – and with it, which view and which rights an agent receives. An agent is never finished: visibility is reviewed and adjusted in operation.
From tool to outcome
In AI-first coaching you clarify which outcomes AI agents should be accountable for in your go-to-market and within which framework. REVAGO then designs, builds and runs your system. You pay for results – not for activity.
Frequently asked questions
What is observation masking?
Observation masking is a design principle for AI agents: the agent receives only the observations that are necessary and safe for its current task. This includes approving individual sources, redacting sensitive fields and task-related views; in context management it also refers to hiding older tool outputs in the agent’s history.
Why is more context not always better for AI agents?
More context brings more noise, higher costs and a larger attack surface. An agent that sees everything can leak confidential data, get side-tracked or be manipulated by injected content. Targeted context makes behaviour more stable and traceable.
How does observation masking help against prompt injection?
Content that never enters the agent’s observation space cannot influence it. Observation masking thus reduces the attack surface but does not replace other safeguards such as limited action rights and human approvals.
Do large context windows make observation masking unnecessary?
No. Larger windows change how much a model can process, not what an agent should see. Data protection, permissions and protection against manipulated content remain tasks of the architecture.
Further reading in the wiki
A neutral overview, not a recommendation of individual providers. REVAGO is not affiliated with the listed projects. Descriptions are based on the projects’ public information; features and licences may change. Selection based on awesome-agents (kyrolabs).
