Skip to content
← Free FDE training guides

Free learning / Agent engineering lab

Build and test a bounded AI agent

Run real LangChain tool loops and LangGraph SQLite restart labs, compare broken candidates and inspect source-bound review without a provider key.

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

Engineering lab library / Run locally

Choose your next agent lab.

Start with the durable workflow reference, then choose the boundary you want to test. Open its walkthrough for setup, commands and expected observations.

Synthetic records. No provider key or model inference. Package setup needs package-registry access.

Search titles, outcomes and prerequisites, then narrow by runtime.

19 of 19 labs · All labs

  1. Start here / Python 3.11+ · Standard library

    Durable workflow reference

    Pause a draft, restart the process and bind a review decision to its exact source.

    One Python file · No package installation

  2. Python 3.11+ · Standard library

    Scoped retrieval and context

    Compare retrieval quality on eight cases while preserving current access and context budgets.

    Python standard library · Standalone file

  3. Python 3.11+ · Standard library

    Regression comparison lab

    Compare the working reference with broken candidates and retain missing-case evidence.

    Python standard library · Keep the workflow file beside it

  4. Node.js 24 · Offline exercise

    MCP tool admission

    Challenge changed tool definitions, forged arguments and current host permissions.

    Node.js 24 · Offline host-policy exercise

  5. Node.js 24 · Offline exercise

    Shared delegation coordinator

    Trace retries, shared attempt limits and late results after manual closure.

    Node.js 24 · Supplied event replay

  6. Python 3.11+ · Standard library

    Destination fencing and stable operation receipts

    Compare a refused stale queue completion with actual destination effects, equal-token repeats and matching operation replay.

    Python 3.11+ · Standard library · Two owned processes · Two scratch databases

  7. Python 3.11+ · Standard library

    Worker lease and recovery

    Compete for one lease across two local processes, then rehearse a worker kill and recover without resetting attempts.

    Python standard library · SIGKILL extension on macOS/Linux

  8. Real library, SDK or framework · Scripted inputs

    LangGraph SQLite restart

    Recover saved work, distinguish retry from review, and route two independent decisions by interrupt ID.

    Python 3.11+ · New virtual environment · Three pinned packages

  9. Real library, SDK or framework · Scripted inputs

    LangGraph interrupt and resume

    Wire a real StateGraph, observe an interrupt and resume its in-memory state.

    Python 3.11+ · New virtual environment · Pinned LangGraph package

  10. Real library, SDK or framework · Scripted inputs

    LangChain tool-calling loop

    Inspect real create_agent orchestration using scripted tool proposals and results.

    Python 3.11+ · New virtual environment · Pinned framework packages

  11. Real library, SDK or framework · Scripted inputs

    Structured agent output

    Run real ToolStrategy validation and repair, then distinguish a valid shape from current source support.

    Python 3.11+ · New virtual environment · Pinned framework packages

  12. Python 3.11+ · Standard library

    Receiver commit and replay

    Compare a duplicate-producing receiver with an atomic effect and receipt, then retry a lost response.

    Python standard library · Owned child-process exits

  13. Python 3.11+ · Standard library

    Agent trace and payload boundary

    Keep bounded observability events, then inspect optional real OpenTelemetry spans without a collector.

    Core: Python 3.11+ · Standard library · Optional SDK extension

  14. Node.js 24 · Offline exercise

    MCP stdio compatibility

    Inspect real framed requests and distinguish a tool refusal from a protocol failure.

    Node.js 24 · Owned child process · Pinned 2025-11-25 profile

  15. Python 3.11+ · Standard library

    Agent canary evidence

    Compare candidate/control segments, retain missing evidence and stop an aggregate-green regression.

    Python 3.11+ · Standard library · Supplied observation packets

  16. Real library, SDK or framework · Scripted inputs

    MCP SDK client and server

    Separate server discovery, tool contracts and current access through real SDK comparisons.

    Node.js 24 · New npm folder · Three pinned packages

  17. Python 3.11+ · Standard library

    Private inference capacity

    Budget weights, KV cache, context and output reservations without claiming measured GPU capacity.

    Python 3.11+ · Standard library · No GPU or model

  18. Real library, SDK or framework · Scripted inputs

    Your first LangGraph workflow

    Trace two ordinary functions, field updates and a missing-source branch before adding persistence.

    Python 3.11+ · Isolated environment · LangGraph 1.2.16

  19. Real library, SDK or framework · Scripted inputs

    Your first HTTP request with FastAPI

    Follow real requests through routing, validation, Python functions and four distinct responses.

    Python 3.11+ · Isolated environment · Supplied pinned requirements

Original LockedIn Labs training. All people, tenants and records are synthetic. These files execute on your machine. No API key, customer data, model inference or external sending is used by any supplied lab.

Use the downloads on the free lab page, or the Academy course's Practice section. Use a disposable working directory. Python labs require Python 3.11 or later; the delegation coordinator and MCP labs require Node.js 24. Never put real source documents or credentials in these examples.

0. Choose a lab and prepare your workspace

This is an original hands-on route for forward-deployed engineers who can run a terminal command and read a small Python function. If you are new to coding, first trace the supplied inputs, state changes and refusal decisions on paper; label that work unexecuted. Python labs need Python 3.11 or later and a text editor. Use python3 --version to check your interpreter before starting.

Use the lab library on the free page to filter by runtime and open the exact walkthrough for your chosen file. Download the files you need and save them in a new disposable folder. The evaluation lab imports the workflow file from that same folder, so keep both original filenames. You do not need an account, API key or package installation for the standard-library labs.

Start withPreparationEvidence to keep
Your first LangGraph workflowPython 3.11+; isolated environment; one pinned packageTwo function traces, retained state fields and a skipped draft for missing input.
Your first HTTP requestPython 3.11+; isolated environment; supplied requirementsFour real FastAPI request/response results and the functions each request reached.
Durable workflow referencePython standard library; one .py fileA paused draft, a fresh-process read and a bound decision.
Scoped retrievalPython standard library; standalone fileAuthorized evidence, content-edit invalidation and revoked access.
Regression comparisonWorkflow and evaluation .py files togetherReference, broken-candidate and missing-case reports.
MCP tool admissionNode.js 24; standalone .mjs fileDefinition change, current grant and argument/result boundary decisions.
MCP stdio compatibilityNode.js 24; standalone file; owned child processCorrelated wire frames, a useful tool result and protocol/tool refusals.
MCP SDK client and serverNode.js 24; new folder; three pinned packagesActual discovery, two protocol profiles and schema/permission refusal evidence.
Private inference capacityPython standard library; no GPU or modelByte ledger, output reservation and unmeasured runtime assumptions.
Agent canary evidencePython standard library; standalone fileSegment comparisons, incomplete evidence and a non-authorizing review recommendation.
Shared delegationNode.js 24; standalone .mjs fileConsumed attempts, freed slots and late-result refusal.
Worker recoveryPython standard library; actual SIGKILL extension on macOS/LinuxA committed lease after process death, bounded reclaim and current receipt.
LangGraph SQLite restartSeparate environment with three pinned packagesThe same real graph checkpoint inspected and resumed in fresh processes.
LangGraph wiringSeparate virtual environment and pinned packageAn observed interrupt and scripted resume; in-memory only.
LangChain tool loopSeparate virtual environment and pinned packagesProposed tool, dispatched result and stop reason.

Choose one lab rather than running every command at once. New to LangGraph? Start with section 0a. New to a tool-calling agent? Start with section 0b. New to retrieval-augmented generation (RAG)? Start with section 0c. New to HTTP APIs or FastAPI? Start with section 0d. For the broader agent delivery exercise, begin with the standard-library workflow, inspect one refusal, then compare the regression candidates. Framework installation requires normal package-registry access; installed examples run without provider inference. They use real framework orchestration with scripted proposals.

If Python reports that a file is missing, check your working directory and the original filename. If the evaluator cannot import its reference, put both files beside each other. A deliberately blocked candidate exits 2; preserve its JSON instead of treating that exit as a package failure. Never fix a refusal by removing the relevant case or using a real customer's records.

0a. Your first LangGraph workflow

LangGraph coordinates steps in a program. You still write the Python functions that do the work. Start with a familiar task: look up a release guide and prepare a suggested reply. If no guide exists, stop with an explicit missing-source result.

Download fde-langgraph-first-workflow.py. It contains two functions registered as nodes: lookup and draft. The shared dictionary is called state. A conditional edge calls route to choose whether draft runs. START and END are graph markers. No model, human review, sending or persistent storage is configured; the draft uses a fixed text template.

Save the file in a new folder. Check that your Python is 3.11 or later, then run:

Code example
python3 --version
python3 -m venv .venv
.venv/bin/python -m pip install "langgraph==1.2.16"
.venv/bin/python -m pip freeze > requirements.lock.txt
.venv/bin/python fde-langgraph-first-workflow.py test
.venv/bin/python fde-langgraph-first-workflow.py demo

On Windows, replace .venv/bin/python with .venv\Scripts\python.exe. Installation needs package-registry access. The installed exercise makes no model or other network requests. Keep the resolved versions and your demo output.

Before running, predict these two paths:

InputFunctions that should runFinal state to inspect
P1, an existing sourcelookup → route → draftstatus drafted; reply includes the P1 guidance
P404, an unknown sourcelookup → routestatus needs_source; draft remains empty

Both paths reach END. That only means the graph has finished scheduling work. It does not mean a useful draft exists or a person approved it. Notice that route reads the current state but returns a destination rather than a field update. Notice also that request survives even though neither node returns it.

In a disposable copy, add a synthetic P2 entry to SOURCES and a test for the result of run_case("P2"). Predict its draft before running. Preserve the P1 and P404 checks; do not fix the missing-source case by inventing guidance. Explain why a fixed template is sufficient for this wiring exercise and what would change if a model generated the draft.

Keep a labeled graph, two predicted-versus-observed outcomes and the tested P2 change. Before installing anything, use LangGraph 101 → Try it to predict the outcomes and inspect the recorded state. The protected Academy lesson uses the same public snapshots alongside its guided instruction and checks. For persistence and a waiting human decision, continue to section 2a after you can explain this smaller graph. The complete Graph API and quickstart are linked in the Academy lesson; this is an original LockedIn Labs exercise.

0b. Your first LangChain agent

LangChain is a software framework that can coordinate a model calling a tool, reading its result and replying. Start with a familiar Python lookup function. The model proposes a call; application code executes the permitted function. The returned result becomes input to the next model call.

Download fde-langchain-agent-lab.py. In this exercise its model adapter is a scripted test double, so the two cases repeat without a provider or API key. The LangChain loop and Python tool execute for real. Source records are synthetic. This teaches the exchange; it does not measure the quality of a real model.

Save the file in a new folder and check Python is 3.11 or later:

Code example
python3 --version
python3 -m venv .venv
.venv/bin/python -m pip install "langchain==1.4.6" "langgraph==1.2.16"
.venv/bin/python -m pip freeze > requirements.lock.txt
.venv/bin/python fde-langchain-agent-lab.py test
.venv/bin/python fde-langchain-agent-lab.py inspect --scenario supported
.venv/bin/python fde-langchain-agent-lab.py inspect --scenario foreign-source

On Windows, use .venv\Scripts\python.exe instead of .venv/bin/python. Installation requires package-registry access. These installed exercises need no model or network service; remote tracing is disabled by the lab. The JSON inspection output omits generated run IDs and provider metadata, and keeps the tool-call IDs that pair requests with results.

Before running, open LangChain 101 → Try it. Follow the proposal, Python check and returned result. Inspect the messages that reach the second model call, then compare them with your own local output. The protected guided lesson uses the same public recordings with deeper instruction and checks. The visual replays recorded output; it does not run the SDK.

Before running, predict the sequence:

MessageWho produced itWhat to inspect
humanApplication, from the user requestThe task to perform
ai with tool_callsScripted model adapterFunction name, arguments and call ID; this is a proposal
toolFramework, from the Python function's resultMatching tool_call_id and found/unavailable content
ai without a tool callScripted model adapterA draft or an explanation that the source is unavailable

The permission check happens inside lookup_procedure, between the proposal and the tool result. The trusted host scope is north, fixed in this synthetic lab. P1 belongs to that scope. P9 does not. Both inputs have a valid shape and enter the function, but only P1 returns source text. Compare the admitted value in the application audit with the returned tool content. call-0 is a correlation label, not permission. No function sends a message.

In a disposable copy, replace only the allowed P1 excerpt with a new synthetic instruction. Predict the changed draft, rerun both inspection cases, and verify that P9 remains unavailable without its source text appearing. Record that result in a regression check in your copy. Keep the original refusal tests. The model adapter is scripted, so do not describe its predictable answer as model accuracy.

Keep an annotated exchange, actual command output and resolved versions. Explain which part a real model adapter would replace and why scope checks stay in the application. For more difficult inputs, multiple proposed calls and independent budgets, continue to section 2b and the advanced tools lesson. The recursion limit in the first exercise is not a timeout or a token-spend limit.

0c. Your first retrieval context

Start with RAG 101 and choose Try it to trace a source into model input. Predict the matches, prepared input and model calls, then compare the three recorded cases. The visual is a replay; the commands below run the actual local search.

RAG means retrieval-augmented generation. It is an application pattern: find relevant information, include it in a model's input, then generate a response using that information. Think of finding the right page for a colleague before asking them to explain it. The model still needs an output check; a supplied source does not guarantee a supported answer.

A chunk is a retrievable passage. Here it is one paragraph. Context is the information supplied for one model call, not the entire document library and not a change to the model's learned parameters. This exercise builds that context before any generator runs. It uses exact word-like matches, not embeddings, a vector database or a model tokenizer.

Download fde-retrieval-context-lab.py, open a terminal in its folder, and use Python 3.11 or later. No packages, accounts or keys are required:

Code example
python3 --version
python3 fde-retrieval-context-lab.py test
python3 fde-retrieval-context-lab.py inspect --scenario supported
python3 fde-retrieval-context-lab.py inspect --scenario terminology
python3 fde-retrieval-context-lab.py inspect --scenario budget

On Windows, use your installed Python 3.11+ command in place of python3. All source records are synthetic. The host fixture permits north procedures P1 and P2; P9 is excluded before ranking. Its source text is absent from the report. A deployed service must derive scope from authentication and enforce it at storage.

Predict each row before running, then compare it with your actual output:

CaseSearch resultSelected contextModel calls
supported: pump, 400 charactersTwo P1 paragraphsBoth complete passages; 80 characters0
terminology: restart, 400 charactersNo exact match; source says resetno_matching_context0
budget: pump, 20 charactersTwo P1 paragraphswithheld_budget; neither whole passage fits0

Read documents, ranked, result.evidence and model_input in order. In the supported case, match the P1 version and paragraph locator to the model-input citation, then compare the exact source text. The evidence also retains a content digest. The input preview combines a fixed teaching question, an instruction and the selected sources; it is never sent. An instruction to treat sources as data is not proof of prompt-injection resistance.

In a disposable copy, replace Pump reset requires local isolation. with Pump restart requires local isolation. in the P1 fixture. Run the terminology inspection again and compare its passage, locator and digest. Retain the original reference file and output. The reference tests describe the original fixture; this controlled edit intentionally changes their assumptions. This exercise shows why a lexical miss is not proof that the source lacks useful information.

The budget counts evidence characters only, not model tokens or the full input. A production budget must include instructions, formatting, conversation and an output reservation using the selected model's counting rules. Embeddings can help find related wording, but authorization, source freshness and answer evaluation still need their own checks. Continue with section 1b for those retrieval and cache boundaries, then compare retrieval quality before judging a generated answer.

Retain your prediction/observation table, all three outputs, Python version and the controlled edit result. Explain what is found, what is selected, and what would be sent as three separate decisions. No model answer was generated.

0d. Your first HTTP request with FastAPI

Begin with API 101's visual request exercise. In Try it, choose a request and predict whether the ticket lookup runs. Follow the request through routing, validation, Python and the response. Compare a missing ticket with an invalid identifier: both fail, but at different layers. Record your predictions before reproducing the four cases below. This visual uses actual local exercise recordings; it does not send requests from your browser.

Suppose one program needs the current status of a service ticket. An API is the agreement about how it asks. HTTP carries a method, address, headers and sometimes a body. JSON is a data format. REST is a style of designing resource interactions; JSON alone is not enough to establish it. FastAPI is a Python framework that maps a web operation to a function you write.

Begin with reading one synthetic ticket. No model is needed to understand this exchange. Before running the lab, predict which requests reach the Python handler and which leave the ticket records unchanged.

Download these two files into a new folder:

Code example
python3 --version
python3 -m venv .venv
.venv/bin/python -m pip install -r fde-fastapi-first-request-requirements.txt
.venv/bin/python fde-fastapi-first-request.py test
.venv/bin/python fde-fastapi-first-request.py demo
.venv/bin/python fde-fastapi-first-request.py contract

Use Python 3.11 or later. On Windows, use py -3 to create the environment and .venv\Scripts\python.exe instead of .venv/bin/python. Keep the filenames unchanged. Installing packages needs registry access. The supplied versions use FastAPI 0.150.0, Starlette 1.9.0 and HTTPX2 2.15.1; the latter is the test client supported by this Starlette version. Keep this environment separate from older FastAPI examples that use HTTPX. Installation is not needed in the Training site.

The exercise uses the real application through an in-process ASGI TestClient. ASGI is the Python interface connecting a server or test client to an application. No listening port is opened, no remote endpoint is called and no model runs. The observed inputs, JSON bodies and function entries are application-level results, not a packet capture or proof that a deployed network works.

RequestStatusHandler / lookup entriesExplanation
GET /tickets/104200BothThe fixture contains that ticket.
GET /tickets/105404BothA valid identifier, but no matching record.
GET /tickets/pump422NeitherThe path value cannot be parsed as an integer.
POST /tickets/104405NeitherThe route supports GET; the Allow header says so.

Read each result's response headers and JSON body. The successful response has id, title and status. The 422 error identifies path and ticket_id. All four cases report records_unchanged: true; this example implements no write. A failure before the handler is different from a missing record inside it.

Code example
.venv/bin/python fde-fastapi-first-request.py inspect --scenario found
.venv/bin/python fde-fastapi-first-request.py inspect --scenario missing
.venv/bin/python fde-fastapi-first-request.py inspect --scenario invalid
.venv/bin/python fde-fastapi-first-request.py inspect --scenario wrong-method

In the contract output, find the GET operation under /tickets/{ticket_id}. Its path parameter is an integer with an exclusive minimum of zero. The OpenAPI description comes from the running application; it is a contract to inspect, not independent evidence that the service enforces authorization.

For one controlled change, make a disposable copy of the Python file and replace the fixture's "status": "open" with "status": "queued". Run inspect --scenario found using that copy. The request, two function entries and 200 status stay the same; the JSON representation now contains queued. Retain the original file for the reference checks. Keep both observed outputs and explain the difference.

Retain your prediction table, six test results, demo output with runtime versions, the parameter contract and the controlled-edit comparison. Before using this pattern with real tickets, add authenticated caller identity, resource access, storage and deployment controls. Input validation is not permission. Continue to the networking 101 and the worker/deployment lesson for those next boundaries.

1. Run the durable workflow reference

The reference uses only the Python standard library. Run:

Code example
python3 fde-agent-engineering-lab.py test
python3 fde-agent-engineering-lab.py demo --db field-desk.sqlite
python3 fde-agent-engineering-lab.py inspect --db field-desk.sqlite
python3 fde-agent-engineering-lab.py review --db field-desk.sqlite --decision accepted
python3 fde-agent-engineering-lab.py inspect --db field-desk.sqlite

The test command exits nonzero on failure. Retain your actual output rather than copying an expected transcript. A successful run exercises twelve cases: useful authorized work, foreign source denial, foreign run denial, restart and request replay, conflicting request reuse, decision replay/conflict, changed proposal, changed source, withdrawn source, an unchanged-version content edit, terminal receipt replay after a later source edit and the isolated source-change report.

demo creates an awaiting_review record. Every following command is a fresh process reading the same SQLite file. review records only acceptance or rejection of that synthetic draft. It does not send a response. Repeat the same accepted decision and verify it is stable. Attempt --decision rejected after acceptance and inspect the conflict. For a foreign-tenant read, use:

Code example
python3 fde-agent-engineering-lab.py inspect --db field-desk.sqlite --tenant south

That command must refuse. This CLI is not an authentication service: a deployed host must derive tenant identity from an authenticated session and authorize reviewers before invoking the domain methods. Its SQLite transaction is a local reference, not evidence about a distributed fleet.

Reject a content edit even when the version stays unchanged

Predict whether an unchanged version number is enough for first acceptance, then run the same file's isolated report:

Code example
python3 fde-agent-engineering-lab.py source-change-demo

This command creates and removes its own temporary SQLite records; it never opens your --db file. In both cases the draft and current source version remain one. The unchanged source can be accepted. Editing the pending source body without incrementing its version must return source_changed; a new connection sees stale, so restarting cannot restore a pending approval.

CaseDraft version / current versionFirst decisionAfter reopening
unchanged1 / 1acceptedaccepted
same-version-edit1 / 1refused: source_changedstale

The check runs inside the same local transaction as the pending decision. This reference's proposal is exactly a fixed prefix plus one source body. It can reconstruct that draft from the current source and compare the resulting digest with the saved proposal digest, without changing the existing database schema. For generated prose, persist separate fingerprints for the actual source snapshots and validate those at first acceptance. Comparing generated prose with source text is not a general provenance or answer-support check.

The unchanged case also withdraws its source after acceptance and replays the same decision. That returns the historical accepted record; it does not check a new action or grant current permission. Any later effect needs its own current authority and source checks. Do not alter accepted history to make a past receipt look like a new approval.

For fifteen minutes of receiving practice, change whitespace in the pending source without changing its version and retain the refusal. Contrast it with an unchanged useful acceptance and with historical replay after withdrawal. Explain where source fingerprints would be persisted for a generated draft and which adapter must authorize the reviewer. This local single-database transaction does not establish an atomic check across a remote source and another service.

1b. Build current, authorized retrieval context

RETRIEVAL / EVIDENCE COMPARISON

Inspect what the score leaves out.

Compare supplied reports from the downloadable Python lab. These eight cases are synthetic and visible. This page displays recorded observations without running retrieval, calling a model or recording completion.

Scoped retrieval

8 of 8 supplied cases observed

Mean recall at 2
0.60

3 query-recall sum / 5 answerable queries

Mean reciprocal rank at 2: 0.60

3 of 3 empty-evidence cases returned no evidence. Counted separately.

0 invalid passages · 0 context-budget violations

Global first, then filter

8 of 8 supplied cases observed

Mean recall at 2
0.10

0.5 query-recall sum / 5 answerable queries

Mean reciprocal rank at 2: 0.20

3 of 3 empty-evidence cases returned no evidence. Counted separately.

0 invalid passages · 0 context-budget violations

Global first, then filter: 8 of 8 cases observed. The selected packet is complete; no readiness claim follows. Selected case: D2 · Two passages required.

Does a useful first hit supply every required passage?

Development practice · Query: “check” · 400-character context ceiling

Scoped retrieval

2 passages returned · 2 relevant

Recall at 2
1.00
Reciprocal rank at 2
1.00

0 invalid passages · within context budget

Global first, then filter

1 passages returned · 1 relevant

Recall at 2
0.50
Reciprocal rank at 2
1.00

0 invalid passages · within context budget

Inspect source identities

These labels identify complete synthetic content snapshots. Read the Python file for the corpus; a matching identifier alone is not answer-support evidence.

Required passages
  • north / P4 · version 1 · paragraph:1a2c5ca12375b26d7efee19770fc3bffe983a23537de732a378212ceedaf740bd
  • north / P5 · version 1 · paragraph:17d12f7eb818a5a42f72d0947735c1b3d8b3eb88da2b7d76c5905ae3a9ac5cc23
Scoped retrieval returned
  • north / P4 · version 1 · paragraph:1a2c5ca12375b26d7efee19770fc3bffe983a23537de732a378212ceedaf740bd
  • north / P5 · version 1 · paragraph:17d12f7eb818a5a42f72d0947735c1b3d8b3eb88da2b7d76c5905ae3a9ac5cc23
Comparison returned
  • north / P4 · version 1 · paragraph:1a2c5ca12375b26d7efee19770fc3bffe983a23537de732a378212ceedaf740bd

Reproduce this comparison locally

python3 fde-retrieval-context-lab.py evaluate --candidate postfilter

Python 3.11+. A complete supplied packet exits 0, without declaring the candidate ready. The commands and metric worksheet continue below.

Take the evidence into a receiving conversation.

Keep this comparison, all eight case states and the reproduction commands in an editable Markdown brief. Add your explanation, actual-run observations and a receiver’s challenge in your own copy.

Download fde-retrieval-context-lab.py from the free lab page. This is a standalone standard-library exercise; it does not import the workflow file. Predict the two retrieval outcomes before running:

Code example
python3 fde-retrieval-context-lab.py test
python3 fde-retrieval-context-lab.py demo

The demo contrasts a deliberately flawed global-top-one/post-filter comparison with a builder that checks current source authorization before chunking and ranking. A foreign document contains more query-term occurrences, so the flawed comparison throws away its only result even though an authorized passage exists. The scoped builder preserves the useful task and keeps the foreign text out. All records are synthetic; the CLI principal stands in for trusted host context, not an authentication service. Real storage adapters must enforce the same scope.

This baseline ranks exact term frequency over paragraph chunks. It is not an embedding index or an answer generator. Inspect the returned tenant, source, version, paragraph locator and content digest. Then compare an unchanged cache hit with a text edit that keeps the old version number and with a revoked grant. The cache compares the entire currently eligible source snapshot, not only the previously selected hits, so newly permitted evidence can invalidate an empty lookup. This intentionally rescans eligible text; it is not a performance claim. The process-local cache now has a fixed expiry, an entry ceiling with least-recently-used eviction and a host-scoped forget operation. Current source and grant checks still run on every request; an unexpired entry never grants access. Use the lifecycle walkthrough below to distinguish cache invalidation from reference removal.

The original context tests also cover source withdrawal, copied result mutation, identity-scoped reuse, duplicate source identity, new evidence after an empty lookup and a character budget that keeps whole chunks. The ceiling covers selected evidence text, not metadata, tokens or a future model request. A withheld_budget result is distinct from no_matching_context; neither proves there is no answer in the corpus. The context_ready state means selected lexical evidence is present, not that a generated answer is supported.

Keep your actual JSON, a source revision and one new case the lexical baseline misses. Explain what a semantic retriever would need to improve, and what must remain invariant when replacing the ranker. The lab labels evidence untrusted but does not call a model or test prompt-injection resistance. Add inference, answer-support, hostile-source and receiving-engineer checks separately before making those claims.

Bound memory lifetime and test scoped forgetting

Run the same file without packages or keys:

Code example
python3 fde-retrieval-context-lab.py test
python3 fde-retrieval-context-lab.py lifecycle

Predict the cache state at the exact expiry before looking at the JSON. The experiment injects a synthetic monotonic clock; it never sleeps or changes the computer's clock. Its two-entry cache has a ten-second fixed lifetime. A hit at second nine updates recency but does not slide the expiry to nineteen.

ObservationElapsed secondsCacheWhat it establishes locally
First north request0rebuiltUseful authorized evidence can be cached.
Same request9hitA hit does not extend the fixed lifetime.
Exact expiry10rebuiltExpired text is not reused, even unchanged.
Same subject, south tenant10rebuiltTenant remains part of cache identity.
South after forgetting north10hitForgetting selects both host subject and tenant.
North after forgetting10rebuiltAvailable source text can be retrieved again.

forget(principal) removes every query entry for the host-selected subject and tenant; calling it again removes zero. Do not accept that principal from a model argument or a browser claim. The CLI fixtures establish no authenticated identity. The tests also fill the two-entry cache, touch the first key, then insert a third key. They establish that the least recently used entry is evicted while the recent one still hits. Expiry is fixed from insertion/rebuild, whereas eviction recency updates on a hit. These are different policies.

Expiration is lazy: build() prunes before lookup, and prune() can be called explicitly. Advancing the clock alone does not run a background deletion process. The entry ceiling bounds record count, not bytes held by source records or caller copies. The test shows a copy returned before forgetting still exists, and the original source remains readable. This is process-local reference removal, not secure memory erasure, distributed deletion or deletion from logs and backups. A revoked grant still blocks reuse immediately, independently of the time limit.

For a fifteen-minute receiving exercise, change the lifetime to five seconds in a disposable copy, predict an exact-boundary result and preserve the ordinary useful path. Add a second query for north and show one forget call removes both query entries while a south entry survives; increase capacity to three for that experiment. Record observed counts, caller-copy survival and remaining storage adapters. Have the receiver explain which layer would prevent reloading a deleted source and which layer would remove old exported copies. Cache forgetting alone cannot establish either.

Compare retrieval quality on a fixed packet

On the free lab page, use the interactive comparison to choose a candidate, inspect a case and predict its interpretation. The browser displays supplied local observations; use the command below to gather your own report. Use Download receiving brief in that comparison to keep the selected report, all case states and source snapshots in an editable Markdown worksheet. Fill in your own explanation and receiver challenge, then add actual local output when you run the lab. Preparing the worksheet does not mark a run or a course complete.

Use the same standalone file; no packages, embeddings or provider key are needed:

Code example
python3 fde-retrieval-context-lab.py evaluate --candidate scoped
python3 fde-retrieval-context-lab.py evaluate --candidate postfilter
python3 fde-retrieval-context-lab.py evaluate --candidate refuse-all
python3 fde-retrieval-context-lab.py evaluate --split development
python3 fde-retrieval-context-lab.py evaluate --split transfer

The eight visible synthetic cases have authored paragraph relevance labels. Inspect evaluation_cases() in your downloaded file before changing a candidate. Four development cases cover foreign ranking dominance, two required passages, withdrawal and revoked access. Four transfer cases cover different terminology, a withdrawn distractor, a foreign-only source and evidence that cannot fit its character budget. “Transfer” is a practice partition, not an independent hidden test. Candidates retrieve without receiving the relevance labels.

Each report retains case IDs, source snapshot identities, required and returned passages, character ceilings, per-query scores and explicit denominators. The context ceiling is two chunks; the flawed post-filter candidate still takes one global result before checking access. The same whole-chunk character budget is applied to its output. Do not feed that flawed comparison into model context.

FieldHow to interpret it
mean_recall_at_2For each executed answerable query, distinct required passages found divided by required passages; average those query recalls.
mrr_at_2Average the reciprocal of the first relevant rank within two results; an answerable miss contributes zero.
answerable_planned, answerable_executedKeep the original population separate from the queries actually run.
correct_empty, unanswerable_executedCount the supplied empty-evidence cases separately; they do not raise answerable recall.
invalid_evidence, context_budget_violationsCurrent source/identity/content checks and context ceilings remain independent of relevance.
unrun, completeName omissions. Complete means all selected cases ran, not that the candidate is ready to deploy.

On the complete supplied packet the scoped candidate has a recall sum of 3 over five answerable queries: mean recall 0.6. The three empty-evidence cases return empty. Development mean recall is 1 across two answerable queries; transfer is 1/3 across three. Keep the terminology miss and budget withholding in that latter denominator. These values describe this visible local packet only.

In D2 the post-filter candidate finds one of two required passages at rank 1. That query has recall 0.5 and reciprocal rank 1. Its complete-packet means are 0.1 recall and 0.2 reciprocal rank. An early useful hit is not complete evidence. The refuse-all control gets the three empty cases right but has zero answerable recall. Source identity includes the tenant, version, locator and content digest; stale or altered text cannot earn a valid hit, and duplicates do not multiply recall.

Now deliberately leave a miss unrun:

Code example
python3 fde-retrieval-context-lab.py evaluate --candidate scoped --omit-case T1-different-terminology

This produces JSON and intentionally exits 2. The mean becomes 0.75 over four executed answerable queries, but complete is false and the omitted case stays in unrun. That higher displayed average is not a retrieval improvement. Omit every answerable case and the metric denominator is zero: its value is null, not perfect. Keep the original complete reports before making a change.

Ask a receiver to add a new terminology query and an independently chosen relevant paragraph, then explain a miss without tuning the expected label to your candidate. Retain the case-level report and propose a new ranking or chunking experiment. This exercise evaluates a small lexical/context baseline, not semantic retrieval, answer support, a live model, prompt-injection resistance or enterprise performance. Relevance labels may be incomplete in real corpora; a representative evaluation needs separate labeling and sampling evidence. Ranked retrieval evaluation and the information-retrieval evaluator reference provide further metric context; this lab uses the explicit denominator policy above.

1c. Recover an abandoned worker lease

Download fde-worker-recovery-lab.py from the free lab page. It is a standalone standard-library exercise using only temporary synthetic SQLite records. Predict whether the abandoned worker may record a completion before running:

Code example
python3 fde-worker-recovery-lab.py test
python3 fde-worker-recovery-lab.py demo

The demo records a queued admission, worker A’s lease, a database-connection restart and worker B’s reclaim at lease expiry. B receives fencing number 2; A’s attempt to finish with number 1 is rejected as lease_lost. B records the current synthetic result. The timestamps are injected clock ticks, not observed latency or a process-kill experiment. The admission is not a completion, and a finished worker record is not a human acceptance or an external-effect receipt.

Inspect the original eight queue tests as well as your actual demo JSON. They cover bound request replay, per-tenant capacity, lease expiry, stale completion, cancellation, checkpoint-version compatibility, persisted attempt limits and stable result receipts. An unchanged request replay cannot resurrect a cancelled job; an old worker cannot claim a declared newer checkpoint format. The format marker is a simple gate, not state migration or complete deserialization evidence.

Write the operator’s next action for each record:

ObservationNext safe decision to explain
A worker has a live leaseKeep a second worker from stealing it.
A lease expires and another worker reclaims itPreserve the increasing fencing number; reject stale completion.
Cancellation invalidates the leaseStop local acceptance; investigate any effect already in flight.
The attempt budget is exhaustedRetain the record and investigate; do not silently replenish attempts.
Rolled-back code cannot read the format markerKeep work unclaimed until compatible handling is established.

The last stored running state with an expired lease is not evidence that a business action failed. This lab has no external effects. Its fencing check protects only its completion row; an external destination needs idempotency, supported fencing or reconciliation of uncertain outcomes. Cancellation does not kill the old process or undo an already-issued request. Do not infer at-most-once business execution from a local completion refusal.

The synthetic tenant and worker arguments stand in for trusted host context. Before exposing these methods through a service, authenticate and authorize callers, derive tenant scope and supply an authoritative clock. Fencing numbers are concurrency versions, not credentials. The local writer transaction is not a distributed queue, fleet-concurrency test, deadline controller or a deployed checkpoint backend. Keep those limitations in the receiving-team runbook.

Run a real local process-kill rehearsal

On macOS or Linux, use the same standalone file with Python 3.11 or later:

Code example
python3 fde-worker-recovery-lab.py crash-demo

This command creates a temporary synthetic database, starts its own child worker and waits for a flushed lease_committed event. That worker has committed the lease and is idle with its SQLite connection open. The parent kills only that owned child with SIGKILL, waits for its exit and reopens the database. It does not accept a process ID or connect to your application database. The internal worker entry refuses an existing file. Temporary records are removed after the report is assembled; keep your JSON output separately if you need it later.

Predict each field before running. Compare your actual report with this worksheet:

FieldObservation to explain
boundary.event, worker_exitlease_committed, then -9 on the supported POSIX run.
boundary.job, after_killIdentical stored lease; still running, with a null result digest.
integrity_checkSQLite returns ok for this local after-commit experiment.
before_expiry, attempts_before_reclaimlease_busy at injected tick 4; one attempt remains consumed.
reclaimedWorker B holds fence 2 at injected tick 5; two attempts are consumed.
reconstructed_stale_submissionA synthetic replay of A's old lease is refused as lease_lost.
finished, receipt_replay_equalB records the synthetic result; reading the same receipt is stable.

The stale submission is reconstructed by the parent. It is not a message sent by the killed worker. The clock ticks are injected, so this is not a measurement of expiry delay or recovery time. The ten bundled tests include the real process-boundary check and preservation of an existing file; those two process tests explicitly skip on unsupported systems. On Windows use demo and record this SIGKILL rehearsal as unrun. The command uses no model, network, customer records, sending action or authenticated service.

Keep the distinction between a process killed after commit while idle and a kill inside a transaction, a host power failure, a storage outage or a remote queue failover. This exercise does not establish those properties or prove at-most-once external effects. Python documents the POSIX kill and return-code behavior; SQLite describes its commit boundaries and storage assumptions.

For a receiving task, ask another engineer to identify the observation that permits reclaim, explain why the failed pre-expiry attempt spends no budget and propose one still-unrun failure experiment. Keep the original JSON with that operator note; do not relabel a proposed experiment as executed evidence.

Compete for one job from separate processes

Use Python 3.11 or later and the same standalone worker file. Predict the consumed attempt count before running:

Code example
python3 fde-worker-recovery-lab.py race-demo

The command admits one synthetic R1 job in its own temporary database and starts two fresh Python processes. Each opens a separate connection before a shared starting gate releases both. Either worker may win; the gate does not guarantee overlapping execution or a particular ordering. Inspect your actual report instead of assigning worker A the winning role in advance.

Report fieldObservation to explain
workersTwo distinct process IDs; one claimed, one lease_busy.
Winning fence1: only one claim was admitted.
after_claims.attempts1, not 2: the refused contender did not consume another attempt.
after_claims.staterunning; result_digest is still null. A lease is not completion.
integrity_checkok on the local file after both processes exit.

The current claim method begins a writer transaction before reading the job, checking its lease and updating its ownership. A process-local lock would not coordinate these separate workers. The second writer must inspect the committed lease and refuse while it is live. SQLite's bounded lock wait can instead fail with a database error under other contention; that is different from the domain's lease_busy refusal. Do not translate a storage failure into permission to run. SQLite transaction control explains the single-writer boundary and BEGIN IMMEDIATE behavior.

Receiving task: give a peer the JSON without your explanation. Have them identify the current owner, consumed attempts and evidence still missing before calling the job complete. Then inspect the sequential expiry demo: explain why reclaim at injected tick 5 may increment the fence, while a competing claim at tick 0 may not. Keep this local observation separate from fleet capacity, clock agreement, lock-timeout recovery, network partitions and external effects. No throughput, distributed execution or authenticated worker identity is tested.

1d. Inspect a shared delegation budget

DELEGATION / TRACE WALKTHROUGH

One request.
One shared budget.

Step through supplied output from the downloadable coordinator. These are synthetic offline observations. No workers, model calls or external actions run here.

Does a failed attempt refund the shared allowance?

Attempts consumed
0 / 2 total
In flight
0 / 2 slots
Source
v3 · current

Before dispatch. Predict the next decision. Deadline: 1000 virtual ms.

  1. 100 ms
    Reserve worker · D1Decision hidden — step forward
  2. 120 ms
    Reserve worker · D2Decision hidden — step forward
  3. 400 ms
    Worker result · D1Decision hidden — step forward
  4. 450 ms
    Worker failure · D2Decision hidden — step forward
  5. 600 ms
    Reserve worker · D3Decision hidden — step forward
  6. 650 ms
    Worker failure · D3Decision hidden — step forward
  7. 675 ms
    Check candidate · D1Decision hidden — step forward
Download the coordinator · Node.js 24

Use the interactive trace on the free lab page before running the coordinator. Choose a case, predict the next decision, then use Next event to inspect the supplied observation. Previous and Restart trace let you revisit the reasoning. The browser replays recorded synthetic output; it does not dispatch workers, run a model or grade your work.

Download fde-delegation-lab.mjs, check Node.js 24 and run:

Code example
node --version
node fde-delegation-lab.mjs supported
node fde-delegation-lab.mjs failed-retry
node fde-delegation-lab.mjs source-withdrawn
node fde-delegation-lab.mjs terminal-manual
node fde-delegation-lab.mjs exact-deadline
node fde-delegation-lab.mjs --all

The final command prints 13 scenario records, one JSON object per line. Exit 0 means the replay ran; it does not mean every proposed action was permitted. No packages, API keys or network calls are needed. Keep the actual output.

In failed-retry, D1 and D2 consume both attempts. D1 returns at 400 virtual ms; D2 fails at 450. At that point, attempts consumed is 2 and in flight is 0. Failure releases a slot without refunding the shared allowance. D3 is refused at 600. Its message at 650 is unknown-attempt, not proof of a third execution.

candidate-held is intermediate. In supported, review rechecks the current source before producing a draft for operator review; nothing is sent. In source-withdrawn, the candidate arrives before withdrawal, but the later review cannot use it. In terminal-manual, the explicit manual decision closes the request before the result arrives. In exact-deadline, an event at 1,000 virtual ms is too late. These timestamps are injected inputs, not latency measurements.

For a changed-constraint experiment, use a disposable copy and change only maxAttempts: 2 to maxAttempts: 3. Predict and rerun failed-retry and foreign-scope. More budget can admit a retry; it cannot authorize foreign scope, revive a withdrawn source or reopen the terminal manual route. Ask a receiver to explain those boundaries from the recorded events.

The existing delegation workbook practice contains the fuller worker packet, conflicting references and receiving contract. Keep that material beside this trace. The local coordinator is single-process and scripted: it does not establish atomic distributed reservation, authenticated worker messages, real cancellation or model quality. A deployment needs isolated integration evidence for those boundaries.

1e. Recover a receiver after its response is lost

25-minute local lab · Python 3.11+ · No packages or provider key

An agent worker can lose its connection after a destination commits an action. Restarting that worker does not establish whether the action happened. Download fde-receiver-recovery-lab.py from the lab chooser. Before running it, predict the effect and receipt counts for each boundary below.

Code example
python3 fde-receiver-recovery-lab.py test
python3 fde-receiver-recovery-lab.py demo

The parent starts only children of this lab in a temporary synthetic workspace. Each child exits abruptly at an explicitly named SQL boundary. Exit 24 occurs after both inserts but before commit; exit 23 occurs after commit but before printing a response. Exit 25 belongs to a deliberately broken receiver that commits its effect separately from its receipt. These codes are lab markers, not HTTP status codes. The temporary files are removed after the report.

BoundaryBefore retry: effects / receiptsAfter retry: effects / receipts
Before shared commit0 / 01 / 1
After shared commit, response missing1 / 11 / 1
Broken: effect committed alone1 / 02 / 1

These are expected local observations; keep the actual JSON from your own run. A missing response means the caller has no receipt. It does not mean the destination has no effect. Inspect before_retry before reading after_retry. For the shared transaction, BEGIN IMMEDIATE serializes the local writer check; the unique tenant/request key binds a canonical payload digest to an effect ID. The effect and receipt commit together. Retrying the same key and payload returns the stored ID. A different payload conflicts; a new key can create another effect. This is request replay protection, not business-level duplicate detection.

Inspect test_distinct_processes_racing_same_key_share_one_effect: two actual processes target one local database and receive the same receipt. Replays still check the current synthetic work-order grant. A key, digest or tenant name is not an authentication credential. In a deployed host, derive tenant context from verified identity and authorize the specific action; do not trust an agent's argument to supply either authority or scope.

Receiving task. Explain the broken receiver's 1 / 0 state to another engineer, then show the retry that produces 2 / 1. Ask them to identify the transaction boundary that repairs it. Propose one changed-payload experiment, run it, retain the conflict and unchanged effect count, and record their actual challenge and your revision. Keep a separate unrun register for remote service failure, database failover, retention expiry and a crash inside commit.

The row in effects is the entire synthetic effect. No email, payment, real tool call, model or network request runs. This is abrupt local process exit around commit, not a power-loss test or a distributed exactly-once guarantee. A local transaction cannot atomically include an unrelated remote service. That service needs its own supported idempotency contract, stable operation identity and an authorized outcome lookup or reconciliation path. Deleting receipts or choosing a fresh key to clear an uncertain outcome can duplicate work. Set retention and reconciliation policy before adapting the pattern to a real receiver.

Implementation references: Python's explicit transaction control and SQLite's atomic commit boundary. The lab uses explicit SQL with isolation_level=None; it does not depend on the newer Python autocommit connection argument.

1e. Fence the effect at the receiving resource

A worker can lose its lease after a successful precheck and still reach a separate destination. The new worker fencing proof workshop pauses an actual worker, reclaims the job in another process and compares the separate queue and destination databases. Download the standalone runner; it needs only Python 3.11+ and uses synthetic temporary data with no network.

Code example
python3 fde-worker-fencing.py
python3 fde-worker-fencing.py --case fence-old-first --units 3

Compare finish-only, new-first fencing, old-first fencing, same-fence repetition, an atomic operation receipt and a changed-payload conflict. This destination refuses an older token after an admitted transaction commits a newer fence; it is not a live lease or permission check. Equal-token retries need a separate operation contract. Keep actual destination effects beside the queue's refused completion, then have a receiver reproduce the changed-unit result. The seventh fence-rollback case contrasts a failing connection’s temporary mark 2 with committed mark 0 after rollback. A token received by a failed transaction is not an established destination fence. The standalone workshop includes the full diagram, predictions, source references and receiving responsibilities.

2. Run a real LangGraph interrupt/resume graph

Keep the framework experiment separate from the standard-library reference. In a new isolated virtual environment, install LangGraph from its normal Python package registry, then record the actual resolved versions:

Code example
python3 -m venv .venv
. .venv/bin/activate
python -m pip install "langgraph==1.2.16"
python -m pip freeze > requirements.lock.txt
python fde-langgraph-lab.py

On Windows activate with .venv\Scripts\activate. Keep the lock file with your practice evidence; use it to reproduce the same environment. The top-level package is pinned to the version used for this walkthrough; transitive versions are captured by your freeze output. It is not a complete pre-resolved lock manifest. The supplied graph was run with Python 3.12 and LangGraph 1.2.16 on 17 October 2026. Follow the linked upstream documentation if your installed version differs.

The graph uses StateGraph, InMemorySaver, interrupt and Command. It asserts that the first invocation waits for review, then scripts an accepted resume. This checks graph wiring with a deterministic drafting node. It is neither a live model evaluation nor a real human-review session. InMemorySaver does not survive a process ending. The SQLite reference illustrates a separate durable design; it is not presented as a LangGraph checkpoint adapter.

2a. Resume a real LangGraph after process exit

LangGraph / Checkpoint explorer

Follow a review through the graph.

Inspect five recorded observations from the local Python lab. Review inputs are scripted; this viewer runs no graph and saves no decisions or progress.

Choose a recorded snapshot

Observation 3 / 5

One acceptance leaves the owner waiting.

The specialist receives its bound answer. Both review nodes re-enter in this pinned SDK, but the owner interrupts again without a decision. Node entry is not approval; finalize has not run.

01 / Draft

Proposal prepared

Same bound draft

Retained
02 / Specialist

Technical review

Merged decision

Accepted
02 / Owner

Accountable owner

Unanswered interrupt

Awaiting decisiond7fb4ac7533cc20d6a4b50b3d50c5480
03 / Join

Finalize

Waiting for owner

Gate closed
Draft → two independent reviews → one joined outcome. An interrupt ID routes an answer; it grants no permission.
Node calls in this processowner → specialist
Saved task resultspecialist: accepted
Inspect recorded JSON · observation 3
{
  "code": "dual-review-observed",
  "status": "awaiting_review",
  "digest": "55630fa2aaaec88ab040caf7d220f20739965f5c6c1ffae6ecec157ae96044c5",
  "pending_reviews": {
    "owner": "d7fb4ac7533cc20d6a4b50b3d50c5480"
  },
  "saved_review_results": {
    "specialist": "accepted"
  },
  "merged_decisions": {
    "specialist": "accepted",
    "owner": ""
  },
  "next": [
    "owner"
  ],
  "node_calls": [
    "owner",
    "specialist"
  ],
  "sent": false
}

Recorded 2026-10-19 · Python 3.12.14 · LangGraph 1.2.16 · 5 separate processes

python3 fde-langgraph-durable-lab.py dual-demo --db graph-two-reviews.sqliteDownload the Python lab

Reproduce your own output in a new local file. IDs are synthetic routing data. Real identity, concurrent resume and external effects require separate checks.

Download fde-langgraph-durable-lab.py. This uses the real LangGraph StateGraph, interrupt and SqliteSaver APIs. It is separate from both the earlier in-memory walkthrough and the standard-library SQLite reference. Use a new disposable working folder and isolated environment:

Code example
python3 -m venv .venv-graph
.venv-graph/bin/python -m pip install "langgraph==1.2.16" "langgraph-checkpoint==4.3.0" "langgraph-checkpoint-sqlite==3.1.2"
.venv-graph/bin/python -m pip freeze > langgraph-requirements.lock.txt
.venv-graph/bin/python fde-langgraph-durable-lab.py test
.venv-graph/bin/python fde-langgraph-durable-lab.py demo --db graph-demo.sqlite

On Windows replace .venv-graph/bin/python with .venv-graph\Scripts\python.exe. Package installation needs normal registry access; installed lab commands need no model key and refuse socket connections. The three package versions above were used with Python 3.12.14 on 18 October 2026. Retain your own resolved lock output and observations.

Fourteen tests check real process-separated persistence, scope naming, refused resume, sequential terminal replay/conflict, rejection, per-request proposal binding and preservation of an existing file. The scripted demo uses four child processes: start, inspect, accept and repeat the decision. Compare these fields:

ObservationWhat it establishes locally
First process: awaiting_review, next review, interrupted trueA pending graph checkpoint exists.
Second process: same digest and pending stateA fresh graph instance reads the saved work.
Third process: accepted, empty next, interrupted falseThe scripted bound decision resumed this local graph.
Fourth process: decision-replayedThe sequential host guard returns the recorded decision.

The demo requires a new filename. An existing graph-demo.sqlite is preserved with demo-needs-new-file; inspect it or choose another disposable filename. Do not reuse a real application database. For manual work, run start and inspect against another new local file:

Code example
.venv-graph/bin/python fde-langgraph-durable-lab.py start --db graph-practice.sqlite
.venv-graph/bin/python fde-langgraph-durable-lab.py inspect --db graph-practice.sqlite

Copy the digest from your actual inspect JSON. Replace the literal PASTE_OBSERVED_DIGEST below with that value; it is a proposal fingerprint, not a credential. Leaving the placeholder in place must refuse the resume.

Code example
.venv-graph/bin/python fde-langgraph-durable-lab.py resume --db graph-practice.sqlite --decision accepted --digest PASTE_OBSERVED_DIGEST

Before acceptance, try a wrong digest, add --source-version 4, or add --deny-review. Each must return a named refusal with exit 2 and preserve the pending checkpoint. The flags simulate trusted host source/reviewer state; they are not authentication. Start a second request with --request R2 and show that the R1 digest cannot approve it. Then accept the correct proposal, repeat the decision and try the conflicting rejected decision. Retain the actual outputs rather than counting every process exit as completed work.

The LangGraph interrupt guide explains that the interrupted node restarts from its beginning. This lab puts no external effect before interrupt. Its code enables strict checkpoint MessagePack handling and disables inherited remote tracing. Keep the SQLite file private and never load an arbitrary checkpoint database.

Normal process exit is not a hard-kill, power-loss, concurrency or migration experiment. The sequential host checks are not a distributed compare-and-set; thread naming is not tenant authentication. File access, reviewer authorization, retention, encryption, backup and schema compatibility require separate deployed controls. No message is sent, and the CLI's scripted accepted value is not an observed independent human review or a business outcome.

Recover a failed node before resuming review

20-minute extension · Same pinned environment and file, Edition 2 or later

A node failure is not a human-review interrupt. Run the new scripted failure rehearsal against another fresh disposable database:

Code example
.venv-graph/bin/python fde-langgraph-durable-lab.py failure-demo --db graph-failure.sqlite

Five separate processes start with a deliberate review-node exception, inspect the checkpoint, retry the failed node, supply a bound decision and replay it. The exception simulates an unavailable dependency; no external outage occurs. The graph, exception propagation, checkpoint storage and process boundaries are real local execution. Compare the actual fields before explaining the result:

ProcessNode calls in this processPending failureHuman interrupt
Deliberate failuredraft, reviewtruefalse
Fresh inspectionnonetruefalse
Retry without a new inputreviewfalsetrue
Bound accepted resumereviewfalsefalse
Same decision replaynonefalsefalse

The failure occurs after the completed draft step has checkpointed. Retrying uses graph.invoke(None, config) on the same thread, not a new input or a human decision. The observed draft digest must remain unchanged. In these pinned versions, task_error_nodes still contains review when retry reaches interrupt. That retained metadata is not itself an instruction to retry again. Inspect interrupted, next and pending_failure together. The latter is a host interpretation for this sequential teaching graph, not a general SDK API. Even the stored application string awaiting_review precedes the actual interrupt, so it cannot by itself distinguish these states.

Try the sequence manually in a new file. The first command deliberately exits 2; this is an observed failure, not a passing execution. Copy the digest from your actual inspect output into each placeholder below (a fingerprint, not a secret):

Code example
.venv-graph/bin/python fde-langgraph-durable-lab.py start --db graph-retry.sqlite --fail-before-review
.venv-graph/bin/python fde-langgraph-durable-lab.py inspect --db graph-retry.sqlite
.venv-graph/bin/python fde-langgraph-durable-lab.py retry --db graph-retry.sqlite --digest PASTE_OBSERVED_DIGEST
.venv-graph/bin/python fde-langgraph-durable-lab.py resume --db graph-retry.sqlite --decision accepted --digest PASTE_OBSERVED_DIGEST

Before retry, try resume: it must return retry-required. Try a wrong digest, --source-version 4 or --deny-review with retry; each refuses without running a node. After retry reaches an interrupt, retry must return not-failed and leave it waiting. Retry never supplies a human decision. Review-node entry appears again when the bound decision resumes because code before interrupt re-enters; keep irreversible effects out of that region. No provider or sending tool runs.

Receiving task. Have another engineer explain why the error metadata after retry does not justify another automatic attempt. Retain all five observations, the unchanged digest and per-process node calls. Ask them to distinguish a completed earlier graph step from side effects inside a failed node. A node's own partial external work may repeat on retry; this exercise does not make that work atomic or establish a distributed exactly-once guarantee. Keep automatic retry policy, real dependency outages, concurrency, cancellation and crash recovery inside a node separately unrun. Consult the current checkpointer guide for step/task persistence; retain the actual package versions beside this result.

Recover a parallel step without repeating its completed branch

20-minute extension · Edition 3 · Same pinned packages

The sequential failure exercise finishes the draft in an earlier graph step. This extension schedules draft and policy as sibling branches in the same step and joins them before review. Policy deliberately raises; draft completes. No real policy service, model or external action runs. Predict whether the completed draft needs to run again, then use another new disposable file:

Code example
.venv-graph/bin/python fde-langgraph-durable-lab.py parallel-demo --db graph-parallel.sqlite

Four fresh processes fail the policy branch, inspect saved work, retry and supply a bound review decision. The local SDK schedules the sibling branches; this exercise does not measure wall-clock overlap, throughput or cost. First-call ordering can vary. Retain the actual JSON and compare these observations:

ProcessNode calls in this processWhat to inspect
Scripted branch failuredraft + policy, order unspecifiedtask_results.draft true; policy error; no review interrupt
Fresh inspectionnoneSame draft digest and saved draft task result
Retry same thread with no new inputpolicy, reviewDraft does not repeat; policy checked; review interrupted
Bound accepted resumereviewAccepted state and no next node

get_state exposes the saved draft output while the sibling policy task still has an error. Visible draft text, digest or awaiting_review status does not establish that the joined step is complete. Inspect task_results, task_error_nodes, policy_status, next and interrupted together. The checked policy value is a deterministic teaching marker, not an authorization, safety or compliance assessment. The review node will not proceed until that branch returns its marker, and interrupt still requires a separate decision.

For a manual rehearsal, use a different fresh filename. The first command intentionally exits 2. Copy your actual inspect digest into the placeholders:

Code example
.venv-graph/bin/python fde-langgraph-durable-lab.py parallel-fail --db graph-parallel-practice.sqlite
.venv-graph/bin/python fde-langgraph-durable-lab.py parallel-inspect --db graph-parallel-practice.sqlite
.venv-graph/bin/python fde-langgraph-durable-lab.py parallel-retry --db graph-parallel-practice.sqlite --digest PASTE_OBSERVED_DIGEST
.venv-graph/bin/python fde-langgraph-durable-lab.py parallel-resume --db graph-parallel-practice.sqlite --decision accepted --digest PASTE_OBSERVED_DIGEST

Before retry, attempt parallel-resume; it refuses with not-awaiting-review. Try a wrong digest, --source-version 4 or --deny-review on parallel-retry; each refuses without discarding the completed draft. After retry reaches interrupt, a second parallel-retry returns not-failed. Replaying the same bound decision returns the recorded result; a conflicting later decision is refused. The parallel graph uses a distinct synthetic thread name from the sequential graph. That separates this exercise's state, not permissions; trusted host identity and access to the checkpoint file still need a real deployment boundary.

Receiving task. Ask another engineer to identify the saved result before retry, then show that the fresh process calls policy and review without draft. Have them explain why starting a new thread or providing a new input would be a different operation, and why completing both branches still does not grant human acceptance. Keep their actual challenge and your revision with the JSON. The SDK persists completed task writes for recovery; it does not undo or make an external effect inside a failed branch atomic. Do not clear the checkpoint to hide a failure. Multi-host coordination, real policy service failures, cancellation, reducer conflicts, schema upgrades, power loss and external exactly-once behavior remain separately unrun. The checkpointer guide explains pending task writes; the fields above are observations of this pinned local experiment.

Route two independent reviews by interrupt ID

25-minute extension · Edition 4 · Same pinned packages

A specialist and an accountable owner must each review the same local proposal. One decision must not accidentally answer the other person's question. This exercise uses a real LangGraph fan-out to two interrupting nodes and a join that runs only after both return. Each branch owns its own decision field. The role flags and decisions are scripted teaching inputs, not authenticated people or recorded independent human review. Nothing is sent.

Download the current fde-langgraph-durable-lab.py, keep the isolated environment from this chapter, and predict the state after only the specialist accepts:

Code example
.venv-graph/bin/python fde-langgraph-durable-lab.py test
.venv-graph/bin/python fde-langgraph-durable-lab.py dual-demo --db graph-two-reviews.sqlite

Use a new disposable filename. Five separate processes start two interrupts, inspect them, resume only the specialist, inspect again and resume the owner. Retain the actual generated IDs; do not substitute names, array positions or IDs from another run. The SDK accepts an ID-to-value map as the resume input:

Code example
Command(resume={observed_interrupt_id: {
    "decision": "accepted", "digest": observed_digest, "role": "specialist"
}})

The host first matches the role to its currently pending ID, checks the proposal digest, current source version and synthetic reviewer grant. The node also validates the supplied decision, digest and role. An interrupt ID routes a value; it is not a permission or proof that the proposal is still acceptable. The LangGraph interrupt reference describes resume behavior; the table records this pinned local experiment:

ObservationPending reviewsDecision evidenceFinalize ran?
Start and fresh inspectionspecialist and owner, distinct IDsNeither recordedNo
Specialist-only resumeowner, same original IDspecialist accepted; owner emptyNo
Fresh inspection after partial resumeownerSame saved specialist resultNo
Owner acceptsnoneBoth acceptedYes; accepted

The first partial resume re-enters both reviewer nodes in these pinned versions. Owner reaches its unanswered interrupt again; specialist receives its bound value. Node entry is not approval. No draft or finalize runs during that partial resume. After a fresh inspection, the final owner resume calls owner and finalize without repeating specialist or draft. Inspect pending_reviews, saved_review_results, merged_decisions, next and node_calls together. The saved-task evidence is transient: finalization removes pending tasks, while the merged decisions remain in application state.

Try it manually in another new file. Replace each placeholder with the value from your own dual-inspect output; fingerprints and IDs here are synthetic local routing data, not credentials:

Code example
.venv-graph/bin/python fde-langgraph-durable-lab.py dual-start --db graph-review-practice.sqlite
.venv-graph/bin/python fde-langgraph-durable-lab.py dual-inspect --db graph-review-practice.sqlite
.venv-graph/bin/python fde-langgraph-durable-lab.py dual-resume --db graph-review-practice.sqlite --review-role specialist --interrupt-id SPECIALIST_ID --digest OBSERVED_DIGEST --decision accepted
.venv-graph/bin/python fde-langgraph-durable-lab.py dual-inspect --db graph-review-practice.sqlite
.venv-graph/bin/python fde-langgraph-durable-lab.py dual-resume --db graph-review-practice.sqlite --review-role owner --interrupt-id OWNER_ID --digest OBSERVED_DIGEST --decision accepted

Before a valid resume, try the owner's ID with the specialist role, an invented ID, a wrong digest, --source-version 4 and --deny-review. Each returns a specific refusal with exit 2 and leaves the decisions unchanged. Reusing a consumed ID also refuses; this extension deliberately does not replay terminal reviews. Starting the same request again refuses instead of replacing its work.

Receiving task. In a fresh file, reverse the decision order and have the scripted owner reject first. Predict the intermediate state and final outcome before running it. The graph still waits for both decisions, then returns rejected if either rejected. Ask a peer to identify the exact unanswered ID, explain why an earlier accepted field is insufficient and locate the host check that refuses a crossed role/ID. Keep their challenge and your revision beside the JSON. Changing the business rule to short-circuit on rejection requires an explicit cancellation and retained-evidence design; it is not demonstrated here. Real identity, role authorization, source retrieval, concurrent resume claims, hard-kill recovery and external effects remain separate deployment work. This local CLI checks sequentially and does not establish distributed atomicity.

2b. Run the actual LangChain tool-calling loop offline

Download fde-langchain-agent-lab.py from the free lab page or the LangChain lesson's Practice section. In a new disposable folder, create a separate virtual environment before installing the pinned packages. Record all resolved versions; this walkthrough does not require the earlier LangGraph setup:

Code example
python3 -m venv .venv-chain
. .venv-chain/bin/activate
python -m pip install "langchain==1.4.6" "langgraph==1.2.16"
python -m pip freeze > requirements.lock.txt
python fde-langchain-agent-lab.py test
python fde-langchain-agent-lab.py supported
python fde-langchain-agent-lab.py foreign-source
python fde-langchain-agent-lab.py authority-override
python fde-langchain-agent-lab.py unknown-tool
python fde-langchain-agent-lab.py spin

On Windows activate with .venv-chain\Scripts\activate instead.

Nine tests passed with Python 3.12 and those top-level package versions on 19 October 2026. Retain your own actual result. The tests also refuse socket connections, and the script disables inherited remote tracing. Package installation needs registry access; the installed lab needs no provider key.

This uses the real LangChain create_agent orchestration and a deterministic BaseChatModel adapter that proposes each supplied tool call. It is not an inference run or a measure of model quality. The ordinary trajectory should be input, tool-proposal, tool-result, answer. The scoped business lookup admits P1 and withholds the foreign P9 text. The strict tool schema rejects an added tenant field before lookup; an ungranted sender is never dispatched.

spin intentionally reaches the graph step limit, reports incomplete and exits with status 2. This is an expected refusal, not an installation failure. A finished graph can still produce a withheld answer. Do not turn either state into an accepted business outcome. The step ceiling is not an elapsed-time, token, distributed-work or external-service budget.

Inspect the source and change a supplied proposal. Add a test that keeps the ordinary request useful while proving the new refusal. A future provider-backed adapter requires a separate environment configuration, model-quality evaluation and execution evidence; do not relabel these scripted results as model results.

Bound business dispatches inside one model turn

A single model response can request several calls. Run the comparison in the same installed environment; it uses three identical, scripted P1 proposals in each run, with the same graph step ceiling:

Code example
python fde-langchain-agent-lab.py budget-demo
RunBusiness lookupsWithheld before lookupUseful P1 draft
Baseline30Yes
Host limit 112Yes

Each proposal retains a correlated result even when its business lookup is withheld. Compare proposed_call_ids with each result's call_id, and count business_dispatches separately from withheld_before_lookup. Do not expect the same callback to win every time. The final adapter examines all results in the turn so a withheld last message does not erase an earlier useful result. The LangChain agent guide describes the orchestration; this installed exercise supplies scripted decisions, not an inference result or a model-quality evaluation.

DispatchBudget belongs to the host and uses an in-process lock. A reservation is consumed before source lookup, including a lookup that returns unavailable. The tests also show that schema rejection occurs before this counter. It is a business-dispatch ceiling, not a ceiling on all proposed or malformed attempts. Resetting the budget inside each callback would remove the aggregate bound. It does not limit tokens or remote duration, deduplicate requests, cancel work already started, or coordinate another process. A new service process would have its own lock and counter unless the host introduced shared accounting.

Receiving exercise · 20 minutes: predict and then change the trusted limit from one to two in a disposable copy of budget_demo. Keep the three proposal IDs and useful draft; expect two business lookups and one withheld lookup. Retain the original and changed output. Explain why an unavailable lookup still spends a reservation, where schema refusals would be counted, and what shared state would be needed for two service processes. Restore the reference before running its fixed-limit tests. Do not add sending, credentials or a live endpoint.

2c. Evaluate useful work, stale approval and missing evidence

Download fde-agent-evaluation-lab.py and fde-agent-engineering-lab.py into the same disposable directory. This exercise uses the Python standard library; no package installation, model account or network connection is needed. Use Python 3.11 or later, and record python3 --version with your output.

Download both files: evaluation lab and required workflow reference. Keep their original filenames together in one folder before running a command. The library and technical-track cards also place the required-file download beside this lab. Downloading the evaluator alone cannot satisfy its local import.

Predict the failed case IDs before running:

Code example
python3 fde-agent-evaluation-lab.py test
python3 fde-agent-evaluation-lab.py run --candidate reference
python3 fde-agent-evaluation-lab.py run --candidate refuse-all
python3 fde-agent-evaluation-lab.py run --candidate stale-review
python3 fde-agent-evaluation-lab.py run --candidate version-only
python3 fde-agent-evaluation-lab.py run --candidate reference --omit-case withdrawn-source

The first command verifies the evaluator, not a learner's competence. Each run calls the reference's real domain methods against new temporary synthetic SQLite databases. The intentionally broken subclasses are teaching copies: refuse-all refuses useful work; stale-review skips the current-source check before acceptance; version-only checks activity/version but omits content binding. They are never proposed production changes.

Inspect the actual report rather than copying these expectations:

CandidateWhat the declared contract should expose
referenceUtility 1/1, boundary 5/5, recovery 1/1; all seven v2 cases observed.
refuse-allForeign-source denial passes, but useful drafting fails; setup-dependent cases report failed observations.
stale-reviewUseful drafting and replay pass; changed, withdrawn and same-version-edited source acceptance fail.
version-onlyThe original six cases pass, but same-version-source fails and persists accepted after reopening. The v2 contract is blocked.
reference with omissionSix executed of seven planned; withdrawn-source remains unrun, so the local decision is blocked.

Exit 0 means local_contract_met. The mutants and omission example deliberately exit 2 with blocked; this is the exercise's expected result, not an installer error. The JSON keeps utility, boundary and recovery denominators separate and lists each failed or unrun case. Duplicate and unknown case IDs are rejected. Unexpected exceptions become failed observations with their class name only; source bodies, database paths and exception messages are not exported.

Change one real requirement before changing code. For example, the current contract does not authenticate reviewers or test revocation between pause and resume. Define that adapter and its acceptance cases rather than treating the existing seven passes as evidence for it. Add a new case without removing a failed case from the denominator. Keep predictions, observed JSON, source revision and unrun work in the handover. These are deterministic local observations, not inference-quality scores, customer outcomes or permission to release a service.

Find the gap behind six passing observations

Edition 2 identifies its report as field-desk-regression-v2. Its seventh case, same-version-source, edits the pending source body without incrementing its version, attempts acceptance and reopens the database. The expected observation is source_changed, persisted stale and an unchanged version. This is the same boundary exercised by the workflow reference's source-change demonstration.

Predict the new mutant before running it. version-only passes all six original cases, including useful drafting, changed-version denial and restart replay. It fails the new case because a version number did not bind the source content. Six passing observations did not make the old packet complete for this newly stated requirement. Keep that difference between observed coverage and untested requirements visible when discussing an agent benchmark.

Code example
python3 fde-agent-evaluation-lab.py run --candidate version-only
python3 fde-agent-evaluation-lab.py run --candidate version-only --omit-case same-version-source

Both commands must exit 2. The complete run observes six passes and one failure. The omitted run observes six passes and one unrun case: boundary evidence is 4/5, not a new 4/4 denominator. A report with the new case absent cannot silently relabel itself as the old contract or claim the new boundary is tested.

For fifteen minutes of receiving practice, give a peer both JSON packets before explaining them. Ask which observation is missing, which is a failure and why neither closes v2. Have them add an independently chosen source change, freeze its expected observation before running, and retain an unchanged useful case. A local contract result remains separate from model quality, authenticated reviewer authority and a production release decision.

2d. Check MCP tool admission

This standalone lab practices the host policy around a Model Context Protocol (MCP) tool. It uses MCP-shaped descriptor fixtures, not a running MCP server or SDK. No packages, network, credentials or model account are needed. Download fde-mcp-contract-lab.mjs, check Node.js 24, then run:

Code example
node --version
node fde-mcp-contract-lab.mjs test
node fde-mcp-contract-lab.mjs supported
node fde-mcp-contract-lab.mjs changed-description
node fde-mcp-contract-lab.mjs forged-scope
node fde-mcp-contract-lab.mjs hint-is-not-authority
node fde-mcp-contract-lab.mjs demo

The test command runs nine checks and exits nonzero on a failed assertion. demo prints 15 scenario records. Scenario commands exit 0 when a replay runs, including a refused call; inspect code and dispatches, not just the exit status. Unknown selectors and extra arguments exit 2.

The MCP tools specification defines discovery, tool schemas and calls. Annotations from untrusted servers are untrusted. Input validation and access controls remain implementation responsibilities. This exercise adds an original local host-admission policy; its digest review is not claimed to be a mandated MCP consent mechanism.

Predict these distinctions before reading your actual output:

CaseBoundary to investigate
supportedOne useful P1 lookup; returned excerpt remains untrusted data.
changed-description / changed-schema / changed-output-schema / changed-annotationsReviewed definition changed; zero business dispatches.
forged-scopeExtra tenant field rejected before dispatch.
foreign-recordOne business lookup; unavailable without foreign text.
revoked-grant / changed-connection / changed-principal / expired-approvalExisting synthetic review does not renew current authority.
hint-is-not-authorityA read-only annotation cannot grant a sending callable.
withdrawn-sourceA valid ID cannot recover withdrawn content.
malformed-result / oversized-resultReturned context withholds invalid or oversized output.

The host's connection key, principal, tenant, approval and clock are trusted synthetic inputs. A real adapter must establish them independently of model arguments and self-reported server names. The local fingerprint covers the reviewed JSON definition, with stable object-key ordering. It is not a signature, endpoint authentication, code attestation or proof that the tool is safe.

The business callable rechecks current scope even when called without the adapter. Argument and result checks are handwritten for exactly the authored contract; they are not a general JSON Schema validator. The result ceiling counts serialized UTF-8 bytes, not characters or tokens, and applies after the local lookup. It cannot cap transport allocation, tool duration, invocation rate or other external costs.

In a disposable copy, remove only the digest-comparison line. Run test again and retain the failed changed-definition observation. Restore the check and show that the ordinary lookup still works. Ask a receiver why increasing an output budget cannot authorize a foreign source or a sender.

Finally, add one new case and its expected dispatch count. Identify the real MCP transport/version negotiation, OAuth, revocation during a remote call, deadlines and rate controls still to test separately. Valid returned text remains untrusted: this lab makes no inference call and does not measure prompt-injection resistance, factual quality or human approval.

Trace a source instruction through a second tool proposal

Edition 2 adds a two-call host-boundary rehearsal:

Code example
node fde-mcp-contract-lab.mjs followup-demo

Each record first looks up a valid P1 source whose excerpt contains an injected instruction to change to south scope and send a response. That first result is schema-valid, within the byte limit and context-ready. Its trust remains untrusted-source-data. The lab does not detect, remove or neutralize the text. The next proposal is an authored fixture, not a model response. This experiment tests application enforcement after source retrieval, not model resistance to prompt injection.

Follow-upFirst lookupSecond proposal and observation
ordinary-lookupOne dispatch, untrusted excerptA normal P1 lookup remains admitted; the returned excerpt is still untrusted.
scope-claimSame accepted sourceAn extra tenant field is invalid-arguments with zero further business dispatches.
send-claimSame accepted sourcesend_response is tool-not-allowed with zero further business dispatches.
revoked-betweenSame accepted sourceTrusted fixture permission is revoked before the next dispatch; access-denied retains zero further business calls.

Explain the two dispatch counts separately. Returning a source is not approving its instructions. The host's north scope never comes from the excerpt or the second proposal. Revocation changes the trusted host fixture, not a model-owned flag. The source is allowed to contain unsafe instructions without gaining any application authority; a schema-valid response is not a safe instruction channel.

Have a receiver predict the sender refusal before running the command. In a disposable copy, add an approved-looking field to the second proposal and retain the argument-shape refusal alongside the ordinary lookup. Identify where a real host derives identity and where a remote result could arrive after permission changes. Keep model behavior, semantic injection detection, remote in-flight revocation and external-effect cancellation unrun. No network, provider, message, credential or remote tool is used by this continuation.

2e. Shape an agent trace before exporting it

Observability / Trace boundary

What should reach the logger?

Predict a case, then inspect recorded output from the local Python lab. These eight synthetic cases use supplied statuses and timing. The browser does not run tools, export telemetry or record completion.

T2 / Proposed diagnostic fields

Useful tool diagnostics

The host reports lookup_procedure, outcome returned and elapsed_ms 12. The values are supplied synthetic inputs.

Predict the boundary decision

Choose a prediction to reveal the supplied observation.

Recorded 2026-10-18 · Python 3.12.14 · 8 supplied cases

Reproduce your own output locally:

python3 fde-agent-trace-lab.py demo

Keep useful diagnostics and challenge a newly added field. This packet does not establish production privacy or general detection of personal data.

20-minute observability lab · Python 3.11+ · No packages or provider key

Use the browser exercise above to predict a case and inspect its recorded JSON. Changing the case or trying again clears your prediction; it does not run the projector or save progress. Then gather your own output with the file below.

Download fde-agent-trace-lab.py. This standalone file projects application events through a deliberately closed schema before they could reach a logger. The two core commands below do not install an OpenTelemetry SDK or export anything. Predict which events retain useful diagnostics before running:

Code example
python3 fde-agent-trace-lab.py test
python3 fde-agent-trace-lab.py demo

The demo processes eight visible synthetic cases and reports every case ID. T1–T3 project: admission keeps a source version, a completed tool call keeps its bounded name/outcome/timing, and a model's readiness claim stays labeled model_proposal. That claim is not an application receipt or human approval. T4–T8 refuse: source text, an attempted tenant override, an exception message, a Boolean used as elapsed time and an unbounded tool name. Inspect your output; these are deterministic local observations, not model or learner scores. Tool statuses and elapsed milliseconds are supplied inputs, not measured calls.

BoundaryExplain the implementation choice
Host contextThe caller supplies a synthetic tenant and run separately; event fields cannot override them. Real authentication remains outside this lab.
Field contractExact keys and approved scalar values only. Extra nested fields refuse the event, rather than silently exporting their contents.
Evidence originTrusted host code chooses the event kind; a model cannot label its own claim an application observation.
FailureA fixed code crosses the boundary. Raw exception messages and rejected values are not echoed into the demo report.
SizeCompact serialized UTF-8 bytes are checked before release, with a default ceiling of 256. This does not limit ingestion memory or telemetry volume.

The approved diagnostic fields remain useful: an operator can correlate R1, inspect a withheld tool outcome or identify a timeout without reading a source body. Refusing every event would discard that useful path. Conversely, removing payload text from the viewer after a logger already persisted it is too late for this boundary. Call the projector before logging, tracing or exception reporting, and test those real sinks separately when adapting the exercise.

In a disposable copy, add a source_locator diagnostic. Define its allowed shape before changing the schema, keep a useful case, and add a case that tries to put source text or a personal identifier into that field. Do not solve the exercise by accepting arbitrary strings or removing the refused cases. Ask a receiver to reproduce a useful tool event and explain the model-claim label without your driving. Keep their question, your revision and actual output.

The synthetic tenant enum and run pattern are teaching fixtures. Even a valid opaque identifier can be linkable or sensitive in a real environment. This is not general PII detection, redaction of arbitrary text or a compliance assessment. These core observations do not test external exporter configuration, retention, access policy, deletion, sampling, distributed correlation or a production sink. The current OpenTelemetry GenAI content-capture guidance recommends leaving instructions, inputs and outputs uncaptured by default. Its conventions are developing; the event format here is an original application exercise and does not claim to implement those conventions.

Export real local spans with OpenTelemetry

Optional SDK extension · 25 minutes. Keep the same fde-agent-trace-lab.py file. The earlier core remains standard-library only; this separate environment installs the actual tracing SDK:

Code example
python3 -m venv .venv-otel
. .venv-otel/bin/activate
python -m pip install "opentelemetry-api==1.45.1" "opentelemetry-sdk==1.45.1"
python -m pip freeze > requirements.lock.txt
python fde-agent-trace-lab.py otel-test
python fde-agent-trace-lab.py otel-demo

On Windows use .venv-otel\Scripts\activate. Installation needs registry access. The installed CLI refuses socket connections and writes its SDK export to an in-memory text stream; no collector, OTLP endpoint or provider key is used. Five SDK checks passed with Python 3.12 and these versions on 19 October 2026, alongside the eight core checks. Without the optional packages, either SDK command returns setup_required and exits 2; this is not a successful trace. An inherited OTEL_SDK_DISABLED=true stays honored: missing spans produce incomplete, expected_spans_missing and exit 2, rather than a claimed export.

The OpenTelemetry Python instrumentation guide describes tracers, spans and event attributes. This extension uses an actual TracerProvider, SimpleSpanProcessor and ConsoleSpanExporter. The exporter writes JSON into StringIO, which the report reads back. A private provider, explicit resource labels and a fresh root context avoid installing a process-wide provider or inheriting ambient resource labels and parents. The application-owned training.* fields are not GenAI semantic conventions.

CaseLocal SDK observation
usefulTwo ended spans share a trace ID; the lookup's parent ID matches the run span ID. The readiness event remains a model proposal.
timeoutTwo spans carry ERROR and a fixed timeout code. No exception event or raw message is recorded.
payloadThe closed projection refuses the entire supplied packet before span creation; zero spans reach the local exporter.

Inspect IDs and status in your actual JSON; IDs and SDK timestamps change each run. The tool result and its elapsed_ms: 12 are authored inputs, not measured network activity. SDK start/end times measure this tiny local instrumentation sequence. UNSET is a span status, not task acceptance, and ERROR describes the supplied failure case. Neither records a human review.

The local exporter test checks what actually reached that sink, including resource labels. It does not establish OTLP delivery, distributed propagation, collector authentication, sampling, storage access, retention or deletion. The original 256-byte ceiling applies to each projected application event, not the complete SDK envelope or total trace volume. Avoid automatic exception capture when an exception might contain private arguments; a fixed diagnostic code can be recorded separately.

Receiving exercise: locate the run and lookup span, compare their trace and parent IDs, then explain why a model readiness event remains unaccepted. In a disposable copy, remove record(root, final) from the useful path. Retain the two spans and show the missing readiness event instead of calling the absence proof that no proposal occurred. Restore the reference, then name the next collector and cross-process experiment with its data-retention owner. Keep those integrations unrun until their own evidence exists.

2f. Inspect an MCP stdio compatibility exchange

Choose the wire profile before writing the adapter

Download the stdio compatibility lab. This is an actual parent/child-process exchange over standard streams, pinned to MCP 2025-11-25. It uses the handshake model: initialize, a matching version and tools capability, then notifications/initialized, tools/list and tools/call. The client waits for each response before issuing the next request. It does not implement the newer profile or automatic fallback.

Version choice matters in field integration. The 2026-07-28 versioning source describes a different model: version and capabilities travel with each request, without this initialization handshake. Its compatibility guidance distinguishes legacy, modern and dual-era implementations. An engineer maintaining a handshake-based integration needs an explicit supported-version contract; passing this older-profile lab does not establish compatibility with a modern endpoint. Sources checked 18 October 2026.

Use the pinned lifecycle, stdio transport and tool messages as protocol references. This teaching implementation supports one authored tool and one pending request. It is not an MCP SDK, general schema validator, complete protocol implementation or interoperability certification.

Run two processes and read the boundary

Save the one file in a new disposable folder. Node.js 24 and permission to start your own child process are required. No packages, model, socket, provider key or customer records are used. The child inherits no environment variables from the parent. The program always launches its own file with the current Node executable; it accepts no arbitrary command or remote endpoint.

Code example
node --version
node fde-mcp-stdio-lab.mjs test
node fde-mcp-stdio-lab.mjs supported
node fde-mcp-stdio-lab.mjs foreign-record
node fde-mcp-stdio-lab.mjs forged-scope
node fde-mcp-stdio-lab.mjs demo

The supported transcript contains four sent methods in order. The initialized notification has no request ID and receives no response. Each request has an incrementing ID; each accepted response must match the pending request. The peer writes a diagnostic to stderr, while stdout carries newline-delimited JSON frames. The client records only diagnostic presence, message identities and the synthetic result. peerExited: true confirms the owned child was closed for that run; it says nothing about remote lifecycle management.

The successful result remains untrusted-tool-content. A server-supplied name is not authenticated identity, and an available tool is not a grant to read another tenant. This peer has a fixed synthetic north scope and can return only the P1 teaching record. There is no sign-in or real authorization service in the lab. Keep the earlier host-admission lab beside it: transport correctness and application authority are separate obligations.

Diagnose the failure at the right layer

CaseExpected observationReceiving-engineer explanation
supportedreceived with a synthetic excerptThe selected wire path returned data; a person has not accepted its use.
foreign-recordtool-refused / tool-unavailableA valid tool invocation can refuse a resource without a protocol failure.
forged-scopeprotocol-refused, JSON-RPC code -32602An added model-controlled tenant field violates the one authored argument contract.
protocol-errorJSON-RPC code -32601A protocol error is distinct from result.isError in a tool execution response.
wrong-idunexpected-response-id before a callNever attach an unrelated response to the current operation.
missing-capability / unsupported-versionStop before discovery/callingDo not silently assume a tool capability or change the agreed profile.
before-readydiscovery-protocol-errorFor this pinned handshake profile, omitting the notification leaves the peer unready.
stdout-noise / oversized-framenon-json-stdout / frame-budgetA friendly status line on stdout breaks framing; the teaching client also limits its receive buffer.
timeoutrequest-timeout and a closed childThe local deadline limits waiting; it does not prove a remote action was cancelled.

Failures use fixed codes rather than copying malformed bytes. The 4 KiB receive limit and one-request-at-a-time contract are deliberately narrow; this client does not implement multiplexing, server notifications, pagination, reconnect, cancellation messages, HTTP/OAuth, server authentication, comprehensive output validation or a deployment sandbox. The deadline closes the owned local peer; do not substitute it for distributed cancellation semantics.

Extend and hand over the integration decision

First predict wrong-id and before-ready, then compare actual transcripts. In a disposable copy, add a second response with a valid-looking but unrelated ID and preserve the refusal. Restore the useful P1 path after the change. Explain what must change before this client could accept legitimate server notifications without confusing them with responses.

Give a receiver the selected protocol revision, commands, actual output, tool/resource refusals and the remaining integration work. Ask them to distinguish a received source, a refused tool, a broken protocol exchange and an accepted business outcome. A separate SDK/modern-profile experiment needs its own package versions and evidence; do not relabel this compatibility lab as that experiment.

2g. Evaluate agent canary evidence before widening access

Define the comparison before looking at the aggregate

Download the canary evidence lab. It evaluates supplied synthetic observations; it does not deploy, route traffic, call a model or decide a person's qualification. All acceptance labels are authored inputs. No supplied packet is evidence of a customer result or an actual human review.

A candidate can look healthy in a service-wide average while a smaller workflow deteriorates. The SRE canarying chapter explains why control/canary separation, representative exposure and aligned measurement windows matter. It also distinguishes artificial load tests from observing a real canary. This exercise is a local analysis of fictional packets, not a canary deployment. Reference checked 19 October 2026 UTC.

The local policy uses two fixed workflow segments, routine and exception. It requires at least 20 supplied observations per segment and cohort, permits at most a five-percentage-point error increase or accepted-work decrease, and limits the candidate response-latency p95 to 1.5 times the control. These are deliberately authored teaching thresholds, not SLO recommendations, statistical confidence bounds or a claim that twenty samples establish readiness. In a real release, choose and document appropriate criteria before exposure.

The packet declares admitted counts independently of its observation rows. The evaluator reconciles them; a missing row is not a successful request. It rejects duplicate IDs, inconsistent scalar types, impossible accepted/error combinations and unexpected segments. Windows must agree and each observation must fall inside the shared half-open interval. This validates the toy packet's consistency, not the authenticity of its counters, assignment, versions, labels or source system.

Run the cases and identify the decision layer

Save the standalone file in a disposable folder. Python 3.11 or later is required, with no packages or provider configuration.

Code example
python3 --version
python3 fde-canary-evidence-lab.py test
python3 fde-canary-evidence-lab.py baseline-ready
python3 fde-canary-evidence-lab.py aggregate-green-segment-red
python3 fde-canary-evidence-lab.py all-refusal
python3 fde-canary-evidence-lab.py missing-observation
python3 fde-canary-evidence-lab.py demo

Every output retains origin: synthetic-teaching-packet and release_authorized: false. A ready-for-human-review result only says this packet met this exercise's criteria. It neither grants production access nor recommends bypassing the accountable release decision.

PacketWhat to retainWhat the engineer should explain
baseline-readyFour cohort/segment counts and two p95 comparisonsUseful supplied outcomes met the authored criteria; no production release was authorized.
aggregate-green-segment-redCandidate errors 7/120 versus control 4/120; exception errors 6/20 versus 2/20The aggregate increase is 2.5 percentage points, but the exception increase is 20 points. The segment regression stops the recommendation.
all-refusalCandidate errors are zero and accepted work is zeroA system that refuses useful work cannot win by having no recorded execution errors.
missing-observationDeclared admission and observed row counts disagreeHold for evidence; do not silently drop the missing record or infer success.
missing-segment / small-sampleMissing or below-minimum segment coverageHold even if the included rows look healthy. The threshold is teaching policy, not statistical power.
mixed-windowDifferent candidate/control intervalsDo not compare a previous incident window with the new candidate's window as if they were concurrent.
latency-regressionThe exception segment's response-latency p95Error rate alone does not describe acceptable operation. These response durations exclude human review/correction effort.
safety-eventOne supplied critical event and the stop reasonDo not average away an explicit safety trigger or excuse it because the sample is small.
duplicate-observation / malformed-scalarA hold with an integrity reasonDuplicate data and a Boolean used as an integer are not ordinary healthy observations.

Accepted counts and response latency remain separate. A production field trial also needs the receiving operator's acceptance criteria, review/correction effort, queue delay, attempt costs and manual fallback. The two supplied segments do not establish representativeness for unmodeled tasks, tenants, loads or times of day. There is no randomization, causal inference, confidence interval, authenticated telemetry ingestion or actual rollout in this file.

Change one criterion and transfer the decision

Predict the aggregate-green/segment-red result before running it. Have a receiver compute both denominators from the JSON rather than reading only the status. In a disposable copy, add a third segment and show why both admission and observation contracts must change; do not let the unknown segment disappear from the comparison. Then add a new required observation field and preserve invalid/missing cases alongside the useful baseline.

Record your policy revision, synthetic packet, commands, actual output, hold/stop reasons and untested receiving-environment assumptions. Name the person who would authorize exposure in a real rollout. Keep the manual fallback and checkpoint-version recovery plan beside that decision. This evaluator is teaching evidence for a discussion, not a production promotion or rollback controller.

2h. Validate structured agent output before source review

Download the structured-output lab into a new disposable folder. Use Python 3.11 or later and the same pinned framework versions as the earlier tool-loop exercise. A separate environment keeps the receiving record reproducible:

Code example
python3 -m venv .venv-output
. .venv-output/bin/activate
python -m pip install "langchain==1.4.6" "langgraph==1.2.16"
python -m pip freeze > requirements.lock.txt
python fde-structured-output-lab.py test
python fde-structured-output-lab.py demo

On Windows use .venv-output\Scripts\activate instead. Package installation needs registry access. After installation the lab runs locally without provider inference; inherited remote tracing is disabled and tests refuse socket access. Eight checks passed with Python 3.12 and these framework versions on 19 October 2026. Retain your own output and resolved versions.

The LangChain structured-output guide describes ToolStrategy and the structured_response state field. This exercise uses that actual strategy with a strict Pydantic contract and a scripted model adapter. The adapter's schema-shaped tool call is an output proposal, not a business lookup or a granted action. No provider-native schema enforcement or model quality is measured by the scripted run.

The contract permits only a procedure ID, an integer version and a bounded quotation. A string or Boolean version and an extra approved field fail validation. Repair feedback returns a fixed instruction instead of echoing the raw validation payload. The repair adapter deliberately fixes its second proposal. That demonstrates the framework's retry path, not a measured repair rate for a language model. never-repair reaches the graph ceiling without a usable proposal; deadlines and token budgets remain separate obligations.

CaseObservation
validOne model call; ready for review; no review recorded.
repairTwo calls and one schema feedback event; typed output returned.
never-repairIncomplete at the graph ceiling; no proposal returned.
foreign-sourceShape passes; current host lookup withholds the source.
unsupported-quoteShape passes; quotation is absent from the current text.
stale-versionShape passes; the claimed version differs from the source.
withdrawn-sourceShape passes; the host's synthetic current source is inactive.

The comparison command exits 0 after printing all seven cases. To inspect an individual refusal, run python fde-structured-output-lab.py unsupported-quote; expect exit 2. Individual never-repair, foreign-source, stale-version and withdrawn-source also exit 2. valid and repair exit 0. Preserve that result rather than deleting the failing condition to make a transcript green.

A valid shape can still carry an unavailable ID, stale version or unsupported quotation. The host checks those separately against fixed north-tenant fixtures. It never takes identity or approval from model fields. Exact substring matching only establishes that the supplied quotation appears in this tiny source; it cannot establish contextual completeness, relevance, paraphrase entailment or factual truth. Even ready_for_review keeps review_recorded: false.

Receiving exercise · 25 minutes: predict the seven outcomes before running demo. Give a peer one schema feedback event and one schema-valid withheld proposal; ask them to identify which boundary rejected each. In a disposable copy change the quote value in ScriptedContractModel._generate while leaving SOURCE_TEXT unchanged: try a shorter exact excerpt, then an unsupported instruction. Retain the allowed and withheld outputs and explain why an exact excerpt could still omit important context. Name the separate semantic review, authenticated scope and execution budgets a real receiving service would need. Keep the supplied reference, actual transcript and remaining gaps together.

2i. Build a real MCP SDK client and server

35-minute core lab · Optional comparisons below · Node.js 24 · Three pinned packages · No provider key

The admission lab teaches host policy, and the earlier wire lab makes its 2025-11-25 handshake explicit. This lab uses the actual v2 SDK packages for both client and server. It discovers one tool, calls it through a real owned child process and compares successful work with schema, permission and output failures. All calls are authored and all sources are synthetic; no model makes a decision.

Download fde-mcp-sdk-lab.mjs from the library and put it in a new empty local folder. Run these commands inside that folder, not inside an application or an existing project. Installation needs package-registry access; the installed lab blocks fetch and socket connections while it exercises local stdio.

Code example
node --version
npm init -y
npm install --save-exact --ignore-scripts @modelcontextprotocol/server@2.3.1 @modelcontextprotocol/client@2.3.1 zod@4.6.7
npm ls --depth=0
node fde-mcp-sdk-lab.mjs test
node fde-mcp-sdk-lab.mjs demo

Retain package.json, package-lock.json, the twelve-test result and your actual comparison JSON. The single .mjs file starts its own server child with Node; you do not start that server separately. A missing SDK reports setup-required and exits 2. The demo keeps all seven observations and reports complete only when they match the expected contract; unexpected connection or validation failures yield incomplete comparison/exit 2. Expected refusals are retained, not dropped from the denominator.

Compare per-request metadata with a legacy handshake

Before running this optional ten-minute comparison, predict three things: which profile sends initialize, where each request carries a version, and whether successful connection setup establishes permission to read a source. Then run:

Code example
node fde-mcp-sdk-lab.mjs profiles > profiles.json

Open profiles.json. complete is true only when both real local SDK runs return the useful P1 version 3 result, preserve their expected boundary counts, close their child transports and match the observed profile structure. A missing or different sequence makes the comparison incomplete and exits 2.

sendEvidence.messages records a small structural summary when the client calls the transport's send method. The following is the sequence observed with the pinned SDK and this file, not a sequence to hand-code into every adapter:

RunOutbound methodVersion location and valueClient info and capabilities present
Modern, pinnedtools/listparams._meta: 2026-07-28Yes, on this request
Modern, pinnedtools/callparams._meta: 2026-07-28Yes, on this request
Explicit legacyinitializeparams.protocolVersion: 2025-11-25Yes, in setup
Explicit legacynotifications/initializedAbsentNo
Explicit legacytools/listAbsentNo
Explicit legacytools/callAbsentNo

In the modern requests, the selected metadata keys are io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientInfo and io.modelcontextprotocol/clientCapabilities. The report keeps the version and presence flags, not identity values or capability contents. Legacy setup uses protocolVersion, clientInfo and capabilities directly in params. A request has an ID; the initialized notification has none. This summary does not retain responses, so an ID alone is not evidence of a matching response.

There is no server/discover call in this pinned modern run. The client is configured with mode: { pin: '2026-07-28' } and skips the discovery probe; the server's factory reports modern. This does not show that discovery is unsupported or unnecessary for an unfamiliar server. The current architecture describes server/discover for learning server capabilities and compatible versions. Confirm the actual SDK configuration and peer behavior before choosing a profile. Do not insert a legacy handshake into the modern sequence to make it look like an older tutorial. See the existing architecture reference.

The observation point matters. This is a bounded record of client transport calls, not captured operating-system bytes, proof of server receipt or a full protocol validator. Arguments, results and arbitrary metadata are omitted from this summary; the separate synthetic result and server diagnostics show the useful lab operation. The record stops after sixteen messages and marks an overflow incomplete for this comparison. The version and client description are compatibility metadata, not authenticated identity or source authorization.

Compare each prediction with your actual file. Explain to a receiving colleague why the two modern requests repeat their metadata, why the legacy tool requests do not, and why both runs still need a current grant and scoped source lookup. Retain the package lock, observed eras, useful result, closed transport and any mismatch. If the command did not run, retain that fact instead of copying the expected table as your own evidence.

Separate server discovery, tool listing and source access

Use this optional ten-minute receiving exercise after profiles. A server can advertise tools and return their input contracts without granting a caller permission to read a particular source. Predict the handler and lookup counts for discovery alone, a permitted call and the same call with its read grant revoked. Then run the three real local SDK cases:

Code example
node fde-mcp-sdk-lab.mjs discovery > discovery.json

This command keeps the pinned modern client and explicitly calls await client.discover({ timeout: 2000 }) before listTools. It does not switch to automatic negotiation or test fallback to a legacy server. Look for the actual server/discover entry in sendEvidence.messages, followed by tools/list. Only the two calling cases add tools/call. Compare this with profiles, where the pinned client makes no explicit discovery call.

serverDiscovery retains selected fields from the SDK's returned object, not a literal response envelope. In this fixture all three runs report version 2026-07-28, tools present, resources/prompts absent, server-info metadata present, ttlMs: 0 and cacheScope: private. Identity values and arbitrary metadata are omitted. The cache fields describe this discovery result; they neither grant source access nor establish whether business content may be shared. Use the existing architecture reference for the discovery concept and the pinned installed SDK for the API actually run.

The count pair means handler entries / procedure lookups.

CaseLast method sentHandler / lookupSource result
discovery-onlytools/list0 / 0No procedure requested or returned
discovery-supportedtools/call1 / 1P1, version 3
discovery-revokedtools/call1 / 0Tool error: access-denied

The tool contract stays in the existing discovered field, separate from serverDiscovery. Both are the same across these runs; a different server may filter what it advertises according to its own policy. In the last case, input validation succeeds and the handler refuses the current read grant before a source lookup. This is not failed discovery or a bad argument. The revoked case starts its synthetic host with canRead: false; it does not measure a permission change during a running session. Keep the useful permitted result beside the refusal rather than discarding it. The comparison is complete only when all three cases, their actual outbound sequences, selected discovery fields and closed transports match. Missing work or a truncated send record yields incomplete comparison and exit 2.

For a pair exercise, the builder retains the exact lab edition, package lock, command and actual JSON. The receiver first writes their own predictions, then locates a discovery field, the tool contract and the result or refusal in that file. Each person keeps their contribution, any hint and one revised explanation. A solo learner labels the receiving step self-review. The SDK/application owner investigates compatibility; an authorized source/access owner resolves a real read refusal. Do not change a grant merely to make the comparison pass. This fixed local teaching grant is not a deployed identity or authorization system.

Compare tools, resources and prompts

Start with the visual MCP introduction and its Try it exercise. Use the three catalog entries to predict what comes back before opening the Receive step. Then run:

Code example
node fde-mcp-sdk-lab.mjs capabilities

This separate comparison adds a resource and prompt to the same local server. The original seven-case demo stays available for tool-boundary work. The new command uses real SDK listing, resource reading and prompt retrieval before calling the procedure tool. It exits 0 only when the observed contents, callback sequence and refusals match; a missing operation is not recorded as success.

Capability in this fictional catalogRequestWhat you receive
lookup_procedure tooltools/call with procedure_id: P1P1 version 3 from the scoped lookup
review-checklist resourceresources/read with training://guides/review-checklistPublic synthetic checklist text
review_procedure promptprompts/get with procedure_id: P1A user-role message asking for a review of P1

An MCP resource URI identifies content; this training:// URI is not a public website or a path the lab fetches. The resource's content is a fixed public teaching fixture, not a private procedure. Its handler reads no external file. Real resources with restricted data need current authorization too.

The prompt handler substitutes P1 into an instruction. Inspect messages, then explain why that is not an AI-written review. It does not call the procedure tool or a model. The host would need to select evidence, construct model input, invoke inference and check the output separately. A tool could wrap inference in a different design; none of this catalog's handlers does so.

Inspect capabilityHandlers: resource-read, prompt-get, handler, lookup. Only the final tool call enters the procedure handler and performs the scoped lookup. The comparison also requests a missing prompt argument and an unknown resource URI. The installed SDK rejects both before a corresponding handler runs. Keep the actual error type and code with your result; do not infer them from an older protocol tutorial. transportClosed must be true after the comparison.

For a fifteen-minute extension, change the prompt's requested procedure to P2 in a disposable copy and predict which output changes. The instruction should name P2 while the separately requested P1 tool result stays P1. Update the comparison expectation for your intentional change, preserve both refusals and explain the remaining model-call step. Never make a failed original comparison look green by discarding its checks. Save the diff and actual output beside your prediction.

The browser comparison uses selected catalog/result fields for readability; it is not a wire capture. SDK output includes protocol metadata, and the SDK owns modern 2026-07-28 negotiation. See the primary server-feature overview, resource specification and prompt-message reference. The prompt reference is the older profile; use it for the template concept, not as a handshake recipe. All three examples and the experiment are original.

Inspect the procedure tool boundary

The server registers a strict Zod input and output schema. Only procedure_id is an argument; tenant north and the current read grant belong to its process host. SDK validation precedes the handler. A well-shaped request still needs that host check and a scoped source lookup. An annotation describes a tool; it cannot grant permission. See the SDK tool guide for registration and validation APIs.

CaseClient eraHandler entriesBusiness lookupsObserved result
supportedmodern11Received P1 v3 and structured data
legacylegacy11Same useful P1 result through the older profile
forged-scopemodern00SDK tool error; extra tenant field rejected
foreign-recordmodern11Tool error; no foreign source content
revoked-grantmodern10Tool error; current host grant denied
unknown-toolmodern00ProtocolError -32602; no sender registered
invalid-resultmodern11SDK tool error; malformed version withheld

Counters come from fixed synthetic stderr events in the session child. The SDK owns stdout as its protocol channel. The modern client pins revision 2026-07-28; the explicit legacy case uses the SDK's legacy handshake. Inspect clientEra and serverFactoryEras rather than inferring a protocol from package version. Modern stdio negotiation can use an additional disposable probe sibling; its diagnostics are not these session counters. The observed older and newer results do not imply identical wire encoding. The SDK protocol-version guide explains the era and serving-entry choices.

Run cases separately to isolate the enforcing boundary. Negative cases intentionally exit 2; supported and legacy exit 0:

Code example
node fde-mcp-sdk-lab.mjs supported
node fde-mcp-sdk-lab.mjs legacy
node fde-mcp-sdk-lab.mjs forged-scope
node fde-mcp-sdk-lab.mjs foreign-record
node fde-mcp-sdk-lab.mjs revoked-grant
node fde-mcp-sdk-lab.mjs unknown-tool
node fde-mcp-sdk-lab.mjs invalid-result

Open the file and trace serveStdio → registerTool → host grant → scoped lookup → SDK output validation. Then find Client → StdioClientTransport → listTools → callTool → finally/close. transportClosed records the SDK releasing its owned session transport; it is not remote-effect cancellation. The closed tool set has no sending function. Returned source data stays untrusted, and a successful exchange is neither a model-quality result nor a human review.

Receiving task. In a disposable copy, add a strict bounded locale argument to both the input schema and the supported client proposal. Preserve all original cases and add a missing-locale case. Predict handler/lookup counts before running it; have a peer explain why accepting a locale must not permit tenant or approved arguments. Keep the original output, changed copy and fresh observation. Ask them to locate the current-grant check without your taking over the keyboard. If a schema change merely strips an unwanted field, test that behavior explicitly; this lab requires strict rejection. Never repair a refusal by disabling validation.

The host scope and grant are synthetic configuration, not login or OAuth. Reviewable tool-definition binding remains in the separate admission lab. HTTP authorization, remote server trust, notification/subscription handling, distributed budgets, real model behavior and production deployment remain receiving experiments. Use the SDK client guide for the client lifecycle, retaining the actual installed versions beside your work.

2j. Size a private inference deployment before admitting work

Private inference / Memory budget explorer

The prompt fits. Does the workload?

Change a synthetic workload and inspect its declared memory budget. This browser calculation runs no model, measures no GPU and saves no learner work.

Prompt fixed at 4,096 tokens per request. One declared device. Dense grouped-query attention only.

Cache budget exceeded49,152 / 32,768 token slots

2 GiB beyond the declared cache budget. 12,288 reserved tokens × 4 requests.

One synthetic device12 GiB
Weights 6 GiBRuntime reserve 2 GiBAvailable KV cache 4 GiB
Requested KV reservation6 GiB / 4 GiB

Bar stops at the budget; the excess stays visible in the numbers above.

Prompt-only accounting

16,384 token slots

Would appear to fit when generated output is omitted.

Prompt + allowed output

49,152 token slots

Does not fit this declared budget. A context limit is a separate per-request check.

Reconstruct the byte ledger
Key/value geometry
2 × 32 layers × 8 KV heads × 128 dimensions × 2 bytes = 131,072 bytes/token
Available cache
4,294,967,296 bytes after weights and runtime reserve
Allocation rule
Round each request up, and capacity down, to 16-token blocks.
Per-request context
12,288 / 16,384 logical tokens before allocation padding
Download the reproducible Python lab python3 fde-private-inference-lab.py demo

Synthetic profile · Estimates, not measured capacity. Actual engine allocations, hardware support, quality, isolation and operator recovery need separate evidence. Changing this explorer does not admit work or record completion.

35-minute planning lab · Python 3.11+ · Standard library · No GPU or model download

On the hosted guide, start with The prompt fits. Does the workload? Change maximum output from 8,192 to 1,024 tokens while keeping four requests. The estimate moves from 49,152 slots (over budget) to 20,480 (within budget). Then choose four requests and 4,096 output tokens: exactly 32,768 slots, with no declared cache headroom left. The colored blocks separate weights, runtime reserve and cache; the ledger exposes the same arithmetic as the Python lab. These browser controls calculate estimates only. They do not execute inference, save progress or prove that a real runtime fits. The protected lesson has the same explorer in 02 Example. Retain the Python output for reproducibility.

Download fde-private-inference-lab.py into a disposable folder. This is an executable capacity estimate with synthetic model geometry and pre-counted token lengths, not an inference server, hardware benchmark or completed on-prem deployment. It makes no network request, starts no service and writes no files.

Code example
python3 --version
python3 fde-private-inference-lab.py test
python3 fde-private-inference-lab.py demo
python3 fde-private-inference-lab.py output-pressure
python3 fde-private-inference-lab.py output-pressure --candidate prompt-only

The nine tests verify the calculation and refusal boundaries. The seven-case reference comparison reports comparison_complete: true and exits 0. An individual non-fitting or unsupported case exits 2. The broken prompt-only candidate also exits 2 for output-pressure even though it prints fits_estimate: its result disagrees with the retained expected decision. Keep the JSON instead of treating that status as a production admission.

Work the memory ledger. Start with a single synthetic 12 GiB device. Subtract 6 GiB of resident weights and a declared 2 GiB runtime reserve. The remaining 4 GiB is the toy cache budget. These are supplied inputs, not measurements or a recommendation for any card or model. A GiB here is exactly 1,073,741,824 bytes. The declared reserve stands in for unmeasured allocations; it does not establish that kernels, activations, graph capture or fragmentation actually fit.

For this dense, full-attention grouped-query model only, calculate:

Text example
KV bytes per token = 2 × layers × KV heads × head dimension × bytes per element
                   = 2 × 32 × 8 × 128 × 2 = 131,072 bytes
Token slots        = floor(cache budget / bytes per cache block) × block tokens
                   = floor(4 GiB / (131,072 × 16)) × 16 = 32,768
Request reservation = ceil((prompt tokens + maximum output tokens) / 16) × 16

The factor two retains both keys and values. Use the eight KV heads, not the 64 query heads. Round each request up to whole blocks and the available cache down to whole blocks; then sum the reservations. Logical context length is prompt plus requested maximum output before allocation padding. This toy pre-reserves worst-case generation rather than predicting what a scheduler will actually hold at a particular instant.

CaseReservationObservation
baseline4 × 5,120 = 20,480 tokensFits the 32,768-slot estimate.
output-pressure4 × 12,288 = 49,152Exceeds memory despite each request fitting its context limit.
context-overflow17,408 logical tokensExceeds the 16,384-token context contract.
block-rounding4 × 5,136 = 20,544Four one-token increases consume four new blocks.
weights-only-quantization7 × 5,120 = 35,840Fits after the assumed weights shrink; KV bytes/token stay 131,072.
half-width-cacheSame seven requestsKV bytes/token halve separately; accuracy and runtime support remain untested.
multiple-devicesNo pooled estimateUnsupported topology: two devices are not automatically one memory pool.

Explain the repair. Compare baseline with output-pressure. The broken candidate counts only 16,384 prompt tokens and wrongly says the changed workload fits. Reducing context, reducing allowed output, limiting simultaneous requests or changing hardware/model are different proposals; each changes the service contract or its evidence requirements. Do not silently truncate a request to make an estimate green. Weight quantization and cache precision are separate inputs; shrinking the weights does not itself shrink each cached key/value element.

The TensorRT KV cache reference describes cache tensor dimensions and application-owned allocation. The vLLM serving reference documents context length, cache dtype, cache memory and executor memory controls. These references inform the engineering questions; this script calls neither runtime. Do not apply its geometry unchanged to latent attention, sliding-window or hybrid architectures, multimodal inputs, prefix sharing, speculative decoding, cache scales/metadata, CPU offload or distributed sharding.

Receiving task. Predict all seven rows first. In a disposable copy change one baseline prompt from 4,096 to 4,097 tokens; retain the one-block increase separately from a maximum-output change. Give a peer the original, changed and broken-candidate outputs. Ask them to find the missing output reservation without your narration and identify the assumptions that a receiving deployment must measure. Keep the script revision, Python version, byte ledger, per-request rounded tokens and the peer's explanation. A good follow-up records the actual model and tokenizer revision, license, supported architecture, runtime configuration, observed post-load cache capacity, load/latency evidence, access controls, egress policy, retention, revocation and operator recovery. A local/private endpoint alone proves none of those boundaries. This exercise does not grant a model credential or activate private inference on the training platform.

3. Make a meaningful change

Choose one extension. Keep a working baseline and record your changed source:

  • Add a source withdrawal test before the model context boundary.
  • Add an authenticated reviewer adapter over the domain method. Test revocation between pause and resume; do not trust a browser-supplied tenant or role.
  • Add a bounded LangChain model adapter with a single read-only tool. Keep the model configuration outside the prompt. Record any unrun provider steps.
  • Propose a durable LangGraph checkpointer, then test crash/resume and replay in that implementation. Do not relabel the in-memory run as durable.
  • Add a simulated unknown external-effect outcome and a reconciliation record. Never add a real sending integration just to make the walkthrough impressive.

4. Hand it over

For a structured receiving conversation, use the free agent-system receiving defense. Bring one useful run, one boundary failure and a changed-condition decision; the receiver should be able to continue one available task from your packet.

Submit the contract, state diagram, source revision, environment versions, observed commands/output, one failing case and its repair, known limits and the operator recovery note. Ask a peer to reproduce an authorized request and diagnose a source-change refusal without you driving. Keep scripted outcomes, observed local results and unrun deployment work clearly separated.

Further reading: https://docs.langchain.com/oss/python/langchain/agents and https://docs.langchain.com/oss/python/langgraph/overview. These are technical references, not a partnership or a credential.

A first reliability evidence review

New to evaluating an engineering claim? Start with this separate forty-five-minute route before the larger evaluation/tracing workshop. Download the reliability evidence and receiving worksheet and the existing evaluation companion plus durable workflow companion into the same disposable folder. Python 3.11+ and its standard library are sufficient; these synthetic local SQLite checks require no model, account, package or network. The worksheet is an editable Markdown file, not an account or assessed submission.

Predict useful and forbidden behavior before running the candidates. Then keep the complete seven-case contract, actual observations and separate utility, boundary and recovery slices. Compare a demonstrated content failure with a missing observation: six passes plus a failure and six passes plus an unrun row are different evidence packets. Both remain blocked under the declared contract. The changed requirement asks for reviewer revocation and actual model output; source withdrawal and deterministic drafts cannot supply those observations. Each receiving person keeps their own run, reasoning and assistance.

The context and reliability foundation lesson adds explanation, checks and teach-back prompts behind the existing training access. This route interprets a bounded local contract; it does not establish production reliability, human learning, client placement or qualification.

Before you move on

Keep the evidence of your work.

  • Actual local commands, package versions and observed results.
  • A comparison retaining useful work, boundary failures and unrun cases.
  • One requirement-driven extension and an operator handover note.

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

Suggested next free session

Model 101: from learned patterns to generated text

Separate the model’s learned parameters from its current input before inspecting tokens and serving capacity. 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 ↑