← Latest papers
🤖 AI

Robustness and Reasoning Fidelity of Large Language Models in Long-Context Code Question Answering

This paper systematically evaluates the robustness and reasoning fidelity of large language models in long-context code question answering across multiple languages and formats, revealing significant performance degradation when models face shuffled options, open-ended queries, or irrelevant distractors.

Original authors: Kishan Maharaj, Nandakishore Menon, Ashita Saxena, Srikanth Tamilselvam

Published 2026-02-20
📖 4 min read☕ Coffee break read

Original authors: Kishan Maharaj, Nandakishore Menon, Ashita Saxena, Srikanth Tamilselvam

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a super-smart librarian (the AI) who has read almost every book in the world. You ask this librarian a question about a specific plot point in a massive, 1,000-page novel.

In the past, we tested this librarian by giving them the question and four possible answers, asking them to just pick the right one. They were great at it. But this new paper asks a scary question: Is the librarian actually reading the book, or are they just guessing based on which answer looks familiar?

The researchers at IBM decided to put this librarian through a series of "stress tests" to see how they really handle long, complex stories (code) written in different languages (Python, Java, and old-school COBOL).

Here is the breakdown of their findings using simple analogies:

1. The "Multiple Choice" Trap (Recognition vs. Reasoning)

The Test: Imagine asking the librarian, "Who killed the butler?"

  • Scenario A: You give them a list: [A) The Butler, B) The Chef, C) The Butler, D) The Butler].
  • Scenario B: You just ask, "Who killed the butler?" with no list.

The Result: The librarians were amazing at Scenario A (picking the right letter), often getting 80-90% right. But when you removed the list (Scenario B), their scores crashed, sometimes dropping by 30-50%.
The Takeaway: The AI wasn't really "solving" the mystery; it was just recognizing patterns. It's like a student who memorizes the answer key but can't explain the math. When forced to write the answer from scratch, they struggled.

2. The "Needle in a Haystack" (Finding the Truth)

The Test: Imagine a giant haystack (thousands of pages of code). The researchers hid one tiny, specific piece of straw (the "needle" or the correct answer) somewhere inside.

  • Test 1: They hid the needle at the very start, the middle, or the very end of the haystack.
  • Test 2: They also threw in a bunch of fake needles (distractors) that looked like the answer but weren't.

The Result:

  • The "Recency" Bias: The librarians were great at finding the needle if it was at the end of the haystack. If the needle was at the start, they often forgot it existed. It's like how you remember the last thing someone said in a conversation but forget the first thing they said.
  • The "Distractor" Problem: When they threw in fake needles (irrelevant code), the librarians got confused and often picked the wrong one, even if the real answer was right there. They got easily distracted by "noise."

3. The "Old Language" Problem (COBOL vs. Modern Code)

The researchers tested the AI on three types of "books":

  • Python & Java: Modern, popular languages. The AI did okay, but still struggled with the "write the answer yourself" test.
  • COBOL: An ancient language used by banks and governments. It's like reading a book written in a dead language with weird grammar.
    • The Shock: The AI was terrible at COBOL when asked to generate an answer from scratch. It could pick the right answer if given a list (because it recognized the words), but it couldn't construct a sentence in COBOL on its own. It's like a translator who can recognize French words in a menu but can't speak a single sentence of French.

4. The "Long Context" Illusion

The AI models claim they can read "1 million tokens" (a massive amount of text) at once.

  • The Reality: Just because the AI can hold a million pages in its memory doesn't mean it can find the right page. As the story got longer, the AI's performance didn't get better; in fact, it often got worse because it got overwhelmed by the sheer volume of information.

The Big Conclusion

The paper concludes that while these AI models are powerful, they are fragile.

  • They rely too much on "cheating" (using multiple-choice options).
  • They forget things that happened a long time ago (the beginning of the code).
  • They get easily confused by irrelevant information.
  • They struggle significantly with older, legacy systems (like COBOL) that power the world's critical infrastructure.

In short: We are trusting these AIs to fix our software and manage our data, but right now, they are more like students who are good at guessing on a test than engineers who truly understand the system. We need to teach them to reason, not just recognize patterns.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →