5.8 KiB
Phase-specific context selection
Historical investigation note: new v10 requests restore full evidence and note/question history; v8/v9 selection is retained only for frozen-request compatibility. Other phase optimizations remain active. See investigation-full-history-v10.md.
The phase_selection_v1 policy deliberately excludes information from model requests. It does not remove or rewrite canonical context, source artifacts, evidence, immutable requests or history in the case package. docs/architecture.md is unchanged. JSON consolidation still follows selection.
Selection rules and safeguards
| Phase | Excluded working information | Protected information |
|---|---|---|
| Interpretation | Unread file catalog entries (replaced by count/scope); context identity/hash scaffolding; navigation pointers on ordinary sources; archive navigation inside provenance | All readable facts, observations, expectations, assumptions, entities and quality warnings; source IDs; source_ref provenance links; entity/quality classification pointers; temporal and snapshot scope |
| Hypotheses | Same case-source scaffolding; interpretation navigation pointers and hash/reference bookkeeping | Every interpretation statement and every readable case source, typed identities, contradiction/unknown data, prior-generation feedback and policy |
| Investigation v9 | All but the latest active-hypothesis note; resolved-question flags move to an ID-to-text closed-question mapping | Current confidence/disposition, complete active proposal, open questions, closed-question identity (prevents duplicate add/resolve), unassessed results, previous result, evidence index and exact recall protocol |
| Diagnosis | Initial proposal rationale/search plans and old chronological notes; active-step bookkeeping; settled budget action history, counters and credit policy; input/source/DB catalogs | All evidence results including empty/negative captures, coverage and provenance; complete interpretation; original observations, entity context, runtime facts, quality warnings; hypothesis end states, falsification criteria, current notes, questions, uncertainty and early-review request |
| Handoff | Investigation direction, stage/summary fields redundant with confirmed diagnosis; storage hashes | Diagnosis, original observations/expectations, remaining unknowns and contradictions, technical facts, human-data requirements, exact evidence contents, local-context reference pairs and mandatory policy |
Read-only phases without a retrieval dialogue do not omit arbitrary unmentioned facts or select facts by keywords/top-N. Their lost context cannot currently be requested from within that one-shot call, so such filtering would risk hiding the decisive clue. A large part of their current savings comes from hundreds of unread catalog entries, not deleting meaningful technical facts. Source references used to ground entity identity remain, even where they look like navigation. Raw database values named path/sha256 are not stripped.
Investigation retains v8 evidence selection and bounded exact recall. Older notes are model claims, not new observations. Their removal does not remove the underlying evidence; older positive or negative results remain discoverable in the index and retrievable by ID. Closed-question text is retained to prevent invalid duplicate questions; it is not blindly discarded to save characters.
Final diagnosis and handoff retain all supplied evidence payloads. They do not reuse the investigation's narrow evidence window: there is no retrieval turn in these stages. An evidence-grounded inconclusive diagnosis remains a valid controlled outcome; no cause or outcome is forced for a known fixture.
Versioning and replay
New modern interpretation contexts store context_selection=phase_selection_v1 and use case_interpretation_resolved_v8. Existing persisted contexts without the marker rebuild their previous prompt. New hypothesis contexts use hypotheses_v4; saved versions remain frozen. New investigation contexts use investigation_project_v9; old contexts keep their prior view. New diagnosis requests use v5 (including early review); new handoff requests use change_request_v6. Provider retry and crash recovery reconstruct the stored version. Original output contracts and budgets are unchanged.
Inspecting exclusions
analysis/phase_selection.py contains explicit per-phase selectors. Its audit_out lists removed working-view paths without copying their contents. Original context and transmitted request are both archived, so exclusions remain inspectable after a run.
Run scripts/measure_phase_selection.py PACKAGE.zip to project supported saved model views through the new policy. It returns per-request before/after all-message character counts and excluded paths. It does not call a provider, mutate archives or claim a token price. Baselines include the previous lossless codec; both sides include their system prompt and existing correction messages. This is a stored-view projection, not a claim of identical future LLM decisions.
Offline comparison on the Bug 20 successful full-run archive:
| Phase | Before (previous codec) | Selected | Additional reduction |
|---|---|---|---|
| Interpretation, two saved calls | 155,961 | 87,801 | 43.7% |
| Hypotheses | 75,623 | 40,208 | 46.8% |
| Early diagnosis | 62,270 | 50,584 | 18.8% |
| Handoff | 31,908 | 31,338 | 1.8% |
Bug 17: interpretation 71,186 -> 36,445 (48.8%); hypotheses 71,000 -> 35,106 (50.6%). Investigation: 18 stored contexts projected v8 -> v9, 1,228,785 -> 1,197,858 all-message characters (2.5%). These gains are additional to earlier lossless compression and evidence-window selection. The smaller handoff gain reflects substantial earlier trimming. Actual token usage and quality still require a live run.