Context Engineering for Trustworthiness: Rescorla Wagner Steering Under Mixed and Inappropriate Contexts

Rushi Wang, Jiateng Liu, Cheng Qian, Yifan Shen, Yanzhou Pan, Zhaozhuo Xu, Ahmed Abbasi, Heng Ji, Denghui ZhangarXiv 2025 · DOI

Abstract

Large Language Models (LLMs) are increasingly integrated with Retrieval-Augmented Generation (RAG) to reduce hallucinations. However, real-world retrieval often introduces "poisoned" context—such as fake news, hate speech, or privacy violations—that can disproportionately degrade model performance. This paper adapts the Rescorla-Wagner (RW) model from neuroscience to analyze LLM sensitivity to such stimuli. We introduce RW-Steering, a fine-tuning approach that enables models to internally identify and disregard harmful signals. Our results show that RW-Steering improves response quality by nearly 40% in contaminated environments, effectively reversing the behavioral fragility observed in baseline models.

Introduction

Retrieval-Augmented Generation (RAG) is the industry standard for grounding LLMs in external knowledge. Despite its benefits, RAG systems are vulnerable to "poisoned" content within retrieved sets. Even a single piece of misinformation among many accurate documents can significantly derail model outputs. For instance, the introduction of one fake news item into a set of twenty accurate documents can cause GPT-4o’s response quality to drop by 23%.

The core challenge lies in understanding the "behavioral curves" of LLMs when encountering mixed contexts. This research seeks to quantify this vulnerability and provide a robust engineering solution to "steer" models toward trustworthy information.

Overview of the RW-Steering framework and the problem of contaminated information pools.

Methods

The Rescorla-Wagner (RW) Analogy

The authors draw a parallel between LLM context processing and classical conditioning. By adapting the RW model—a mathematical framework describing how animals learn associations—they predict how LLMs weigh competing contextual cues. The model identifies a "novelty bias": LLMs tend to over-prioritize infrequent or "surprising" stimuli, making them disproportionately sensitive to the "odd one out" in a document set.

RW-Steering

To mitigate this bias, we propose a two-stage fine-tuning method:

  1. Joint Optimization: Models are trained to generate a "structured analysis" identifying inappropriate segments before producing a final response.
  2. Targeted Training: Models are exposed to distributions where appropriate information is dominant but "poisoned" segments are present, teaching them to disregard minor contamination across varying context lengths.

Poisoned Context Testbed

We developed a new benchmark comprising 7.6K user queries and 45.3K contextual segments. It covers four high-risk categories: privacy-violating data, fake news, hate speech, and non-factual data, sourced from established datasets like LIAR and ETHOS and augmented via GPT-4o.

Results

RW-Steering achieved a 39.8% improvement in average response quality across various context mixtures. While baseline models like Qwen-2 and Phi-2 exhibit sharp performance declines upon encountering any inappropriate context, RW-Steering "reverses" this curve, maintaining stability even as contamination increases.

Key insights include:

  • Novelty Bias: LLM sensitivity is inversely related to information dominance. LLMs are "surprised" by rare, inappropriate info and give it too much weight.
  • Fragility at the Margin: Small amounts of bad info are more damaging to "clean" models than additional bad info is to "dirty" ones.
  • Awareness vs. Action: Detection alone is insufficient; joint optimization of detection and generation is required for effective steering.

Discussion and Conclusion

While the RW analogy is illustrative rather than a literal mapping of transformer mechanics, it provides a powerful lens for context engineering. Future work will explore scaling these methods to 70B+ parameter models and extending the framework to agentic LLMs that must monitor for risky environmental feedback in real-time. RW-Steering represents a significant step toward building LLMs that remain trustworthy even when operating in the messy, "poisoned" environments of the open web.

Summary updated

BibTeX
@misc{wang2025context,
  author = {Rushi Wang and Jiateng Liu and Cheng Qian and Yifan Shen and Yanzhou Pan and Zhaozhuo Xu and Ahmed Abbasi and Heng Ji and Denghui Zhang},
  title = {{Context Engineering for Trustworthiness: Rescorla Wagner Steering Under Mixed and Inappropriate Contexts}},
  year = {2025},
  eprint = {2509.04500},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.04500},
}
Figure