Context as a Risk Variable
An operational formulation for reliability degradation under context growth in systems with LLMs
A large part of contemporary engineering of systems with LLMs implicitly assumes a property of contextual monotonicity.
The hypothesis can be formulated informally as follows:
adding context does not reduce reliability.
This premise appears in different architectures and operational strategies:
- continuous increase of context windows
- persistent memory between inference cycles
- aggressive retrieval via RAG
- serialization of entire repositories
- cumulative interaction history
- long-running stateful agents
- progressive expansion of operational memory
The intuitive justification seems reasonable. If the system has more information available during inference, then it should make better decisions.
However, this conclusion depends on an undue extrapolation from an ideal predictor to a finite-capacity approximate probabilistic model.
This text proposes an alternative operational formulation:
in real generative systems, context must be treated simultaneously as a source of information and as a risk variable.
More precisely, contextual growth does not imply monotonicity of reliability.
1. Problem formulation
Consider an input space:
π = (π₯β, π₯β, β¦, π₯β) β π³*
where:
- represents the operational context provided to the system, as an ordered sequence of tokens, documents, retrieved states or conditioning artifacts
- represents the set of finite sequences over the alphabet
Also consider:
- a task
- a set of acceptable outputs
- a parametrized generative model
We define the operational reliability of the system as:
π
(π) = β(π¦ βΌ π(ΞΈ)(Β· | π))(π¦ β π΄(π))
π
(π) = β(π¦ βΌ πβΞΈβ(Β·|π))(π¦ β π΄β)
Notational note. Since is a sequence, the addition of context represents concatenation, not set union. We denote concatenation by or, when the order is irrelevant to the argument, by .
The contextual monotonicity hypothesis can then be written as:
π
(π Β· π) β₯ π
(π)
for any additional sequence .
A large part of contemporary architectures implicitly assumes this inequality.
This text argues that it is not guaranteed in approximate generative systems.
2. The extrapolation error
In information theory, let:
- be the variable to be predicted
- the relevant subset of context
- additional context
Then the following holds:
The inequality is correct.
Conditioning on more variables does not increase the true conditional entropy, because an ideal predictor can always ignore irrelevant variables.
However, this property belongs to the true distribution of the observed process, not to the approximate model used operationally.
A parametrized generative system does not directly implement:
It implements an approximation:
where:
- represents learned parameters
- inference occurs under a finite computational budget
- the real input is a concrete sequence of tokens
- relevance selection is approximate
The relevant operational question is not:
is there useful information in ?
The relevant operational question is:
can the concrete system use without degrading the decision margin of the inference?
This is a question about approximation, statistical competition and operational stability.
3. Non-monotonic reliability
Consider a contextual decomposition:
where:
- represents relevant operational signal
- represents contextual noise, obsolete state, redundant information, conflicting instructions or spurious retrieval
The contextual monotonicity hypothesis assumes:
However, in approximate models, the operationally dangerous case is:
Sufficient condition. This occurs when the injection of shifts the distribution away from relative to . A formal sufficient condition is:
That is: the addition of increases the divergence between the model and the true distribution, degrading the probability of producing outputs in . This condition is realizable whenever introduces sufficient competitive attentional mass to redistribute , as formalized in Section 6.
This does not contradict information theory.
It contradicts only the extrapolation of ideal information theory to finite probabilistic models executing under real constraints.
4. Expected loss under imperfect conditioning
Consider the expected logarithmic loss (cross-entropy):
The formal decomposition of this quantity is:
where is the irreducible entropy of the task and the term captures all additional loss arising from the approximation.
In real operational systems, the term can be interpreted as composed of three conceptually distinct sources:
where:
- represents the intrinsic approximation error of the model, present even with ideal context
- represents degradation induced by long, noisy or conflicting context
- represents contextual selection error: relevant information present but not selected or not dominant
This decomposition of is an operational interpretation, not a single formal identity. Its value lies in making explicit that and grow with the uncontrolled growth of .
The important consequence is:
the presence of additional information does not imply a reduction in the observed operational loss.
The system may fail not because the correct information does not exist, but because it ceases to statistically dominate the inference process.
5. Decision margin
To simplify the analysis, consider the case where , where:
- represents the correct output, with
- represents an incorrect, regressive or unnecessary output
Define the logarithmic decision margin:
In this binary regime, operational reliability is related to the margin by the logistic function:
Since is strictly increasing, it holds directly that:
Contextual degradation can therefore be interpreted as margin collapse: the addition of reduces , which reduces monotonically. The system exhibits operational stability when:
When the margin approaches zero, small perturbations become sufficient to change the final decision.
In code generation systems, this frequently appears operationally as:
- editing outside the requested scope
- invisible regression
- alteration of correct code
- recovery of obsolete state
- partial obedience to instructions
- semantically plausible but incorrect changes
- instability between equivalent cycles
The problem is not the absence of superficial coherence.
The problem is the loss of sufficient probabilistic separability between correct and incorrect solutions.
6. Contextual competition
In a simplified model of attentional competition, consider attention weights for the token at position :
where:
- represents the query vector of the token at position
- represents the key vector of the token at position
- represents the dimensionality of the attention space
- represents the total number of available tokens
Note. The symbol (bold vector) denotes the attention query vector and is distinct from , which denotes the parametrized generative model.
Separate the context into:
- : set of relevant token positions
- : set of irrelevant token positions
The attentional mass on the relevant signal, for the query position , is:
with:
Even when each irrelevant token has low individual relevance, the accumulated growth of the denominator can reduce the statistical dominance of the relevant signal. Formally, if with bounded away from zero for , then independently of the relevance of the tokens in .
The operational problem is not only computational cost.
It is probabilistic competition for inferential influence.
Modern architectures with head specialization, implicit sparsity and retrieval mechanisms partially mitigate this effect. However, such mechanisms do not eliminate the general problem of contextual competition under operational context growth.
7. Cumulative context as authoritative state
A large part of contemporary agentic systems treats accumulated probabilistic inference as an authoritative state representation.
Formally, consider the contextual growth between inference cycles:
where denotes sequence concatenation and:
- represents the context of the current cycle
- represents the interaction history added in cycle
- represents persistent memory content retrieved in cycle
This type of architecture tends to satisfy:
where denotes the sequence length. The continuous growth of context produces multiple consequences:
- increase in the conflict exposure
- increase in inferential cost
- reduction in auditability
- propagation of obsolete state
- amplification of spurious retrieval
- greater sensitivity to contextual ordering
The central problem is not memory itself.
The problem is turning accumulated probabilistic inference into an operational source of truth.
An incorrect inference persisted in memory can reappear later as a valid contextual premise.
This mechanism produces recursive contextual contamination: inference errors in cycle become contextual premises in cycle , potentially amplifying over time.
8. Deterministic context reconstruction
An architectural alternative consists of not accumulating operational context between inference cycles.
Instead, the context can be reconstructed deterministically from the verifiable state of the system.
Consider a repository in cycle .
A deterministic analyzer produces:
where represents a deterministic structural analysis process.
This analyzer can compute:
- dependency graphs
- cyclomatic complexity
- cognitive complexity
- churn
- test coverage
- failure regions
- structural coupling
- typing
- risk metrics
A selector function then defines the operational context:
where:
- represents the current task
- represents a contextual selection policy
The probabilistic agent does not receive the entire repository.
It receives only under an explicit constraint:
where represents a maximum operational context budget.
The model then proposes a change:
The state transition does not depend on the model's self-confidence.
It depends on an external verifier:
The verifier can include:
- compilation
- static analysis
- test execution
- structural invariants
- domain validations
- risk policies
In this regime, probabilistic inference becomes a subordinate component of a deterministic control loop.
9. Risk functions
Consider an operational risk function over the repository:
where:
- represents deterministic metrics extracted from
- represents weights defined by the system policy
Relation to operational reliability. Under regular conditions of contextual selection, in particular when is a monotonic projection of and is computed over the same artifacts that compose , the following relation holds:
This relation is not universal: it depends on being risk-sensitive, that is, on selecting regions of high with priority. When this condition is satisfied, serves as a measurable proxy for operational reliability.
Possible examples of :
- compilation errors
- test failures
- structural complexity
- high churn
- lint violations
- circular dependencies
- absence of minimum coverage
- historical instability
A conservative transition policy may require simultaneously:
and:
For systems of automatic iterative improvement, the stronger condition may be required:
In this regime, the system does not use the generative model as authority over the state.
It uses the model as a heuristic mechanism restricted by external verifiers.
10. Contextual convergence
Consider the set of high-risk code units in cycle :
where:
- represents the local risk of unit , computed deterministically (for example, as a linear combination of over )
- represents an operational threshold
Define the operational context as the structural neighborhood of :
where is the dependency graph of and denotes the set of units at edge distance from some element of in .
With this definition, is monotonic: . Therefore:
The expression above does not constitute universal proof of convergence: it depends on being strictly decreasing across cycles, which requires the conditions of Section 9.
It describes a desirable architectural property:
the system must possess structural pressure to reduce operational context as the state converges.
Architectures based on cumulative memory frequently produce the opposite property:
even when the system approaches operational stability.
11. Appropriate limits for probabilistic inference
The fundamental problem is not using probabilistic models.
The fundamental problem is allowing probabilistic models to become authorities over operational state.
Generative models are particularly useful for:
- synthesis
- heuristic search
- structural transformation
- semantic compression
- approximate exploration of large spaces
However, verifiable operational state must remain in deterministic artifacts:
- code
- types
- tests
- builds
- metrics
- graphs
- structured logs
- analyzers
- formal or semi-formal verifiers
The context provided to the model must be a temporary projection of these artifacts.
Not an accumulated probabilistic memory of what the system believes happened.
12. Conclusion
The contextual monotonicity hypothesis is not guaranteed in approximate generative systems.
The relevant operational formulation is not:
In real systems, the correct problem is:
The best context is not necessarily the largest.
It is the context that maximizes operational reliability under real inference constraints.
Consequently, robust architectures for agentic systems must:
- reconstruct context deterministically from
- explicitly limit the contextual budget via
- separate verifiable state () from probabilistic inference ()
- use external verifiers for state transitions
- prevent authoritative persistence of unverified inference
- reduce operational context as the system converges, via
The path to more reliable generative systems probably does not consist of unrestricted expansion of operational memory.
It consists of progressively reducing probabilistic authority over the system state.
Probabilistic inference must operate within deterministic envelopes capable of:
- reconstructing state
- selecting context
- validating transitions
- rejecting regressions
- measuring risk externally
- limiting contextual propagation
The operational reliability of systems with LLMs depends less on the absolute amount of context available and more on the architectural capacity to control how context is produced, selected, validated and discarded.