Skip to content
← Free FDE training guides

Free learning / 40-minute context lab

Give the model the right working packet

Understand context, compare useful and lossy summaries, and refresh stale facts in an original offline exercise.

No account needed. Use your own copy for writing and keep the original as a reference.

Engineering lab library / Run locally

See what survives the summary.

Build a working packet, remove unnecessary detail, then compare missing facts with stale ones. Run the complete exercise offline with Python.

Synthetic records. No provider key or model inference. Runs locally with the standard library.

  1. Start here / Python 3.11+ · Standard library

    First context packet

    Build real JSON packets and compare information loss and freshness without calling a model.

    Python 3.11+ standard library · No installation or account

LockedIn Labs · Original 40-minute context exercise · Updated 20 October 2026

You ask a teammate to write a client update. What do they need in front of them? The current incident, the next step, any restriction and the deadline. They do not need every old conversation. They cannot use a current fact you never supplied. Preparing that working packet is the starting point for context management.

This guide builds an actual JSON request plan in Python. All incidents are fictional. No model runs, no account is needed, and no request leaves your computer. The plan is a provider-neutral teaching envelope, not a ready-made Claude, OpenAI or LangChain API call.

1. Understand context before optimizing it

Context is the information supplied for one model request. It can include instructions, the task, conversation, tool descriptions and evidence. Context management selects and maintains that information. It is an engineering practice, not a programming language or a model.

Three different things often get called memory:

ThingWhat it means here
Learned model parametersPatterns learned during model training
Saved application stateRecords or messages the application retains
Current contextInformation selected into this request

Putting a file in a repository or a note in a database does not automatically make it part of a model call. The application or framework must select it. Retrieval helps find material; a context builder decides what to include.

Think of a colleague receiving an incident packet. That analogy helps explain selection, but it does not mean a model has the same memory or judgment as a person.

2. Run the local context builder

Download the original Python exercise into a new practice folder. Use Python 3.11 or newer. The exercise uses only the standard library, so there are no packages, credentials or model downloads to install. It reads no local project files or account state and writes no files.

Code example
python3 fde-first-context.py test
python3 fde-first-context.py demo
python3 fde-first-context.py inspect --case compact

On Windows, use py -3 instead of python3.

Nine checks cover useful compression, lost constraints, stale facts, false relabeling, refreshed evidence, source scope, excluded state, task preservation and byte counts. A successful test run ends with OK. An observed failing packet is an expected exercise result, not a command failure.

The application-side scope in this small program is an explicit synthetic project marker. It demonstrates checking before copying; it is not an authentication system.

3. Follow the information into the request

The task is to draft an update about incident INC-17, without sending it. The model-visible request plan has three parts:

Text example
APPLICATION                         REQUEST PLAN
                                    ┌─────────────────────────────┐
Task + host instruction ───────────►│ Instruction + current task  │
                                    ├─────────────────────────────┤
Incident INC-17                     │ Evidence                    │
  check scope                       │   source_id + revision      │
  select relevant fields ──────────►│   problem + next_step       │
                                    │   restriction + deadline    │
                                    └─────────────────────────────┘
Old unrelated conversation ── leave out
Runtime permission checks  ── stay in the application

The source restriction says to keep the import paused until the service owner approves a retry. That is essential to the update. The deadline includes UTC (Z); dropping the zone changes what the reader knows.

Open assemble in the file. It checks the source scope and explicitly copies the permitted fields. Adding an unrelated field to the source does not automatically put it in the packet. This is different from serializing the whole runtime object into a prompt.

4. Compare shorter with useful

Predict each case before inspecting it:

Code example
python3 fde-first-context.py inspect --case full
python3 fde-first-context.py inspect --case compact
python3 fde-first-context.py inspect --case lossy
CaseSerialized sizeObservation
full1,002 UTF-8 bytesAll required fields and six diagnostic lines
compact565 UTF-8 bytesAll required fields; no diagnostic repetition
lossy450 UTF-8 bytesRestriction and deadline missing

The useful summary saves 437 bytes while preserving the fields needed for this draft. The shortest version saves another 115 bytes and loses two decision constraints. Size and usefulness are separate questions.

These sizes come from compact JSON serialization followed by UTF-8 encoding. They are not token counts, window limits, model timings or billed usage. Use the token lab to understand that separate representation.

Compaction is reducing what you carry forward. This exercise uses a hand-written field-selection rule. A model-generated prose summary needs its own evaluation: can another person recover the important facts, sources and restrictions? There is no model-generated summary in this program.

5. Refresh facts, not just the label

The incident now advances to revision 2. There is a replacement file, a revised restriction and a new deadline. Compare:

Code example
python3 fde-first-context.py inspect --case stale
python3 fde-first-context.py inspect --case refreshed

The stale packet has no missing fields, yet revision, next_step, restriction and deadline differ from the current record. Completeness does not imply freshness.

The refreshed packet is 568 bytes and preserves the current record. The program's test_relabeling_is_not_refreshing test changes just the old revision label to 2: the version matches, but three fields still disagree. Re-read the record and rebuild the packet instead.

A source can change again after a model drafts an answer. Before a consequential action, the application needs a current permission and source check. A prompt cannot make that later action atomic.

6. Make one controlled change

Keep the original exercise. Work in a separate copy.

  1. In the lossy branch, keep the deadline but still delete the restriction.
  2. Predict the missing list, then inspect that case. The original two-field loss test should now fail because you intentionally changed its fixture.
  3. Record the actual missing field and explain what the draft could omit.
  4. Restore the restriction and compare with compact.
  5. Inspect the relabeling test. Explain why its version match does not pass the whole contract.

Retain a small before/after packet, the observed result and your explanation. Do not reduce a failure to a headline score.

The inspection code compares exact fields with a known synthetic source. It cannot judge arbitrary prose or prove that a model follows instructions. Marking source text as evidence also does not establish prompt-injection resistance. Real source access, model evaluation and action enforcement remain distinct checks.

7. Bring the method to an FDE task

Your coding agent resumes from a note saying the tests passed. The repository has changed since that note was written.

Draw what goes into the next request: the task, relevant files, current revision and new test observations. Keep the old note as dated evidence. Explain what would invalidate it. Do not treat a remembered success as a test of new code.

Keep these artifacts:

  • A plain explanation of context, retained state and retrieval.
  • A diagram showing selected input and application-owned authority.
  • Five observed cases, including lost and stale facts.
  • One controlled repair and the next model or integration check.

Continue into the guided Academy lesson for the interactive packet comparison, knowledge checks and saved practice. Program access is checked on sign-in.

8. Read the primary references

Checked 20 October 2026. This is original instruction and exercise code, not a copy of provider courseware.

Before you move on

Keep the evidence of your work.

  • A diagram separating selected input from application authority.
  • Five observed packets with missing and stale facts identified.
  • One controlled repair and a refresh rule.

Keep these in your own working copy. Reading this page does not save work or record completion.

Suggested next free session

Read your first output contract

Give the receiving application a contract for the answer. This is a suggested sequence; choose the practice that addresses your current gap.

Open the next free guide
Have Academy access?

Continue with worked explanations, practice and review in the related lesson.

Open the related Academy lesson →
Back to top ↑