---
title: "Rerank and hand hits to the session"
lesson_id: "05"
---

# Rerank and hand hits to the session

- **Lesson ID:** 05
- **Goal:** Merge BM25 and dense hits, rerank a short list, and hand winners to the packer.
- **Human lesson:** [05-rerank-and-hand-off.html](05-rerank-and-hand-off.html)

## Prerequisites

- Lessons 03 and 04.

## Inputs, outputs, and artifacts

- **Inputs:** Lexical hits and dense hits.
- **Outputs:** Four chunks for the context assembler, or a Spotlight tool path.

## Agent build steps

1. Union by chunk id.
2. Offer weighted sum, on-device judge, or Spotlight-only.
3. Keep the judge on SystemLanguageModel. No public cloud.
4. Hand winners to a Dynamic Profile pack on LanguageModelSession.
5. Cite [WWDC26 246](https://developer.apple.com/videos/play/wwdc2026/246/) and [WWDC26 326](https://developer.apple.com/videos/play/wwdc2026/326/) lightly.

## Constraints

Short list only. Honest APIs. No em dashes. Hybrid merge stays Swift for the session hand-off.

## Key concepts

- Union BM25 and dense hits by id. Rerank tens of chunks, not thousands.
- Rerank can be a weighted sum or an on-device judge.
- Pass winners to the context assembler as search-lane slices.
- A Dynamic Profile can put those hits in `Instructions`.

## Takeaways

- Pass a small number of chunks, such as four, to the packer.
- `LanguageModelSession(profile:)` is the hand-off pattern.
- Cap what you put in instructions even on the Spotlight path.

## Acceptance checks

- Three rerank options are listed.
- Public-cloud judge is rejected.
- Agent brief link is present.
