Skip to main content

On fast-moving libraries, I hallucinate APIs and drift across versions

PhaseImplementationRolesEngineer · ArchitectSeverityHighApplies toAll coding agentsEvidenceOfficial docs

In one sentence: when you ask me to call into a fast-moving library, I fill the gaps from training memory—I may use an API that's deprecated or has a changed signature, mix usage from different major versions, or even hallucinate a method that doesn't exist. The code "looks right," the compiler won't always catch it, and it only blows up at runtime.

Symptom​

You ask me to "write an X with this library." I write it fluently: method names, argument order, return values—no hesitation. Then you run it, and—

  • xxx is not a function: the method I called doesn't exist in the version you pinned, or it was renamed a while ago;
  • arguments don't line up: I passed them by an old signature from memory, but the new version moved that parameter, changed its type, or added a required one;
  • half new, half old: in the same block, initialization uses the new-version style while the calls below use the old-version style, and the two don't fit together.

The faster a library iterates, the more likely I am to trip here—frontend frameworks, cloud-vendor SDKs, AI/LLM client libraries. The version I have the "strongest impression" of is often no longer the one you installed today.

Why this happens​

I may reuse old documentation or a familiar call shape without checking the installed version, exports, signatures, and migration notes. Training knowledge can lag, but agents can read manifests and current sources; they are not necessarily unaware of the present version.

Naming a version is insufficient: a package.json range may differ from the lockfile or runtime resolution, and online docs may default to latest. I should check the actual dependency and first-party docs for that version, then use types, compilation, or a minimal call to validate the visible contract.

Context7 can retrieve version-related material; it is a documentation connector rather than proof of API correctness. Check library identity, version coverage, and the returned excerpt's origin. Disclose missing coverage instead of treating a nearby version as verified.

Consequences​

  • Stale API. I used a method that's deprecated or has a changed signature. In a strongly typed language the type checker may catch it on the spot; in weakly typed or dynamic languages it usually surfaces only when that line runs.
  • Mixed versions won't run. Half-new, half-old usage stitched together passes review line by line, yet the whole thing won't start.
  • Hallucinated methods are the hardest to catch. A method this library never had, with a convincing name—you can't easily spot it in review, until runtime reports "undefined."
  • The debugging cost lands on you. These errors often don't surface while I'm writing the code; they show up when you run tests or even after release, far more expensive to track down than one trip to the docs would have been.

What to do instead​

  1. Check the actual version first. Read manifests, lockfiles, and available runtime information before deciding whether to ask you. A version range or a number in the prompt is not proof of what is installed.
  2. Use first-party sources for that version. Context7 and similar retrieval can help, but returned material needs a verifiable origin and version. If coverage is missing, check official versioned docs/source or disclose that verification is unavailable.
  3. Validate the visible contract. Run types, compilation, or a minimal smoke call according to risk. Passing supports tested paths rather than every parameter and semantic behavior.
  4. Separate facts from illustrations. Label fictional libraries, unexecuted code, and inferred migrations. Cite the matching source for real methods and parameters.

Example​

Before:

You: write a connection pool with somelib
Me: (calls somelib.createPool(...) from memory—that's the 2.x style;
the 3.x you pinned changed it to new somelib.Pool(...), and it only errors at runtime: createPool is not a function)

After:

You: write a connection pool with somelib@3.x. Check Context7 for the 3.x API first, docs over memory, then run a type check.
Me: (confirms from the doc source that 3.x is new somelib.Pool(...), writes to the real signature,
runs tsc with no errors, and annotates "per somelib 3.x official docs")

The difference isn't that I understand the library better—it's that I now hold a fact that matches your version, plus a gate that can disprove me on the spot, so I don't have to gamble on what "looks right."

Tool differences​

Web fetching, documentation indexes, and MCP retrieval differ in client availability, permissions, and version coverage. This review checked Context7's version-retrieval description and Claude Code's MCP integration docs; neither guarantees that every client retrieves proactively or every library has complete historical coverage.

Record the library, version, and source actually retrieved, then compare them with the installed dependency.

Version notes​

Applicable versions

Checked the Context7 README and Claude Code MCP/best-practice guidance on 2026-10-29. Retained version pinning and signature checks, while validating retrieval availability, document version, and call behavior separately. Types do not catch every runtime or semantic difference. The somelib example is fictional, not a migration claim about a real library.

Further reading and sources​