This analysis examines the test coverage across the llama_index monorepo, covering 946 test files across 600+ test directories. The project uses pytest with a 50% minimum coverage threshold enforced in CI. While the core framework has solid coverage foundations, several critical gaps exist in satellite packages, core subsystems, and integration test depth.
Key findings:
llama-index-finetuninghas zero test coverage (2,236 LOC)llama_index/core/instrumentation/has no dedicated test directory (786 LOC)- Callback integrations are severely undertested (33% have tests, all shallow)
response_synthesizers,retrievers, andselectorsin core have <10% test coverage- Many integration packages have only import-verification tests, not behavioral tests
| Module | Source Files | LOC | Impact |
|---|---|---|---|
core/instrumentation/ |
25 | 786 | HIGH - Observability/monitoring backbone |
core/composability/ |
3 | 110 | LOW - Small but entirely untested |
core/settings.py |
1 | 248 | MEDIUM - Global configuration singleton |
core/bridge/ |
5 | 212 | MEDIUM - Pydantic/LangChain interop (heavily used, never directly tested) |
core/instrumentation/ is the most critical gap. It contains the event handler
system (agent, chat_engine, embedding, LLM, query, rerank, retrieval, synthesis
events), span tracking, and the dispatcher. This infrastructure underpins all
observability and is completely excluded from coverage via pyproject.toml:
[tool.coverage.run]
omit = [
"llama_index/core/instrumentation/*", # explicitly excluded
"llama_index/core/workflow/*",
]Recommendation: Remove the coverage exclusion and add unit tests for:
- Event handler dispatch and registration
- Span lifecycle (open, close, error)
- Event payload serialization
- Dispatcher thread-safety guarantees
| Module | Source Files | LOC | Test Files | Test LOC | Coverage |
|---|---|---|---|---|---|
core/retrievers/ |
6 | 993 | 2 | 23 | ~2.3% |
core/response_synthesizers/ |
13 | 1,925 | 3 | 160 | ~8.3% |
core/selectors/ |
6 | 633 | 1 | 53 | ~8.4% |
core/base/ |
15 | 3,202 | 1 | 510 | ~15.9% |
core/retrievers/ has only one test file (test_composable_retriever.py, 23
lines) covering 6 modules and nearly 1,000 LOC. The retriever is a fundamental
component in every RAG pipeline.
Recommendation:
- Add tests for
BaseRetriever,VectorIndexRetriever, and query transformation logic - Test retriever composition and chaining
- Test async retrieval paths
- Add edge cases: empty results, malformed queries, metadata filtering
core/response_synthesizers/ has only test_generate.py and test_refine.py
for 13 source modules covering tree summarize, compact, accumulate, and other
synthesis strategies.
Recommendation:
- Add tests for
TreeSummarize,CompactAndRefine,Accumulatesynthesizers - Test streaming response synthesis
- Test token-budget-aware synthesis
- Test error recovery in multi-step synthesis chains
core/workflow/ (14 modules, 196 LOC) has no dedicated test directory. It is
tested indirectly via tests/agent/workflow/ (10 files, 2,478 lines), but these
are integration tests exercising workflows through the agent layer. There are no
isolated unit tests for:
context.py/context_serializers.py- Workflow context managementretry_policy.py- Retry and error handling policiesdecorators.py- Workflow step decoratorsevents.py- Workflow event primitivesdrawing.py- Workflow visualization
Recommendation: Add unit tests for workflow primitives independent of agents, especially context serialization round-trips and retry policy behavior.
| Metric | Value |
|---|---|
| Source files | 23 |
| Lines of code | 2,236 |
| Test files | 0 |
This package provides fine-tuning engines for OpenAI, Azure OpenAI, MistralAI, embedding adapters, sentence transformers, Cohere rerankers, and cross-encoders. It also includes dataset generation utilities and a fine-tuning callback handler.
Recommendation (Priority: HIGH):
- Add unit tests for
OpenAIFinetuneEnginewith mocked API calls - Test
EmbeddingQAFinetuneDatasetgeneration and serialization - Test
validate_json.pywith valid/invalid training data - Test
OpenAIFineTuningHandlercallback event recording - Test dataset generation utilities with controlled inputs
3 test files cover only the Pandas/Polars query engines and exec_utils. Untested:
ParamTuner- Parameter tuning utilityNudge- Prompt optimization moduleJSONAlyzeQueryEngine- JSON query engine- All 3 natural language retrievers (
NLCSVRetriever,NLDataFrameRetriever,NLJSONRetriever) - Output parsers and prompt templates
Recommendation: Add tests for the NL retrievers and JSONAlyze engine since these are user-facing query interfaces.
Only 2 test files cover the RAG CLI base. Untested:
new_package/- Package scaffolding from templatesupgrade/- Code migration utilitiescommand_line.py- Main CLI dispatcher and argument parsing
Recommendation: Add tests for package template generation (deterministic output) and CLI argument parsing/dispatch.
Only 4 of 12 callback packages have tests, and all 4 are shallow import-only checks that merely verify class inheritance:
def test_handler_callable():
names_of_base_classes = [b.__name__ for b in Handler.__mro__]
assert BaseCallbackHandler.__name__ in names_of_base_classesPackages without any tests (8): agentops, aim, argilla, arize-phoenix, honeyhive, langfuse, literalai, opik
Recommendation (Priority: HIGH):
- Add mocked behavioral tests for at least the top 3 most-used callbacks (langfuse, arize-phoenix, wandb)
- Test event serialization, callback registration/deregistration, error handling when the external service is unavailable
- Replace import-only tests with actual functionality tests
Missing: azure-openai, baseten, clarifai, fireworks, gaudi, huggingface-openvino, instructor, ipex-llm, opea, openvino-genai, premai
Recommendation: Prioritize azure-openai (widely used) - add mocked tests
for embedding generation, batch operations, and error handling.
Missing: clarifai, gaudi, ipex-llm, maritalk, mlx, mymagic, openvino-genai, openvino, optimum-intel, premai, text-generation-inference
Recommendation: Add at least class instantiation + mocked completion tests for
each. Prioritize mlx (growing Apple Silicon adoption).
Many integration packages that nominally "have tests" only test class instantiation or inheritance. A sample analysis found:
| Package | Tests | Depth |
|---|---|---|
| Anthropic LLM | 30+ | Excellent - mocks, streaming, multi-provider, error handling |
| OpenAI Embeddings | 6 | Good - retry logic, error exhaustion, batch operations |
| Cohere Embeddings | 13 | Good - async, images, batch, serialization |
| Groq LLM | 3 | Shallow - only integration tests requiring API key |
| All 4 callback packages | 1 each | Trivial - import/inheritance check only |
Recommendation: Establish a minimum test standard for integrations:
- Class instantiation with required parameters
- At least one mocked completion/embedding call
- At least one error handling scenario
- Serialization round-trip test
The CI enforces only 50% minimum coverage (COV_FAIL_UNDER: 50). For a
framework this widely used, consider:
- Raising to 60% for
llama-index-core - Requiring 40% minimum for all integration packages
- Adding differential coverage checks on PRs (already have
diff-coverin llama-dev)
The pyproject.toml explicitly excludes instrumentation/* and workflow/* from
coverage measurement. These are production-critical subsystems that should be
measured and tested.
The test suite is predominantly unit tests. Consider adding:
- Contract tests for integration packages: Verify each integration implements the base interface correctly (beyond just inheritance checking)
- Snapshot/regression tests for response synthesizers: Ensure deterministic outputs don't change unexpectedly
- Property-based tests (with Hypothesis) for text splitters and node parsers: These have complex edge cases that are well-suited to fuzzing
- Performance regression tests for hot paths (embedding batching, retrieval)
While pytest-asyncio is configured and used, async code paths don't consistently
have test parity with their sync counterparts. Key areas to audit:
- Async retrieval in
core/retrievers/ - Async streaming in response synthesizers
- Async workflow execution
- Add tests for
llama-index-finetuning- 2,236 LOC with no tests; mock external API calls and test dataset generation/validation logic - Add tests for
core/instrumentation/- Remove coverage exclusion; test event dispatch, span lifecycle, and handler registration - Improve callback integration tests - Replace trivial inheritance checks with mocked behavioral tests
- Expand
core/retrievers/tests - Only 2.3% coverage on a fundamental RAG component - Expand
core/response_synthesizers/tests - Only 8.3% coverage; test all synthesis strategies - Add
core/settings.pytests - Global configuration has no dedicated tests - Add unit tests for
core/workflow/primitives - Context serialization, retry policies, decorators
- Add mocked tests for untested embedding integrations (especially azure-openai)
- Add mocked tests for untested LLM integrations (especially mlx)
- Improve
llama-index-experimentalcoverage - NL retrievers and JSONAlyze engine - Improve
llama-index-clicoverage - Package scaffolding and CLI dispatch - Establish minimum test standard for all integration packages
- Raise CI coverage threshold from 50% to 60% for core
- Remove
instrumentation/*andworkflow/*from coverage exclusions - Add contract tests for integration base class compliance
- Investigate property-based testing for text splitters/node parsers