Skip to main content
QUICK REVIEW

[Paper Review] Robustness and Reasoning Fidelity of Large Language Models in Long-Context Code Question Answering

Kishan Maharaj, Narayanan Menon|arXiv (Cornell University)|Feb 19, 2026
Topic ModelingComputer Science0 citations
TL;DR

The paper introduces LongContextCodeQA, a multilingual extension of LongCodeBench with COBOL and Java datasets and evaluates robustness of LLMs under shuffled options, open-ended generation, and distractor insertion across up to 1M token contexts, revealing persistent recognition–generation gaps and language-dependent vulnerabilities.

ABSTRACT

Large language models (LLMs) increasingly assist software engineering tasks that require reasoning over long code contexts, yet their robustness under varying input conditions remains unclear. We conduct a systematic study of long-context code question answering using controlled ablations that test sensitivity to answer format, distractors, and context scale. Extending LongCodeBench Python dataset with new COBOL and Java question-answer sets, we evaluate state-of-the-art models under three settings: (i) shuffled multiple-choice options, (ii) open-ended questions and (iii) needle-in-a-haystack contexts containing relevant and adversarially irrelevant information. Results show substantial performance drops in both shuffled multiple-choice options and open-ended questions, and brittle behavior in the presence of irrelevant cues. Our findings highlight limitations of current long-context evaluations and provide a broader benchmark for assessing code reasoning in both legacy and modern systems.

Motivation & Objective

  • Assess how long-context code QA models perform as context length scales up to 1 million tokens across Python, COBOL, and Java.
  • Investigate robustness to input variations by introducing option shuffling, open-ended generation, and needle-in-a-haystack distractors.
  • Evaluate cross-language generalization and identify failure modes in long-context code reasoning.
  • Provide a multilingual benchmark and controlled perturbations to better measure reasoning fidelity in enterprise and legacy code.

Proposed method

  • Extend LongCodeBench with COBOL and Java QA datasets (OPPSCAL COBOL, internal IBM COBOL, and Java from major GitHub repos) to test long-context reasoning.
  • Use With Options (shuffled) and Without Options (open-ended) settings to separate recognition from generation.
  • Inject distractors (irrelevant code fragments) and varying needle positions (Start/Middle/End) to assess retrieval robustness.
  • Evaluate a wide set of models (GPT-4o, Gemini, Claude, LLaMA, Mistral, Qwen, Granite) across context lengths from 32k to 1,024k tokens.
  • Analyze performance as context length grows, language, and evaluation setting to identify failure modes.
Figure 1: Accuracy trends across context lengths for Python dataset, comparing “With Options” and “Without Options” settings.
Figure 1: Accuracy trends across context lengths for Python dataset, comparing “With Options” and “Without Options” settings.

Experimental results

Research questions

  • RQ1How does model accuracy scale with long context length across Python, COBOL, and Java?
  • RQ2Do models rely on answer options or true reasoning when options are shuffled or removed?
  • RQ3How robust are models to irrelevant information inserted into long code contexts?
  • RQ4Are there language-specific differences in effective context length and retrieval, especially for legacy languages like COBOL?
  • RQ5What are the common failure modes in long-context code reasoning across state-of-the-art models?

Key findings

  • All models show a recognition–generation gap, with accuracy dropping when options are removed (15–35 percentage points in Python).
  • Performance does not scale monotonically with context length; some models degrade or behave inconsistently as context grows.
  • In COBOL, OPPSCAL shows near-perfect performance with options but large drops without options, while internal IBM COBOL data are more challenging but Gemini models cope better in long contexts.
  • In Java, frontier models excel in multiple-choice but also show stabilization or improvement for long-context optimized models (e.g., Gemini-2.5-Flash) up to 1M tokens, with open-ended performance remaining strong for some models.
  • Needle-in-a-haystack experiments reveal strong recency bias and position-dependent retrieval, with end-context often easier than start in COBOL; open-ended generation remains challenging even when relevant needles are present.
  • Across languages, generation remains fragile; reliance on superficial cues in multiple-choice and sensitivity to distractors indicate gaps in true long-context reasoning.
Figure 2: Accuracy trends for OPPSCAL dataset.
Figure 2: Accuracy trends for OPPSCAL dataset.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.