Troubleshooting
On this page
This page lists concrete, source-verified failure modes โ not speculative advice.
result.context is just a placeholder message
Symptom: result.context is "๐ ุงูู
ุนููู
ุงุช ุงูู
ุณุชุฑุฌุนุฉ:\nูุง ุชุชููุฑ ู
ุนููู
ุงุช.\nโโโ ููุงูุฉ ุงูุณูุงู โโโ" (or the English equivalent).
Cause: SmartContextComposer.compose() was called with an empty chunks list โ meaning retrieval + filtering + ranking together produced zero results.
Diagnose:
result = engine.run(query)
print(result.total_retrieved, result.total_after_filter, result.total_after_rank)
total_retrieved == 0โ retrieval itself found nothing. Check thatindex()/index_documents()was called with a non-emptychunks/textslist and (if using vector search) a workingembed_fn/vector_db/vector_store_adapter.total_retrieved > 0buttotal_after_filter == 0โFilterConfigthresholds (min_chunk_length/max_chunk_length/noise patterns) excluded everything retrieved.
result.guard_passed is False
Check result.guard_warnings โ it will contain one of exactly these (verified strings from ContextGuard.validate):
"context is empty โ "โ see above."context is too short (N characters < M)."โ raise your retrievaltop_kor lowerGuardConfig.min_context_length."context is not relevant to the query (similarity=X.XXX < Y.YY)."โ only appears ifcheck_relevance=Trueand anembed_fnwas passed toContextGuard. Lowerrelevance_thresholdor investigate your embedding model/retrieval quality.
Note "context is too long" and "no valid source found in context." are warnings that do not flip guard_passed to False โ they can appear even when guard_passed is True.
ValueError: weights length must equal n_queries.
Raised by WeightedBudgetAllocation.allocate(). Make sure len(weights) == n_queries exactly when constructing it directly. If you're using ComplexityBasedAllocation, this is handled for you internally as long as you pass analyses with the correct length โ if it doesn't match, it falls back to equal allocation rather than raising.
ValueError: prefix_length N exceeds chunk text length M.
Raised by legacy_compat.PrefixDeduplication.deduplicate() on the first chunk shorter than prefix_length. Either lower prefix_length, filter out short chunks first, or switch to HashDeduplication (no length restriction).
AttributeError: can't set attribute
You tried config.separator = "..." or config.template = "..." directly. Both are read-only properties on ContextEngineConfig. Use config.composer.separator = "..." / config.composer.template = "..." instead.
TypeError: Can't instantiate abstract class ... with abstract method ...
You subclassed one of the strategy ABCs in strategy.py without implementing every @abstractmethod. For HybridRetrieverStrategy specifically, remember it requires both retrieve() and the method property.
from context import validate_chunk gives None
This is the documented __init__.py shadowing quirk โ see API Overview. Import from the submodule instead: from context.legacy_compat import validate_chunk.
My custom composer/filter/ranker isn't being used
Verify you passed it to the correct constructor keyword: chunk_filter=, ranker=, composer=, guard=, query_analyzer=, budget_allocator=, retriever= (note retriever= expects a HybridRetriever-shaped object, while the others expect their respective *Strategy ABC). Also double check you didn't subsequently call engine.index(...) in a way that silently rebuilds a default retriever โ see the warning in api/engine.md.
Performance is degrading over a long-running process
Check two things via engine.get_performance_report():
cache.hit_rateโ if low and you expect repeated queries, verifyCacheConfig.enabled=Trueand that queries are normalized consistently (the cache key is based on the lower-cased, stripped query text plus sorted filters โ small wording differences produce different keys and thus cache misses).VectorRetriever._query_cachegrows unboundedly for the lifetime of the process (no eviction) โ if you're embedding a huge number of distinct queries over a long-running process, this is an unbounded memory growth point to be aware of, separate from the boundedContextCache. This only applies to in-memory mode (embed_fn); a nativevector_dborvector_store_adapterhas no client-side query cache to grow.
Need more detail?
Every class's API page includes a "Common Mistakes" section with issues specific to that component โ see API Overview.