Context triage ranks available evidence and fills an agent’s context window from highest priority down. It is useful when evidence exceeds the useful context budget or when missing some information has greater consequences than missing other information. A larger window does not remove the need to decide what supports the current task. section 3.2 section 3.2.1
A practical policy divides context into four tiers:
- P0, critical: Always include the active task, system prompt, and safety constraints. section 3.2.2
- P1, important: Include current files, recent tool results, and error traces when space allows. section 3.2.2
- P2, supporting: Compress older conversation turns and background documentation into summaries. section 3.2.2
- P3, deferrable: Leave recoverable material unloaded initially, retaining handles for retrieval when needed. section 3.2.2
Assign policy ownership and classify evidence by task, consequences, and recoverability. Defer an item only if it can be fetched later and its omission will not make the next action unsafe or irreversible. An agent may promote deferred evidence when a hypothesis requires it, but should not demote policy-protected evidence. Record classification reasons in the perception trace. section 3.2 section 3.2.2
Triage a code review
Argus discovers modified files, their Python imports, relevant tests, and project configuration. It sorts them by priority and greedily selects files that fit its token budget; its trace records selections and drops. The implementation can skip even a modified file if it does not fit, despite the stated P0 policy. That gap must be visible when evaluating whether the review received required evidence. section 3.7
Listing 3.8 Argus triage: fit discoveries into the token budget (ch03-perception/argus/perception.py)
# Triage: sort by priority, fill greedily
priority_order = {"modified": 0, "imported": 1, "test": 1, "config": 2}
contexts.sort(key=lambda c: priority_order.get(c.relevance, 3))
trace.files_discovered = len(contexts)
trace.tokens_considered = sum(c.tokens for c in contexts)
selected, used = [], 0
for ctx in contexts:
if used + ctx.tokens <= budget: #A
selected.append(ctx)
used += ctx.tokens
else:
trace.dropped_files.append((ctx.path, ctx.relevance))
trace.files_selected = len(selected)
trace.files_dropped = trace.files_discovered - trace.files_selected
trace.tokens_selected = used
logger.info(
"Perception: %d/%d files selected (%.0f%% selectivity), "
"%d tokens used of %d budget",
trace.files_selected, trace.files_discovered,
trace.selectivity * 100, used, budget,
)
if trace.dropped_files: #B
logger.warning("Dropped: %s", trace.dropped_files)
return selected, trace
Inspect the greedy selection loop and its handling of files that exceed the remaining budget. section 3.7
Misclassification can hide a crucial dependency; an overly tight budget can produce false positives and extra retrieval cycles. Monitor repeated retrieval, token spend per successful outcome, and reliable use of critical evidence against workload baselines. Compare token costs only between designs that meet the same required outcome, authority boundary, and acceptance evidence. section 3.2.5 section 3.8 section 2.3.5
Context triage can work with progressive discovery, which finds evidence as the task develops, and semantic compaction, which compresses selected but verbose context. Preserve decision-critical evidence until the relevant decision is resolved. section 3.8
