Lab 26: the rules still hold
- Approved by
- Panaversity ·
You build the check that Dave Kowalski's month-end review needed, and watch it fail on Friday's run. You give the rule and the state of the work a home outside the window. Then you cut, one cut at a time, and run the same check after each. The lab takes 2 sittings, and a free plan can spread them over days.
| Sitting | Do it after | Tasks |
|---|---|---|
| Sitting 1 | 26.1 to 26.6 | Setup, Tasks 1 to 3 |
| Sitting 2 | 26.7 and 26.8 | Tasks 4 to 6 |
Before you start
Important
The lab's files are not published yet. The download link for brightline-lab-ch26.zip and the answer keys below will work once they are. Until then, read the tasks with the chapter.
The download. Everything starts from brightline-lab-ch26.zip (download it here). It holds the brightline-ap repository at its tag ch25, with this lab's files added, so you need not have done Lab 25.
What you need. Node, Python with uv, git, the GitHub CLI, and Claude Code, Codex and OpenCode, each signed in. Your staging key for the Claude API goes in .secrets/anthropic.env. No key passes through a chat.
The job. It is Monday, May 3, 2027, 8:40 a.m. On Friday, April 30, at 4:10 p.m., Dave Kowalski asked for the review in these words, "Tell me which open invoices are a problem, and why, with the policy line for each." You started one session with it, on a $1.00 budget, with a summary set at a token threshold, and left. No check by code has tested the review on every invoice, because the portal's check by code runs on the weekday triage only.
How a task works. Start a fresh session with the named coding agent in brightline-ap/, and give it the task's prompt in plan mode. Write your prediction before the agent shows the result. Check the evidence against What good looks like, then download the answer key. End with a line in ports/ch26.md.
Set up (Claude Code). Unzip the folder, then give the agent this prompt.
Read
README.mdandAGENTS.md. Put this folder under git with a main branch, in one first commit, "Start from the end of Chapter 25", and tag itlab26-start. Install the packages for both languages, asREADME.mdsays. Run every test that needs no key. Then replay Friday's recorded run fromtraces/month-end-drift.jsonl, with no key and no network. Show me the request word for word, the number of turns, the number of open invoices, the run's cost, and the review's first and last entries. Finish by showing me that git tracks nothing in.secrets/.
What good looks like: one commit at the tag lab26-start, and every test green. The replay shows Dave's sentence, about 60 turns, and a cost under the $1.00 budget. Every entry of the review has a reason. docs/chapter-26/ holds the concepts as text for your agents.
Note
No run is recorded yet. Friday's run, traces/month-end-drift.jsonl, is not in the kit, so its replay stops and says there is no recorded run. The setup's replay, Task 1's steps 1, 2 and 5 and Task 2's steps 1 to 5 wait for it. Two files in the kit are scripted, and each says so in its first lines: the hosted session's events and a response whose summary is empty, both read in Task 4. Every other step can be done now.
Replay and live runs. npm run replay reads a run back from its trace, with no key and no network. A live run is one session, npm run month-end, with npm run connector:month-end running in another terminal. That connector serves data-month-end/, Brightline's data on Friday, April 30. The session's limits, its model and its trigger are in sessions/month-end.config.json. Fill in its prices from the pricing page first. A live run prints its budget and sends nothing until you add --yes. Your agent runs these commands, and you approve each live run.
Sitting 1: the check, the cause, the first cut
Before you start, answer in a line each: What are the two causes of drift (26.1)? Which of the three kinds can be fetched again (26.3)? After this sitting, you can: write a check by code for a rule that must hold on every item, read from a trace what filled the window and what a cut removed, and give a rule and the state of the work a home outside the window.
New words in this sitting's prompts.
| Word in a prompt | What it means |
|---|---|
| Replay | Read a run from its recorded trace, with no request to the model |
| Scripted session | The file sessions/month-end.md: the same request and the same steps each time, so two live runs can be compared |
| Tokens by part | The window's tokens, split into the instructions, the tool definitions, the request, the tool results and the worker's own turns (26.2) |
| Trigger | The number of input tokens at which the API clears or summarizes |
| Scripted file | A file written by a script, or by hand in the shape a vendor documents, and not recorded from a run. Its first lines say so |
| Owned file | A file only you may change. The agent proposes a change and waits. The worker's instructions, in prompts/ap-worker.v<N>.md, and AGENTS.md are owned files |
| Your own copy | The array of the whole conversation that your loop keeps (21.5) |
Task 1. The end check, built first (Claude Code)
Goal: a check by code that tests Dave's rule on every invoice of a review, with tests of its own, and its verdict on Friday's run.
Where: src/hosted/check-triage.ts, the check the weekday triage already has. Nothing in this task sends a request. Steps 1, 2 and 5 read Friday's run, which is not recorded yet. Steps 3, 4 and 6 need no run.
Predict: the worker's instructions already ask for a policy citation, and the portal has a check for one. If you run that check on Friday's review, does the review pass?
In plain words. You cannot say whether a rule held until something tests it. So the check comes before the diagnosis and before every fix. You use it at the end of each task that follows.
Read 26.1 in
docs/chapter-26/.
- Replay Friday's run from
traces/month-end-drift.jsonl. Show me the request, and the review as a table: one row for each open invoice, with the worker's decision, its reason and its policy line, in the order the worker decided them.- Quote the sentence in the newest version of the worker's instructions,
prompts/ap-worker.v2.md, that asks for a citation. Run the portal's citation check,citesPolicyLine(), on the review. Stop there and wait for my prediction. Then show me its result.- Extend
src/hosted/check-triage.tsso that it can check a review as well as a morning report. It stays plain code with no model call. Given a run's events, it fails a review if any invoice thatlist_open_invoicesreturned has no entry, if any invoice the review calls a problem has no policy line written(file.md:N), or if any policy line was not returned bysearch_policyin that run. It returns the failures in plain words, one line for each invoice. Add a script,check:review, that runs it on any trace.- Write tests for it from three fixtures in
tests/fixtures/review/, which you make from the lab's data: one review that passes, one with a problem invoice that has no line, and one with a line thatsearch_policynever returned.- Run the check on Friday's run. Show me each invoice in the order it was decided, with pass or fail, and the turn at which the worker decided it.
- Add a line to
ports/ch26.md: my prediction, what the old check said, and what the new check said.
What good looks like: citesPolicyLine() passes Friday's review. It asks whether a citation is there, and the first invoices carry one. The new check fails the review. Its three tests pass. In the table of step 5, every failure comes late in the run, after one turn, and no invoice decided before that turn fails. Your prediction: it passed. One citation anywhere in an answer satisfies the instructions' sentence, and "for each" was Dave's.
Checkpoint: the check fails on Friday's run, and its three fixture tests pass.
Saves: the review check in src/hosted/check-triage.ts, its three fixtures and tests, and your first line in ports/ch26.md.
Check it now. Download Task 1's answer key.
Task 2. Which kind had no home (Claude Code)
Goal: the cause of the drift, read from the trace and named. Then the rule in the worker's instructions, the state of the work in a progress file, and the check passing on a live run.
Where: the trace first. Then the worker's instructions, and your own loop in src/loop/, on the model the kit pins. Steps 1 to 5 read Friday's run, which is not recorded yet. Steps 6 to 8 need no run.
Predict: two sentences asked for policy lines on Friday. One is in the worker's instructions, and one is Dave's request. At the last invoice, which of the two was the model still reading?
In plain words. You read the trace for two things: what filled the window, and what was taken out of it. Then you sort what the window held into the three kinds, and ask of each one where else it lives. Nothing is cut in this task.
Read 26.2 and 26.6.
- From the recorded trace, show me tokens by part at four moments: the first turn, a turn midway, the last turn before anything was removed, and the turn after that. Add up all three input fields of
usagefor each. Name the part that grew most, and the tool whose results fill it.- List every event in the trace where something was removed from what the model sees: its turn, what kind of event it is, and the tokens before and after. Beside that list, put the turn of the first invoice the check fails.
- Show me the summary's text, whole. Quote the sentence where it states the task. Stop there and wait for my prediction.
- Make a table of what the window held on the turn before the summary. Give one row to each rule the run had to follow, including the rule against paying and each part of Dave's sentence. Give one row to the decisions made so far, and one to each tool's results. For each row, ask me which kind it is: a rule, the state of the work, or evidence. Then fill in a last column yourself: where else it existed on that turn. The choices are the worker's instructions, the connector, or nowhere.
- Name the failure with one of the names in 24.7, and say which of 26.1's two causes this run shows.
- The worker's instructions are an owned file. Propose one sentence for them: every invoice that a review calls a problem carries its own policy line. Show me the diff and wait. Save the result as a new file with the next version in its name,
prompts/ap-worker.v3.md, and leave the old file as it is. Then buildagents/ap-worker.mdfrom it, asAGENTS.mdsays.- Add the memory tool to my own loop, in
src/loop/memory.ts. My handler maps/memoriesto one folder for one person and one company, underdata/memory/. For this review that is Dave's folder at Brightline,data/memory/org_brightline/dave/. It refuses any path outside it. Write two tests: a path that climbs out of the folder is refused, and one person's run never reads another person's folder.- Add to the worker's instructions, as a second diff for my approval, saved as the version after that: before the first invoice, write the request word for word at the top of
/memories/month-end-progress.md. After each decision, add one line: the invoice, the decision, its policy line if it is a problem, and the values you decided on, such as the vendor's terms or the purchase order's amount.- Run
sessions/month-end.mdlive on my own loop, with the summary's trigger as it was on Friday. Tell me the budget and how many requests you expect before you send them. Then run the check, and show me the progress file.- Show me tokens by part and the run's cost, beside Friday's. Add both to
ports/ch26.md, with my prediction.
What good looks like: tool results are the part that grew. The trace holds one removal, a summary, and the first failing invoice comes straight after it. The summary states the task and leaves out "with the policy line for each". In your table, the rule against paying lived in the instructions, and the worker kept it to the end. "For each" and the decisions lived nowhere else. The tool results lived in the connector. The name is context loss, and the cause is removal. On the live run a summary still arrives, and the check passes on every invoice. The progress file opens with Dave's sentence and has one line for each invoice, with a policy line on each problem. The tokens are not lower than Friday's, because nothing has been cut yet. Your prediction: the instructions' sentence. Dave's was in the turns that the summary replaced.
Checkpoint: the check passes on a live run, with no cut made.
Saves: the next version of the worker's instructions, src/loop/memory.ts with its two tests, the progress file from the run, and the table of step 4 in ports/ch26.md.
Check it now. Download Task 2's answer key.
Task 3. Cut the evidence, at the tool and in the API (Claude Code)
Goal: find_vendor gives the review only what the review uses, and the API clears old tool results from what the model sees. The check passes after each cut, and you have read what each one saved.
Where: the find_vendor tool of the practice connector, py/brightline_ap/practice_connector.py, and its definition in tools/ap-tools.json. Then the request your loop sends.
Predict: the API clears an old tool result. Straight after, you print your own copy of the conversation. Is that result still in it?
In plain words. Evidence is the kind that can be fetched again, so it is the kind you may cut. You make it smaller as it arrives. Then you let the API drop the old results. You never delete from your own copy by hand. After the cut at the tool the session is much shorter, so the clearing needs a trigger of its own, below the session's new size.
Read 26.3.
- Show me one
find_vendorresult from Friday's trace, with its tokens. Mark each field the review used in a decision.- Other work still needs every field, so today's result stays the default (17.2). Propose the smallest change that lets a caller ask for only the fields it needs, with today's result as the default. Show me the diff, with a test that a caller who asks for nothing special gets what it got before. Wait for my approval.
- Run
sessions/month-end.mdlive. Run the check. Show me tokens by part and the cost, beside Task 2's run.- Now turn on the clearing of old tool results in the request my loop sends, with the setting's name and its beta header as 26.8 gives them. Keep the last 3 tool uses. Leave the memory tool's results out of the clearing. Propose a trigger low enough to clear at least once in this run, and a minimum number of tokens to clear each time, and tell me what each clearing does to the cached part of the request. Wait for my approval. Change nothing in my own copy of the conversation.
- Send one request that carries both the clearing and the summary by threshold. Show me the status code. If the API refuses it, show me the error's text and stop.
- Run the session again. For each clearing, show me the turn, the tool uses and the tokens cleared, as the response reports them. Stop there and wait for my prediction. Then show me the length of my own copy before and after the first clearing, and the text the model saw in place of a cleared result.
- Run the check. Then pick one invoice whose
find_vendorresult was cleared, and show me its line in the progress file.- Show me tokens by part, the cache read tokens and the cost for three runs side by side: Task 2's, after the cut at the tool, and after clearing. Add the table to
ports/ch26.md.
What good looks like: the review used the vendor's terms, and not the bank digits or the AP team's note. After the cut at the tool, the tool results part is smaller on every turn, and the check passes. With clearing on, each cleared result is replaced by placeholder text that tells the model it was removed.1 Your own copy has the same length before and after. The check still passes. One request carries both the clearing and the summary by threshold.2 The cleared invoice's line in the progress file still holds the value the decision was made on. The cache read tokens fall on the request after each clearing, because a clearing invalidates the cached part of the request.1 No summary arrives after the cut at the tool. By the kit's estimate the whole session is now about 14,000 input tokens, and a summary by threshold takes no trigger below 50,000.3 Task 4 deals with that. Your prediction: yes. The API clears what the model sees, and "Your client application maintains the full, unmodified conversation history."1
Checkpoint: two cuts are made, the check passed after each, and your table shows what each one saved.
Saves: the change to find_vendor and its test, the clearing setting in the loop's configuration, and the three-run table in ports/ch26.md.
Check it now. Download Task 3's answer key.
Checkpoint 1: a home first, then a cut. Before Sitting 2, check that you can do these without looking back.
- Say why the old citation check passed Friday's review, and what the new check tests that it did not.
- Name the three kinds, and say where each one lived on the turn before the summary.
- Say what the API cleared, what it left in your own copy, and what the clearing cost you.
Sitting 2: the summary, the subagent and the port
Before you start, answer in a line each: What must a summary's instructions say (26.4)? What does a subagent receive from its parent (26.5)? After this sitting, you can: write a summary's instructions and read what the summary kept, move side work to a subagent whose own prompt carries the rules it needs, and test on another harness whether a rule in its instruction file holds after a compaction.
New words in this sitting's prompts.
| Word in a prompt | What it means |
|---|---|
| Summary block | The block the API returns in place of the older turns. It goes back in later requests exactly as it came (26.4) |
| By threshold, on demand | The API summarizes when the input reaches your trigger, or your code asks for a summary in a request of its own |
| Fixture | A saved response that a test feeds to the code, so the test needs no key |
| Parent | The worker that starts a subagent |
| Instruction file | The file a harness loads into its requests: CLAUDE.md in Claude Code, AGENTS.md in Codex and OpenCode45 |
Task 4. The summary: what it kept, and what reads the file again (Claude Code)
Goal: the summary has instructions that you wrote, you have compared its text with the progress file, and you know what brings the progress file back into the window afterward. One summary on demand works in a request of its own, and a summary that does not arrive is handled.
Where: your own loop in src/loop/, and one look at a hosted session's events. Step 1 reads Task 2's live run. This task's own live runs turn off Task 3's cut at the tool and its clearing.
Predict: the API writes a summary during one of your requests. Do that response's top-level input_tokens and output_tokens include what the summary cost?
In plain words. A summary is a shorter copy, written by the model, of whatever it is given. Since Task 2, nothing that matters lives only in the turns it replaces. Here you tell it what to keep, read what it kept, and find out who opens the progress file again. A summary by threshold needs a trigger of at least 50,000 input tokens, and after Task 3's cut the session never gets there. So in this task find_vendor sends every field again, the vendors' long notes fill the window as they did on Friday, and the summary is the one cut you test.
Read 26.4.
- Show me the summary from Task 2's run beside the progress file from the same run. For each line of the progress file, say whether the summary holds it, holds it changed, or does not hold it.
- Write the summary's instructions in
prompts/month-end-summary.v1.md. They replace the default prompt whole, so ask me first what the summary must retain, one item at a time, and write only what I answer. End them by telling the model not to call tools.- Make a copy of the session's configuration for this task, with the clearing left out, and have my loop send each
find_vendorcall with nofields, so it returns every field as on Friday. Keep the trigger at 50,000. Runsessions/month-end.mdlive with these instructions and this copy. Show me the new summary. Stop there and wait for my prediction. Then show me the usage of the request in which the summary was written, with every entry ofusage.iterations, and what the summary cost.- Find out what reads the progress file again after a summary. With step 3's copy of the configuration, start two runs from the same turn before the summary. In the first, the worker's instructions tell it to view the progress file after any summary. In the second, they do not, and my loop adds the file's text to the next user turn when a summary block arrives. For each, show me the first three turns after the summary, and whether the file's text was in the window.
- Ask for one summary on demand, in a request of its own that carries no clearing. Read
stop_reasonbefore you look for the block. Then replace the summarized messages in my own copy with the block, exactly as it came, and change nothing else. Write two tests that fail if a later request leaves the block out, or keeps the summarized messages after it.- Write a test from the fixture
tests/fixtures/compaction/empty-summary.json, a scripted response whose summary block has no content. My loop records that the summary did not arrive, keeps my own copy as it was, and carries on.- The hosted worker is summarized by its platform. From the hosted session's events in
traces/hosted-month-end-events.jsonl, which are scripted and say so in their first line, list the event types, and show me any event that marks a compaction.- Run the check on step 3's run. Add tokens by part, the cost with the summary's own cost shown apart, and the answer to step 4 to
ports/ch26.md.
What good looks like: your instructions name what to retain and end by forbidding tool calls, because a summary can fail to arrive when the model calls a tool instead.3 The new summary holds each item you named. Its cost appears under usage.iterations, and you added it to the run's total. Your notes say which of step 4's two runs had the file's text in the window after the summary, and you kept that one. The memory tool's page promises a look at the memory folder only "before starting a task".6 The summary on demand came back in a request with no clearing, since one request cannot carry both.7 In the hosted session's events, a compaction is an event of the type agent.thread_context_compacted.8 Both swap tests pass, and so does the test for the missing summary. The check passes. Your prediction: no. The summary is an extra step that is billed, and the top-level counts leave it out.3
Checkpoint: the check passes with your summary instructions, and ports/ch26.md says what reads the progress file again.
Saves: prompts/month-end-summary.v1.md, the swap in src/loop/ with its three tests, and the summary's cost in ports/ch26.md.
Check it now. Download Task 4's answer key.
Task 5. The lookups in a subagent (Claude Code)
Goal: the vendor lookups run in a subagent's own window, and one short line comes back for each. The subagent's own prompt carries every rule it needs. The check passes, and you have compared what the whole run cost.
Where: the worker built on the Claude Agent SDK, in src/sdk/. Tasks 2 to 4 ran on your own loop. A subagent needs a harness, so this task changes runtime. It starts with a baseline run of its own, a first run to compare the others with.
Predict: the parent's system prompt holds all of Brightline's rules, and this worker loads no settings files. A subagent starts. Which of those rules is it reading on its first turn?
In plain words. Side work goes into a window of its own, and only its answer comes back to the parent. But that window starts without the parent's conversation. So you decide what the subagent must be told, and where that is written.
Read 26.5.
- Give this worker the newest version of the worker's instructions and the memory handler from
src/loop/memory.ts. Runsessions/month-end.mdlive on it with no subagent. Run the check. This run is this task's baseline.- Show me the line that sets
settingSourcesfor this worker, and say what a subagent started by it would receive, and what it would not.- Show me the worker's instructions as a numbered list of rules. Ask me, one rule at a time, whether a subagent that only looks up vendors needs it. Then define the subagent
vendor-lookup: its own prompt holds the rules I chose, its only tool isfind_vendor, and its answer is one line for each vendor with the vendor's id and its terms.- Write the parent's changed instructions in
prompts/ap-worker.subagent.md, as a diff for my approval, so that it asksvendor-lookupfor a vendor's terms and no longer callsfind_vendoritself. Leave the versions inprompts/ap-worker.v<N>.mdas they are, because my loop and the hosted worker are built from them. The parent still writes each decision to the progress file, with the terms the subagent returned.- Run
sessions/month-end.mdlive. Show me the subagent's first request, part by part. Stop there and wait for my prediction. Then mark what in that request came from the parent.- Run the check. Show me the parent's tokens by part beside the baseline run, then the number of requests the subagent sent, their tokens, and the cost of the whole run.
- Add one harmless rule as a new line in the
CLAUDE.mdat the project's root, turn on the loading of project settings for one run, and show me whether the subagent's first request carries that rule. Then turn the loading off again, remove that line, and say why this worker keeps it off (22.9).- Add to
ports/ch26.md: the rules I gave the subagent, the two costs, and my prediction.
What good looks like: the baseline run passes the check with no subagent. The subagent's first request holds its own prompt, its tool and the prompt string the parent passed. It holds none of the parent's conversation and none of the parent's system prompt.9 The parent's tool results part is smaller than in the baseline run, and the check passes. The whole run can cost more than the baseline's, because the subagent sends requests of its own.10 Your notes say whether the saving in the parent was worth that. In step 7, the rule in the project's CLAUDE.md reaches the subagent while the loading is on.9 Your prediction: none of them. A rule that the subagent needs must be in its own prompt.
Checkpoint: the check passes with the lookups in a subagent, and both costs are in your notes.
Saves: the instructions and the memory handler wired into the worker in src/sdk/, the vendor-lookup subagent there, the parent's instructions in prompts/ap-worker.subagent.md, and the cost comparison in ports/ch26.md.
Check it now. Download Task 5's answer key.
Task 6. The port (Codex, then OpenCode)
Goal: the drifting session replayed in Codex and compacted there, with the check's verdict for a rule typed into the chat and for the same rule in AGENTS.md. Then the same in OpenCode.
Where: a Codex session in brightline-ap/, then an OpenCode session. The kit has AGENTS.md beside CLAUDE.md. The tool results are in sessions/month-end-tool-results.jsonl. The practice connector's own code made them from data-month-end/, with no model call, so they are the connector's answers and not a model's.
Predict: you run the review twice in Codex. In one run "for each" is only in the request you type. In the other it is in AGENTS.md. You compact both halfway. For which run will the check pass?
In plain words. You run one experiment on two more harnesses. The only thing that differs between its two runs is where the rule lives. The check you built in Task 1 gives the verdict.
By hand. When the agent tells you it is halfway, compact the session yourself with the tool's own command (12.8). Then tell the agent to carry on.
Read 26.8. You are replaying
sessions/month-end.mdas the worker, from the tool results insessions/month-end-tool-results.jsonl, with no connector and no key.
- Run one. Take the request as Dave wrote it. Decide the first half of the open invoices, one at a time, reading each tool result as you go. Then stop, and tell me you are halfway.
- After I compact, decide the rest, and write the review to a file. Run the review check on it, and show me each invoice with pass or fail.
- Run two, in a fresh session.
AGENTS.mdis an owned file. Propose the sentence from Task 2 for it, show me the diff, and wait. Then repeat steps 1 and 2.- Add a table to
ports/ch26.md, with one row for each run: the harness and its version, today's date, where the rule lived, and how many invoices passed after the compaction.
Then give the same prompt to OpenCode, and add its two rows.
What good looks like: four rows, two for each harness, each with the check's count. For Claude Code, the documented behavior is that the CLAUDE.md at the project's root is put back from disk after a compaction.11 For OpenCode, the documented behavior is that "the current versions of your instruction files become the session's baseline" after a compaction.12 For Codex, the vendor's pages do not say, so your rows are the only evidence. On both, write what the check said, and do not correct a row to match what you expected. If a run with the rule in AGENTS.md fails the check, that is a finding. Record it with the harness's version.
Finish: the pull request and the tag.
Update
README.mdanddocs/deploy.mdwith the review check, the progress file, the cut at the tool, the clearing, the summary's instructions and the subagent. Run/code-reviewand/security-reviewon the branch, and fix or answer every finding. Open the pull request, wait for its checks, and show me both reviews. I will merge. Then tag the mergech26, push the tag, and from a clean clone of the tag run every test that needs no key.
Checkpoint: the tag ch26 passes from a clean clone, and ports/ch26.md has a row for every run of the port.
Saves: the changed AGENTS.md, the port's table in ports/ch26.md, and the tag ch26.
Check it now. Download Task 6's answer key.
Checkpoint 2: the rules still hold. Check that you can do these without looking back.
- Say what a summary's instructions must tell the model, and where you read what the summary cost.
- Say what a subagent receives from its parent, and where a rule it needs must be written.
- Say what your rows show for a rule typed into a chat, and for the same rule in an instruction file, after a compaction.
- Say which check gave the verdict in every task, and why it was built first.
Required and optional
Required: the setup and Tasks 1 to 6, with the Codex part of Task 6. Advanced: the OpenCode part of Task 6.
Apply it to your vertical (optional)
Pick one long job that your own business would give a worker, such as a month of claims or a week of orders. Write down one rule that must hold on the last item as on the first. Then list what the window would hold halfway through, and sort the list into rules, the state of the work, and evidence. For each line, write where else it lives. Mark every line whose answer is "nowhere".
If something goes wrong
| What you see | Why | What to do |
|---|---|---|
| The new check passes Friday's run | It tests for one citation, as the old check did | Test every invoice the review calls a problem (Task 1) |
| The live run in Task 2 is never summarized | The trigger is above what the run reaches | Use the trigger the kit's configuration gives for this session |
| No summary arrives in Task 3, or in Task 4's live run | The cut at the tool keeps the session near 14,000 tokens, and a summary by threshold needs at least 50,000 | Expected in Task 3. In Task 4, send find_vendor with every field and the clearing off (Task 4, step 3) |
| A 400 error on the request for a summary on demand | The request also carries the clearing setting | Ask for the summary in a request of its own (Task 4) |
| A summary block arrives with no content | The model called a tool instead of summarizing | End the summary's instructions by telling it not to call tools (Task 4) |
| The subagent's answers ignore one of Brightline's rules | The rule is only in the parent's system prompt | Write it into the subagent's own prompt (Task 5) |
| A live run differs from the recorded one | A model's wording changes from run to run | Compare the check's results, not the text. Record the difference in ports/ch26.md |
Artifact checklist
- The review check in
src/hosted/check-triage.ts, with its three fixture tests - The worker's instructions, with the "for each" sentence and the progress file's lines, each version reviewed
-
src/loop/memory.ts, with a folder for one person and one company, and its two tests - The change to
find_vendorand its test, and the clearing setting -
prompts/month-end-summary.v1.md, the swap for a summary on demand, and its three tests - The
vendor-lookupsubagent, with its own prompt, and the parent's instructions inprompts/ap-worker.subagent.md -
ports/ch26.md, with every prediction, tokens by part and the cost after each task, and the port's rows - The tag
ch26
Exam notes
Sources
- Context editing, Anthropic.↑↑2↑3
- Context engineering: memory, compaction, and tool clearing, Anthropic cookbook.↑
- Compaction at a token threshold, Anthropic.↑↑2↑3
- Custom instructions with AGENTS.md, OpenAI.↑
- Instructions, OpenCode docs.↑
- Memory tool, Anthropic.↑
- Compaction on demand, Anthropic.↑
- Managed Agents reference, event types, Anthropic.↑
- Subagents in the SDK, Claude Agent SDK, Anthropic.↑↑2
- Best practices for Claude Code, Anthropic.↑
- Explore the context window, Anthropic.↑
- Compaction, OpenCode docs.↑
- Owner
- Panaversity