Fabrication
Generating reference to non-existent APIs, packages, or symbols.
a.k.a. hallucinationa.k.a. api-hallucinationa.k.a. package-hallucinationa.k.a. confabulation
Description
The agent emits code that references APIs, packages, functions, or symbols that do not exist in any reachable dependency or runtime. Syntactically plausible, factually false. Distinct from obsolescence (real-but-retired) and from dependency blindness (real-and-present-but-ignored).
Detection signals
- Agent emits an import or function call whose identifier is absent from all declared dependencies and stdlib.
- Static analyzer (e.g., pyflakes, tsc) flags the reference as undefined at pre-commit.
- Execution-grounded check (sandboxed run) raises ImportError, AttributeError, or analogous resolution failure.
- LSP-based symbol lookup returns no candidate.
Prior work
- Fang Liu (2024) — Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Code
- Joseph Spracklen (2024) — We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs
Related failure modes
- Obsolescence — Using deprecated APIs, retired packages, or outdated library versions — often because the model's training data pre-dates current releases.
- Dependency blindness — Reimplementing functionality that already exists in reachable code.
- Supply-chain attack — Slopsquatting, typosquatting, compromised MCP servers.
Mitigating tools
- agenta — Open-source LLMOps platform: prompt playground, prompt management, LLM evaluation, and observability.
- agentic-security — Agentic LLM vulnerability scanner and AI red-teaming kit.
- AI-Red-Teaming-Playground-Labs — AI red-teaming labs: turnkey training environments for attacking AI systems.
- Arize Phoenix — Open-source LLM tracing and evaluation platform built on OpenTelemetry.
- AutoRAG — Open-source framework for retrieval-augmented generation (RAG) evaluation and optimization.
- DeepTeam — Open-source LLM red-teaming framework from Confident AI with 40+ attack vulnerabilities.
- Context Hub — Up-to-date, curated API docs for coding agents.
- Context7 — Up-to-date, version-pinned library documentation for coding agents — delivered as an MCP server.
- coze-loop — Full-lifecycle AI agent management platform with debugging, evaluation, and monitoring.
- DeepEval — The open-source LLM evaluation framework for testing and evaluating LLM applications across 20+ custom and researched metrics.
- docetl — LLM-powered data processing with automatic pipeline optimization.
- FuzzyAI — A powerful tool for automated LLM fuzzing from CyberArk.
- garak — The LLM vulnerability scanner.
- giskard-oss — Open-source evaluation and testing library for LLM agents and ML models.
- Guardrails AI — Output validation framework with a catalog of validators and reask-on-failure loops.
- Guidance — Programmable interleaving of prompt, control flow, and constrained generation.
- helm — Holistic Evaluation of Language Models (HELM).
- Instructor — Pydantic-typed structured output for LLM APIs with automatic retries.
- judgeval — The open source post-building layer for agents: evals, traces, and regressions.
- lighteval — Hugging Face all-in-one toolkit for evaluating LLMs across multiple backends.
- llm-guard — The Security Toolkit for LLM Interactions.
- lm-evaluation-harness — A framework for few-shot evaluation of language models.
- lmms-eval — One-for-all multimodal evaluation toolkit across text, image, video, and audio tasks.
- lmnr — Laminar — open-source observability platform purpose-built for AI agents.
- logfire — Pydantic Logfire — observability for AI agents, LLMs, and Python apps built on OpenTelemetry.
- magic-mcp — Magic MCP — generate frontend components inside Cursor, Windsurf, and Cline.
- mlflow — Open-source platform for the machine learning lifecycle — experiments, tracking, models, and LLM evaluation.
- mypy — Static type checker for Python. Catches mismatched types before runtime.
- NeMo Guardrails — Colang-based programmable guardrails for LLM applications.
- evals — Framework for evaluating LLMs and LLM systems, plus an open registry of benchmarks.
- openlit — Open-source AI engineering platform: OpenTelemetry-native LLM observability, guardrails, evaluations, prompt management.
- opik — Debug, evaluate, and monitor LLM applications, RAG systems, and agentic workflows.
- Outlines — Constrained decoding via finite-state machines over regex, JSON Schema, and CFGs.
- llm-app — Ready-to-run cloud templates for RAG, AI pipelines, and enterprise search with live data.
- pezzo — The cloud-native open-source LLMOps platform.
- pr-agent — AI-powered tool for automated pull-request analysis, feedback, and suggestions.
- pre-commit — Multi-language framework that runs configurable hooks before commits land — denies the commit on hook failure.
- promptbench — Unified evaluation framework for large language models with adversarial perturbations.
- promptflow — Build high-quality LLM apps — from prototyping, testing to production deployment and monitoring.
- promptfoo — Test prompts, agents, and RAGs — red-teaming, pentesting, and vulnerability scanning for LLMs.
- promptmap — Security scanner for custom LLM applications.
- PydanticAI — Structured-output agent framework with Pydantic-typed tool and return schemas.
- Pyright — Microsoft's fast static type checker for Python.
- PyRIT — The Python Risk Identification Tool for generative AI (PyRIT).
- ragas — Supercharge your LLM application evaluations — RAG- and agent-centric metrics.
- ragflow — Open-source RAG engine based on deep document understanding.
- Smolagents — Minimalist code-agent library that expresses actions as executed Python.
- TruLens — Evaluation and Tracking for LLM Experiments and AI Agents
- uqlm — Uncertainty Quantification for Language Models.