Sense and Sensitivity: Examining the Influence of Semantic Recall on Long Context Code Reasoning
Adam Štorek, Mukur Gupta, Samira Hajizadeh, Prashast Srivastava, Suman Jana
TL;DR
This work distinguishes lexical recall (verbatim code retrieval) from semantic recall (understanding code behavior) in long-context code understanding. It introduces semantic recall sensitivity as a benchmark property and a counterfactual line-removal method to measure it, revealing that existing benchmarks often mask semantic failures through pattern matching. The SemTrace task is proposed to force semantic recall by using unpredictable operations, uncovering pronounced position-dependent degradation (median $92.73\%$) that far exceeds CRUXEval's $53.36\%$ on existing tasks. The findings suggest current evaluations substantially underestimate semantic recall fragility in long-context code understanding and motivate high-sensitivity benchmarks and careful interpretation for production deployments. Overall, the paper highlights a critical gap between observed lexical competence and genuine semantic understanding in state-of-the-art models as context length grows.
Abstract
Large language models (LLMs) are increasingly deployed for understanding large codebases, but whether they understand operational semantics of long code context or rely on pattern matching shortcuts remains unclear. We distinguish between lexical recall (retrieving code verbatim) and semantic recall (understanding operational semantics). Evaluating 10 state-of-the-art LLMs, we find that while frontier models achieve near-perfect, position-independent lexical recall, semantic recall degrades severely when code is centrally positioned in long contexts. We introduce semantic recall sensitivity to measure whether tasks require understanding of code's operational semantics vs. permit pattern matching shortcuts. Through a novel counterfactual measurement method, we show that models rely heavily on pattern matching shortcuts to solve existing code understanding benchmarks. We propose a new task SemTrace, which achieves high semantic recall sensitivity through unpredictable operations; LLMs' accuracy exhibits severe positional effects, with median accuracy drops of 92.73% versus CRUXEval's 53.36% as the relevant code snippet approaches the middle of the input code context. Our findings suggest current evaluations substantially underestimate semantic recall failures in long context code understanding.
