Context Engineering and Prompt Management

Context Engineering and Prompt Management

Context Prioritization — Stack

Context prioritization › Stack

29 of 57 in this book · 3 min read

Technology landscape as of 2026-10-10. Knowledge cutoff May 2026.

Selection criteria

The mechanism has to turn incomparable candidates into one ordered list, fast, and explain itself afterwards.

  • Cross-source comparability. Whether the mechanism operates on scores (and therefore needs them calibrated) or on ranks (and therefore does not).
  • Latency budget. Where the mechanism sits relative to the model call. Anything that scores every candidate with a neural model adds its own inference to every request.
  • Redundancy handling. Whether diversity among selected items is expressible at all, or whether the mechanism can only rank by relevance.
  • Constraint expression. Whether floors, caps, per-class quotas, and token-size awareness can be stated declaratively, or have to be bolted on around the ranker.
  • Determinism. Whether repeated runs over an identical candidate set produce an identical order, including ties.
  • Explainability. Whether the mechanism can report, per candidate, the contribution that produced its score and the reason it was cut.
  • Tunability without retraining. How a product changes the balance between freshness and relevance — a configuration edit, or a training run.
  • Evaluability. Whether a change to the policy can be scored offline against recorded candidate sets before it touches traffic.

Options

Option Best for Watch out for
Rank fusion (reciprocal rank fusion and its variants) Combining producers whose scores are on incomparable scales, which is the normal case Discards score magnitude, so a near-perfect match and a marginal one from the same producer are treated as adjacent ranks
Weighted linear score combination Few sources with scores you have actually calibrated, and a need to express strength of evidence Requires per-source normalisation that silently decays as any producer changes; weights become folklore nobody can re-derive
Cross-encoder rerankers (open reranker models, hosted rerank endpoints, late-interaction models) Getting genuinely better relevance ordering within one textual candidate class Scores one query-document pair at a time, so cost scales with candidate count; says nothing about non-textual candidates like memory or tool output
Maximal marginal relevance and other diversity-aware selectors Candidate sets with heavy redundancy, especially overlapping document chunks One more parameter to tune, and an aggressive diversity setting discards genuine corroboration along with duplication
Rule-based slot allocation (fixed quotas per class with fallback) Products that need a predictable context shape and auditable behaviour more than optimality Quotas are a standing product decision that goes stale; reserved room is wasted whenever a class has nothing good
Learned ranking over joint features (gradient-boosted trees or small models over source, score, age, length) High-volume products with enough labelled outcomes to train on Needs outcome labels that most products do not collect; a ranker trained on past context becomes a feedback loop
Search-engine fusion and hybrid scoring in the retrieval layer (Elasticsearch, OpenSearch, Vespa, vector databases with hybrid modes) Reusing an existing scoring stack for the document-shaped portion of the candidate set Prioritises inside one index only; the final ordering across memory, history, and tool results is still yours to decide
Bin-packing by token cost with value weights Making the room constraint explicit when candidates vary enormously in size A greedy value-per-token selection systematically prefers short candidates and can starve a long but decisive passage