Skip to content

LECTURE 03 · PRACTICE

Context Engineering Lab

Choose what your agent needs for its next decision

Illustrative simulation. Outcomes follow the exercise rules; they are not measurements of an AI model's reliability.

Runs locally in your browser. No account, API key, LLM call, or backend. Page refresh starts over; download a handover to keep a record.

← Return to the lesson and downloads

01 / READ THE TASK

Extract shared validation. Preserve behavior.

Two public functions, submitPayment({ reference, amount }) and previewPayment({ reference, amount }), duplicate the same checks.

Acceptance: preserve signatures, exact error messages, validation order, and successful return values. Relevant tests must pass.

Scope: change the implementation, add a helper, and extend targeted tests. Keep the caller, approved contract, and dependencies unchanged.

Next decision: For { reference: '', amount: 0 }, which error should the shared helper throw first?

02 / INSPECT SOURCES

Available is different from loaded

Component
Evidence
Origin
specification.md · fixture owner approval
Scope
validation fixture
Available revision
r2 · Current fixture source
Loading policy
Explicit load or refresh; inspecting this panel does not load evidence into the simulated input.
Loaded status
r1 · in next input

Available content

Approved revision 2 supersedes revision 1. Check empty reference first: Reference is required. Then amount <= 0: Amount must be positive. Both-invalid input must report Reference is required.

Loaded snapshot

Old specification revision 1: check amount <= 0 first, then empty reference.

03 / DIAGNOSE

Current working context

Estimated size: 560 / 4000 illustrative tokens

Estimator: selected content + uncompacted action text, characters ÷ 4, rounded up. Capacity is an illustration, not a model limit. Size does not measure correctness.

  • Missing decision evidence: Approved specification revision 2; Current implementation or tests
  • Known stale loaded sources: Approved specification: loaded r1, available r2
  • Unresolved contradictions: None exposed by currently loaded claims
  • Acceptance checked: Not checked (both-invalid order only). Other contracts: not executed.

Rules and constraints

No item loaded in this component.

Task and acceptance criteria

Refactoring task · r1

task-brief.md · exercise assignment

Extract duplicated validation in submitPayment and previewPayment. Preserve signatures, exact errors, successful returns, and check order. Allowed: entries.mjs, a helper, targeted tests. Decision: which validation runs first?

Evidence

Approved specification · r1

specification.md · fixture owner approval

Old specification revision 1: check amount <= 0 first, then empty reference.
Unrelated build log · r1

illustrative image pipeline log · unrelated task

Image batch 1: thumbnail rendered; no payment validation information.
Image batch 2: thumbnail rendered; no payment validation information.
Image batch 3: thumbnail rendered; no payment validation information.
Image batch 4: thumbnail rendered; no payment validation information.
Image batch 5: thumbnail rendered; no payment validation information.
Image batch 6: thumbnail rendered; no payment validation information.
Image batch 7: thumbnail rendered; no payment validation information.
Image batch 8: thumbnail rendered; no payment validation information.
Image batch 9: thumbnail rendered; no payment validation information.
Image batch 10: thumbnail rendered; no payment validation information.
Image batch 11: thumbnail rendered; no payment validation information.
Image batch 12: thumbnail rendered; no payment validation information.
Image batch 13: thumbnail rendered; no payment validation information.
Image batch 14: thumbnail rendered; no payment validation information.
Image batch 15: thumbnail rendered; no payment validation information.
Image batch 16: thumbnail rendered; no payment validation information.
Image batch 17: thumbnail rendered; no payment validation information.
Image batch 18: thumbnail rendered; no payment validation information.
Image batch 19: thumbnail rendered; no payment validation information.
Image batch 20: thumbnail rendered; no payment validation information.
Image batch 21: thumbnail rendered; no payment validation information.
Image batch 22: thumbnail rendered; no payment validation information.
Image batch 23: thumbnail rendered; no payment validation information.
Image batch 24: thumbnail rendered; no payment validation information.

Working state

Prior session note · r1

illustrative prior session · unverified

I think amount should be validated first, following specification revision 1. I have not checked the current implementation, approved contract, or tests. Next session should extract a helper with amount validation first. No commands were run.

Tools and reusable procedures

No item loaded in this component.

04 / ACT ONE STEP AT A TIME

Choose a context action

The first three controls act on Approved specification. Each action has a different purpose.

Add the selected snapshot. Availability alone does not establish authority.

Replace only the selected loaded snapshot with its current fixture revision.

Remove the selected item from future input; keep its source and history.

Shorten working history while keeping decisions, uncertainty, and references. No freshness guarantee.

Compare loaded claims, provenance, approved intent, and observations. Recency alone cannot decide.

Apply the transparent exercise rules. This is not a real model prediction.

05 / INSPECT THE CONSEQUENCE

What changed, and what remains?

Only the old assumption is loaded. Inspect sources, then choose one action. No checks have run.

  • Retrieve Approved specification revision 2.
  • Retrieve Current implementation or tests.
  • Validation order has not been justified by a conflict investigation.
Transparent simulation rules
  • Only amount-first assumptions: preview proposes amount first and fails the both-invalid condition.
  • Contradictory loaded claims: show a conflict and withhold an accepted proposal.
  • Approved spec r2 plus code or tests supports reference first. Investigate to justify intent and mark old claims superseded, retaining their audit trace.
  • One current source provides partial evidence. Both code and tests are useful; no single click sequence is required.
  • Exclusion changes size. Compaction can preserve a stale assumption. Neither refreshes evidence.
  • Preview checks only the illustrative both-invalid order. Reading tests does not run them.

06 / PRESERVE CONTINUITY

Save a handover, then resume

A note preserves claims; it does not validate them. A new session needs evidence loaded explicitly.

Explicitly load these sources on resume (optional)

With nothing selected, resume loads only the task and handover. Prior verification remains historical; refresh flags and uncertainties stay visible.

Debrief

A smaller context can still be wrong; a larger context can be necessary to resolve uncertainty. Try excluding the log and compacting before refreshing. Then compare the old note with approved intent and current observations.

This fixture can establish a justified reference-first decision and a simulated check for one input. A real agent run must still refactor the code, run the tests, review signatures and all error cases, inspect scope violations, and record actual results.

Action history (0)

Reset clears this exercise only. No external files change.

Released under the MIT License.