
Knowledge Cutoff: Why Your Assistant Suggests Deprecated APIs with Confidence
- كاتب موثّق
محتويات المقال
orders.append(new_rows, ignore_index=True) and a short explanation. CI fails with AttributeError: 'DataFrame' object has no attribute 'append'. pandas deprecated that method in 1.4 and removed it in 2.0, and the project runs a newer major version. The assistant never hinted that its answer might be out of date.
The common misconception
Assistants often do know recent APIs, so the misses look like exceptions. The tone never changes. A stale answer is written with the same assurance as a current one. Some assistants search the web, so the same question is current in one tool and stale in another. It's natural to assume a system would say "I'm not sure about the newest version" when it should.
What actually happens
Knowledge stops at a cutoff
The effective cutoff is fuzzier than the reported one
Why the deprecated API wins
Nothing in the output marks it as stale
The same task, old API and current API
import pandas as pdorders = pd.DataFrame({"id": [1, 2], "total": [120, 80]})new_rows = pd.DataFrame({"id": [3], "total": [50]})# Common in code written before pandas 2.0:orders = orders.append(new_rows, ignore_index=True)# AttributeError: 'DataFrame' object has no attribute 'append'import pandas as pdorders = pd.DataFrame({"id": [1, 2], "total": [120, 80]})new_rows = pd.DataFrame({"id": [3], "total": [50]})# DataFrame.append was removed in pandas 2.0; concat replaces itorders = pd.concat([orders, new_rows], ignore_index=True)print(len(orders)) # 3from datetime import datefrom importlib.metadata import versionpackages = ["pandas", "numpy", "scikit-learn"]pins = "\n".join(f"- {name} {version(name)}" for name in packages)system_prompt = f"""Today is {date.today().isoformat()}.This project uses exactly these versions:{pins}Use only APIs that exist in these versions. If you are not sure that anAPI exists in them, say so instead of guessing."""print(system_prompt)How to apply it in your project
Pin and state your versions Keep a lockfile, and put the versions that matter, plus today's date, into the system prompt or the project instructions your assistant reads. Ground answers in current docs For anything that changes, such as APIs, prices or policies, supply the current documentation or enable a search tool instead of relying on memory. Make deprecations loud Fail CI on deprecation warnings and run linters that know your library versions, so stale suggestions fail fast. Check generated code against release notes when you upgrade Before a major upgrade, search the codebase for APIs the release notes remove, including code an assistant wrote.
Key takeaways
A model's knowledge stops at a training cutoff, and the model keeps answering long after it. Effective cutoffs are fuzzy and vary by topic, so recent releases may be thin or missing even before the cutoff. Deprecated APIs are part of the training data, and nothing in the output marks them as old. The model doesn't know today's date or your versions unless you put them in the prompt. Ground the model with current docs and versions, and let tests and warnings catch the rest.
📚 المصادر
Cheng et al., Dated Data: Tracing Knowledge Cutoffs in Large Language Models, arXiv:2403.12958 Wang et al., LLMs Meet Library Evolution: Evaluating Deprecated API Usage in LLM-based Code Completion (ICSE 2025), arXiv:2406.09834 Models overview: reliable knowledge cutoff and training data cutoff — Claude API Docs Web search tool — Claude API Docs What's new in pandas 2.0.0: removed DataFrame.append — pandas documentation
التعليقات (0)