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 22 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.

Start with the visual Context 101 lesson if you want to see what enters the request first. In Try it, assemble a packet from a saved or current record, leave fields out and predict what needs repair. The browser compares your selection locally; this guide lets you inspect and run the Python that performs the original five comparisons.

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.

Before restoring a saved packet, check whether its sources are still current and whether this caller may still read them. A revoked document must not enter the next model request merely because an earlier request included it. In this lab, a fixed project marker illustrates scope; it is not a real identity system or a revocation test.

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.

UNDERSTAND THE SYSTEM

A smaller packet can lose the decision.

Follow five observed cases from the local context lab. The frames compare separate request plans, not a model reasoning aloud. Byte lengths describe serialized JSON; no model call, token count or answer quality is measured.

FOLLOW THE WORK

Watch one example, step by step.

5 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Current source

The fictional incident is the reference for the current task. Revision 2 changes the next step, restriction and deadline. A version label helps detect change but is not an authenticity or access check.

CONNECTED TO
  • Scope and read: Build the packet
  • Current reference: Compare the facts
Read the full worked example
  1. 01
    Full is not the same as necessary

    The full plan has all six required evidence fields plus six repetitive diagnostic lines. It passes this fixture's input checks at revision 1. No answer has been generated.

    FULL · RECORDED: 1,002 bytes · no missing or changed fields

  2. 02
    Remove repetition, retain the constraint

    The compact plan removes the diagnostic repetition and keeps the source ID, revision, problem, next step, restriction and deadline. The reduction is 437 bytes; it is not a token or price saving.

    COMPACT · RECORDED: 565 bytes · all six required fields

  3. 03
    Shorter can remove the safe next step

    The lossy plan also drops the restriction and deadline. It saves another 115 bytes, but the intended update no longer has the instruction to keep the import paused or its due time. Restore those facts before evaluating a draft.

    LOSSY · RECORDED: 450 bytes · restriction and deadline missing

  4. 04
    Complete can still be stale

    The current source advances to revision 2, but this request restores the old compact packet. Every field is present; four values differ: revision, next step, restriction and deadline. Changing the label alone leaves three old facts.

    STALE · RECORDED: 565 bytes · four changed values

  5. 05
    Rebuild from the current record

    The refreshed plan selects the actual revision-2 values. It passes the known-field comparison at 568 bytes, slightly larger than the stale one. In a real system, recheck access and freshness as required, then separately evaluate the model's draft and any proposed action.

    REFRESHED · RECORDED: 568 bytes · no missing or changed fields

Read the connections in plain English
  1. 01
    Current source → Build the packet

    Select from the currently permitted source; the lab uses a fixed scope marker rather than real authentication.

  2. 02
    Build the packet → This request

    Choose the task's necessary evidence and preserve its source identity.

  3. 03
    This request → Compare the facts

    Inspect the actual fields being supplied, not the existence of a record elsewhere.

  4. 04
    Current source → Compare the facts

    The reference determines whether the selected values are current, including more than the revision label.

  5. 05
    Compare the facts → Choose the next step

    Use the observed missing and changed fields to choose the repair.

  6. 06
    Earlier snapshot → Build the packet

    The builder can restore an earlier selection instead of reading the current source. Its old facts become part of the request; they are not updated merely by restoration.

Check your understanding: Why is the 568-byte packet more useful than the 450-byte packet?

It retains the current restriction, deadline and next step. The smaller one lacks required evidence. Size, completeness, freshness, authorization and answer quality are separate questions; this lab measures bytes and checks a known input contract.

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

Free account

Give your practice a home.

Try a role exercise with account drafts and a downloadable worksheet. Keep the files you made in this guide in your own working copy.

Create a free learning account

Guided training · by application

Build toward a program.

Request structured lessons and a training seat. Scope, schedule, feedback arrangements and tuition are confirmed in writing before you commit.

Explore a training application
Have Academy access?

Use your existing training seat to open worked explanations and practice in the related lesson. Creating a free account does not grant a seat.

Open the related Academy lesson →
Back to top ↑