jevfieldnotes
TUTORIALS

Select context while keeping required facts

Keep relevant conversation chunks and protect the goal, order IDs and unresolved commitments.

2 MIN READ · PLUS RUN TIME · UPDATED 20 SEP 2026
Download Python example ↓

Python 3.10+ · No packages to install · Local demo uses supplied answers

Select chunks without editing the transcript

The lab proposes keep or omit_from_candidate for each chunk. The original transcript stays intact. This makes it possible to compare the shorter selection with the full conversation and recover anything missing.

Run the local example

Download the ZIP above, unzip it and open a terminal in that folder. You need Python 3.10 or later; there are no packages to install. dry-run writes request payloads. demo reads the supplied, hand-written responses and runs the application logic. Use a new output folder for each run.

python jev_lab.py --mode dry-run --out requests
python jev_lab.py --mode demo --out demo-run

Mark the facts you must keep

The goal and an unresolved commitment have protected flags. The example deliberately gives them low model values: your application should keep them anyway. Apply the same rule to system instructions and other required context. Reassemble selected chunks in conversation order.

Include the task in each question

A chunk can matter for one task and be irrelevant to another. Send the current task and the exact chunk together, retaining a stable ID. If you truncate input before the request, inspect what was actually sent; a model cannot judge text that was removed.

Check which of the five chunks survive

The supplied answers keep the goal, order ID, threshold-boundary example and commitment. Only the weather chunk is omitted. The protected goal and commitment remain despite low values. Inspect results.json to confirm which chunks were kept by a rule.

keep = sample.get('protected', False) or answer['noul'] >= cutoff
# Never edit the original transcript in this step.
# Reconstruct selected chunks in original order.

Replay a completed task with both contexts

Pick a conversation whose outcome you know. Run the downstream task once with full context and once with the selection, keeping model settings fixed. Check missing facts, wrong actions and completion before comparing token counts. A smaller prompt that loses an order ID is not an improvement.

Try your own chunks

Use the samples.json structure for your data, including protected flags. Set TYPESAFE_API_KEY and replace 0.8 below with a cutoff chosen on validation conversations. The starter requires --calibrated for this live Noul task; that flag does not perform calibration. Only --high affects this keep/omit policy.

python jev_lab.py --mode live --samples own-chunks.json \
  --high 0.8 --calibrated --out live-context
# Replace 0.8 with a threshold selected on validation transcripts.

Keep full context when selection fails

A timeout, missing chunk or invalid answer must not silently drop information. Fall back to the original context or an explicit review path. Retain both the original and selected versions while evaluating the change.

Test records, output files and retry behavior

The five local labs passed 27 synthetic cases and 18 response-validation and injected-failure tests. These tests cover application logic. No live Jev call was made.

Files written by a run

results.json contains validated decisions and raw answers. failures.json records failed rows. manifest.json records the run mode, model identifiers, dataset and rubric hashes, thresholds and completion counts. Demo runs omit latency and token usage. Live timing includes network and retries; recorded token usage covers successful responses only. The client does not infer a bill.

What happens when a request fails

The client rejects invalid answer types, unknown labels, inconsistent distributions and nonfinite values where applicable. Authentication and validation errors stop immediately. Selected HTTP failures, including 429 and 529, get at most three attempts. Numeric Retry-After is supported within a ten-second wait budget; HTTP-date values are not parsed. Network timeouts stop rather than retrying a potentially billed call.

Failed rows produce a nonzero exit status. Quality metrics cover valid rows, so read the failure count too. The ZIP’s README documents these behaviors.

Related official reading

Jev model limitationsRead the documented problems with distracting context and multi-step inference before evaluating context selection.