Skip to main content

Module selection

Module selection 

Source
Expand description

Context selection policy: build candidate ledger items and select the working set for a turn.

This is a pure policy layer. It consumes already-loaded candidate sources (harness fragments, instruction selections, pins, compaction summaries, transcript entries, skills) and produces a ContextLedger whose items carry a ContextVisibility and a human-readable reason for every inclusion or omission decision. Side effects belong to the caller.

§Selection order

  1. Always-loaded harness context (visible, never evicted by budget).
  2. Current user turn (visible, outside ordinary budget eviction).
  3. Active pins (pinned, before ordinary transcript items).
  4. Applicable closest AGENTS.md before broader guidance (visible).
  5. Active skill instructions then discovered skill metadata (visible).
  6. Latest compaction summary (visible) when older transcript turns are omitted; older summaries stay archived.
  7. Recent transcript entries (visible) within budget, oldest evicted first under pressure.

UI-only and live-only transcript entries are never selected. Items whose token estimate alone would exceed the available input budget are marked ContextVisibility::Blocked instead of being silently truncated.

Structs§

CompactionSummaryCandidate
A compaction summary considered for selection.
HarnessCandidate
A harness context fragment considered for selection.
InstructionCandidate
An instruction source considered for selection.
PinnedCandidate
A pinned working-set item considered for selection.
SelectionInput
All candidate sources for a turn, ready for selection.
SkillCandidate
A loaded skill considered for selection.
TranscriptCandidate
A transcript entry considered for selection.
UserTurnCandidate
The current user turn, kept outside ordinary budget eviction.

Functions§

select_context
Select the context working set for a turn.