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:

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:

Also consider:

We define the operational reliability of the system as:

𝑅(𝑐) = β„™(𝑦 ∼ π‘ž(ΞΈ)(Β· | 𝑐))(𝑦 ∈ 𝐴(𝑇))
𝑅(𝑐) = β„™(𝑦 ∼ π‘žβ‚ΞΈβ‚Ž(Β·|𝑐))(𝑦 ∈ π΄β‚œ)

R(c)=β„™y∼qΞΈ(β‹…βˆ£c)(y∈AT) R(c) = \mathbb{P}_{y \sim q_\theta(\cdot \mid c)} \left( y \in A_T \right)

Notational note. Since cc is a sequence, the addition of context nn represents concatenation, not set union. We denote concatenation by cβ‹…nc \cdot n or, when the order is irrelevant to the argument, by (c,n)(c, n).

The contextual monotonicity hypothesis can then be written as:

𝑅(𝑐 Β· 𝑛) β‰₯ 𝑅(𝑐)

for any additional sequence nn.

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:

Then the following holds:

H(Y∣Xr,Xn)≀H(Y∣Xr) H(Y \mid X_r, X_n) \le H(Y \mid X_r)

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 pp of the observed process, not to the approximate model qΞΈq_\theta used operationally.

A parametrized generative system does not directly implement:

p(y∣xr,xn) p(y \mid x_r, x_n)

It implements an approximation:

qθ(y∣xr,xn) q_\theta(y \mid x_r, x_n)

where:

The relevant operational question is not:

is there useful information in XnX_n?

The relevant operational question is:

can the concrete system use XnX_n 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:

c=(sβ‹…n) c = (s \cdot n)

where:

The contextual monotonicity hypothesis assumes:

R(sβ‹…n)β‰₯R(s) R(s \cdot n) \ge R(s)

However, in approximate models, the operationally dangerous case is:

R(sβ‹…n)<R(s) R(s \cdot n) < R(s)

Sufficient condition. This occurs when the injection of nn shifts the distribution qΞΈ(β‹…βˆ£sβ‹…n)q_\theta(\cdot \mid s \cdot n) away from ATA_T relative to qΞΈ(β‹…βˆ£s)q_\theta(\cdot \mid s). A formal sufficient condition is:

DKL(p(β‹…βˆ£s)βˆ₯qΞΈ(β‹…βˆ£sβ‹…n))>DKL(p(β‹…βˆ£s)βˆ₯qΞΈ(β‹…βˆ£s)) D_{KL}\big(p(\cdot \mid s) \,\|\, q_\theta(\cdot \mid s \cdot n)\big) > D_{KL}\big(p(\cdot \mid s) \,\|\, q_\theta(\cdot \mid s)\big)

That is: the addition of nn increases the divergence between the model and the true distribution, degrading the probability of producing outputs in ATA_T. This condition is realizable whenever nn introduces sufficient competitive attentional mass to redistribute qΞΈq_\theta, 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):

L(qΞΈ,c)=𝔼y∼p(β‹…βˆ£c)[βˆ’logqΞΈ(y∣c)] L(q_\theta, c) = \mathbb{E}_{y \sim p(\cdot \mid c)} \left[ -\log q_\theta(y \mid c) \right]

The formal decomposition of this quantity is:

L(qΞΈ,c)=H(p(β‹…βˆ£c))+DKL(p(β‹…βˆ£c)βˆ₯qΞΈ(β‹…βˆ£c)) L(q_\theta, c) = H\big(p(\cdot \mid c)\big) + D_{KL}\big(p(\cdot \mid c) \,\|\, q_\theta(\cdot \mid c)\big)

where H(p(β‹…βˆ£c))H(p(\cdot \mid c)) is the irreducible entropy of the task and the DKLD_{KL} term captures all additional loss arising from the approximation.

In real operational systems, the DKLD_{KL} term can be interpreted as composed of three conceptually distinct sources:

DKL(p(β‹…βˆ£c)βˆ₯qΞΈ(β‹…βˆ£c))β‰ˆeapprox+econtext+eselection D_{KL}\big(p(\cdot \mid c) \,\|\, q_\theta(\cdot \mid c)\big) \approx e_{\text{approx}} + e_{\text{context}} + e_{\text{selection}}

where:

This decomposition of DKLD_{KL} is an operational interpretation, not a single formal identity. Its value lies in making explicit that econtexte_{\text{context}} and eselectione_{\text{selection}} grow with the uncontrolled growth of cc.

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 𝒴={y+,yβˆ’}\mathcal{Y} = \{y^+, y^-\}, where:

Define the logarithmic decision margin:

Ξ”(c)=log⁡qΞΈ(y+∣c)βˆ’log⁡qΞΈ(yβˆ’βˆ£c) \Delta(c) = \log q_\theta(y^+ \mid c) - \log q_\theta(y^- \mid c)

In this binary regime, operational reliability is related to the margin by the logistic function:

R(c)=β„™(y=y+∣c)=Οƒ(Ξ”(c))=11+eβˆ’Ξ”(c) R(c) = \mathbb{P}(y = y^+ \mid c) = \sigma(\Delta(c)) = \frac{1}{1 + e^{-\Delta(c)}}

Since Οƒ\sigma is strictly increasing, it holds directly that:

Ξ”(sβ‹…n)<Ξ”(s)⟹R(sβ‹…n)<R(s) \Delta(s \cdot n) < \Delta(s) \implies R(s \cdot n) < R(s)

Contextual degradation can therefore be interpreted as margin collapse: the addition of nn reduces Ξ”\Delta, which reduces RR monotonically. The system exhibits operational stability when:

Ξ”(c)>0 \Delta(c) > 0

When the margin approaches zero, small perturbations become sufficient to change the final decision.

In code generation systems, this frequently appears operationally as:

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 ii:

Ξ±ij=exp⁡(𝒒iβŠ€π’Œj/d)βˆ‘l=1mexp⁡(𝒒iβŠ€π’Œl/d) \alpha_{ij} = \frac{\exp\left(\mathbf{q}_i^\top \mathbf{k}_j / \sqrt{d}\right)}{\sum_{l=1}^{m} \exp\left(\mathbf{q}_i^\top \mathbf{k}_l / \sqrt{d}\right)}

where:

Note. The symbol 𝒒i\mathbf{q}_i (bold vector) denotes the attention query vector and is distinct from qΞΈq_\theta, which denotes the parametrized generative model.

Separate the context into:

The attentional mass on the relevant signal, for the query position ii, is:

AS(i)=βˆ‘j∈Sexp⁡(zij)βˆ‘j∈Sexp⁡(zij)+βˆ‘j∈Nexp⁡(zij) A_S^{(i)} = \frac{\sum_{j \in S} \exp(z_{ij})}{\sum_{j \in S} \exp(z_{ij}) + \sum_{j \in N} \exp(z_{ij})}

with:

zij=𝒒iβŠ€π’Œj/d z_{ij} = \mathbf{q}_i^\top \mathbf{k}_j / \sqrt{d}

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 |N|β†’βˆž|N| \to \infty with exp⁡(zij)\exp(z_{ij}) bounded away from zero for j∈Nj \in N, then AS(i)β†’0A_S^{(i)} \to 0 independently of the relevance of the tokens in SS.

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:

ct+1=ctβ‹…htβ‹…mt c_{t+1} = c_t \cdot h_t \cdot m_t

where β‹…\cdot denotes sequence concatenation and:

This type of architecture tends to satisfy:

|ct+1|β‰₯|ct| |c_{t+1}| \ge |c_t|

where |β‹…||\cdot| denotes the sequence length. The continuous growth of context produces multiple consequences:

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 tt become contextual premises in cycle t+kt + k, potentially amplifying econtexte_{\text{context}} 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 β„›t\mathcal{R}_t in cycle tt.

A deterministic analyzer produces:

St=A(β„›t) S_t = A(\mathcal{R}_t)

where AA represents a deterministic structural analysis process.

This analyzer can compute:

A selector function then defines the operational context:

Ct=Ο€(St,T) C_t = \pi(S_t, T)

where:

The probabilistic agent does not receive the entire repository.

It receives only CtC_t under an explicit constraint:

|Ct|≀B |C_t| \le B

where BB represents a maximum operational context budget.

The model then proposes a change:

Pt∼qΞΈ(β‹…βˆ£Ct,T) P_t \sim q_\theta(\cdot \mid C_t, T)

The state transition does not depend on the model's self-confidence.

It depends on an external verifier:

V(β„›t,Pt)=1β‡’β„›t+1=apply(β„›t,Pt) V(\mathcal{R}_t, P_t) = 1 \Rightarrow \mathcal{R}_{t+1} = \mathrm{apply}(\mathcal{R}_t, P_t)

V(β„›t,Pt)=0β‡’β„›t+1=β„›t V(\mathcal{R}_t, P_t) = 0 \Rightarrow \mathcal{R}_{t+1} = \mathcal{R}_t

The verifier can include:

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:

Ξ¦(β„›)=βˆ‘i=1kwiΟ†i(β„›) \Phi(\mathcal{R}) = \sum_{i=1}^{k} w_i \varphi_i(\mathcal{R})

where:

Relation to operational reliability. Under regular conditions of contextual selection, in particular when Ο€\pi is a monotonic projection of StS_t and Ξ¦\Phi is computed over the same artifacts that compose CtC_t, the following relation holds:

Ξ¦(β„›t+1)<Ξ¦(β„›t)⟹R(Ct+1)β‰₯R(Ct) \Phi(\mathcal{R}_{t+1}) < \Phi(\mathcal{R}_t) \implies R(C_{t+1}) \ge R(C_t)

This relation is not universal: it depends on Ο€\pi being risk-sensitive, that is, on selecting regions of high Ο†i\varphi_i with priority. When this condition is satisfied, Ξ¦\Phi serves as a measurable proxy for operational reliability.

Possible examples of Ο†\varphi:

A conservative transition policy may require simultaneously:

V(β„›t,Pt)=1 V(\mathcal{R}_t, P_t) = 1

and:

Ξ¦(β„›t+1)≀Φ(β„›t) \Phi(\mathcal{R}_{t+1}) \le \Phi(\mathcal{R}_t)

For systems of automatic iterative improvement, the stronger condition may be required:

Ξ¦(β„›t+1)<Ξ¦(β„›t) \Phi(\mathcal{R}_{t+1}) < \Phi(\mathcal{R}_t)

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 tt:

Ut={uβˆˆβ„›t:ρ(u)>Ο„} U_t = \{ u \in \mathcal{R}_t : \rho(u) > \tau \}

where:

Define the operational context as the structural neighborhood of UtU_t:

Ct=neighborhoodG(Ut) C_t = \mathrm{neighborhood}_G(U_t)

where GG is the dependency graph of β„›t\mathcal{R}_t and neighborhoodG(U)\mathrm{neighborhood}_G(U) denotes the set of units at edge distance ≀k\le k from some element of UU in GG.

With this definition, neighborhoodG\mathrm{neighborhood}_G is monotonic: UβŠ†Uβ€²β‡’neighborhoodG(U)βŠ†neighborhoodG(Uβ€²)U \subseteq U' \Rightarrow \mathrm{neighborhood}_G(U) \subseteq \mathrm{neighborhood}_G(U'). Therefore:

|Ut+1|<|Ut|β‡’|Ct+1|≀|Ct| |U_{t+1}| < |U_t| \Rightarrow |C_{t+1}| \le |C_t|

The expression above does not constitute universal proof of convergence: it depends on Ξ¦(β„›t)\Phi(\mathcal{R}_t) 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:

|Ct+1|β‰₯|Ct| |C_{t+1}| \ge |C_t|

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:

However, verifiable operational state must remain in deterministic artifacts:

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:

arg⁡maxcR(c)=arg⁡maxc|c| \arg\max_c R(c) = \arg\max_c |c|

In real systems, the correct problem is:

arg⁡maxcR(c)β‰ arg⁡maxc|c| \arg\max_c R(c) \neq \arg\max_c |c|

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:

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:

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.