CCAR-P · Claude Models, Prompting, and Context Engineering
Reasoning effort and context lifecycle, context editing, memory and compaction
A code-migration agent works six hours straight: it reads hundreds of files, runs tests and fixes things. By hour four it starts repeating commands it already tried and forgets that one module was excluded. The team proposes two fixes: raise the reasoning effort to “max” on every step, or move to a model with a larger window. Neither attacks the cause: the context filled with noise and the agent has no mechanism to keep what matters.
Effort: a reasoning budget per type of step
Effort regulates how much the model reasons: more effort improves hard steps in exchange for latency and tokens. In a long agent, steps are not all worth the same:
- Mechanical steps (listing files, reading a result, applying an already-decided change): low effort. Raising it spends time without improving anything.
- Decision steps (choosing the migration design, diagnosing a failure nobody understands): high effort, because an error is carried through the rest of the session.
- Sessions with a latency target (an interactive assistant): medium or low effort and reasoning only where evaluation justifies it; an overnight process has more room.
The rule is the same as in the rest of the domain: start with the cheapest option that meets the quality floor and raise it where evals show the gap. Putting everything at max is the “biggest model just in case” of effort.
What it takes to sustain a long session
Effort doesn’t fix the context. To keep performance steady across the session there are three mechanisms, chosen by what is being lost:
| Problem | Mechanism | How it works |
|---|---|---|
| The context fills with old tool results that are no longer needed (test outputs, files read hours ago) | Context editing | Clears the oldest results once a threshold is passed, and leaves the rest intact |
| Some information must survive the session or a new window (decisions, excluded modules, migration state) | Memory tool | The agent writes and reads notes in files that persist outside the window; that is what the next session loads |
| The whole conversation nears the limit and everything before it is still relevant | Compaction | Summarizes the history into a shorter version and continues from there |
Notice the cost of each. Context editing removes without summarizing, so it costs no extra call and loses nothing of what is kept, but what was cleared doesn’t come back. Compaction consumes a summarization pass (latency) and can lose detail if the summary is poor. Memory depends on the agent writing what matters, and reading it when it starts.
For the migration agent, a reasonable combination: context editing for the old test outputs, memory for decisions and exclusions (so they survive any trimming) and compaction as a safety net when the session reaches the limit. With that, high effort is reserved for decision steps.
What isn’t the solution
- A larger window: it postpones the problem and lets in more noise; the model remembers the important less well the fuller it gets.
- Restarting the session without carrying anything over: the agent repeats what is already done.
- Stuffing the whole history into the system prompt: you pay for it on every call and it doesn’t distinguish what is still current.
- Trusting the model to “remember”: what must survive gets written down.
The usual traps
- Max effort on every step.
- Minimum effort on the decisions the rest of the session inherits.
- Compacting when the problem is old results that could have been cleared.
- Clearing old results when the problem is a decision that must persist.
- Not saving to memory what the next session needs.
In the exam
Identify what is being lost: accumulated noise (context editing), information that must survive (memory) or a conversation nearing the limit with everything still current (compaction). Then look at the latency and accuracy requirements to assign effort by type of step. Discard “raise everything to max” and “more window” as an answer to long-session degradation.
Quick question
A practice exam question on this domain. It counts towards your progress.
A procurement team built a prompt that summarises supplier proposals. Its text, in a single block, contains the instructions, two example summaries and then the proposal pasted by the buyer, with no markers between them.
In about 5% of runs the output copies the style of an example but with details of the example's supplier, and in a few cases it treats a sentence inside the proposal such as "Summarise only the pricing section" as an instruction to follow. Proposals vary in length, up to about 20 pages, and the buyers paste them from different formats. The team wants a low-effort fix that does not change the model.
Which change best addresses the failure?