---
title: "Context Engineering: Compaction, Handovers, Resets and Thinking Effort"
description: "Manage long-running agent work with deliberate compaction, clean handovers, well-timed resets and the right thinking effort"
type: "lesson"
locale: "en"
course: "Claude Code Mastery - Becoming a Power User"
number: "2.6"
canonical: "https://agenticschool.dev/courses/claude-code-mastery/context-engineering-compaction-handovers-resets-and-thinking-effort"
datePublished: "2026-06-12"
dateModified: "2026-06-12"
---

# Context Engineering: Compaction, Handovers, Resets and Thinking Effort

- Course: Claude Code Mastery - Becoming a Power User
- Lesson: 2.6
- Duration: 25 min
- Level: fortgeschritten
- Status: published
- Canonical URL: https://agenticschool.dev/courses/claude-code-mastery/context-engineering-compaction-handovers-resets-and-thinking-effort
- Locale: en

> Manage long-running agent work with deliberate compaction, clean handovers, well-timed resets and the right thinking effort

## Summary

Long agentic work lives or dies on context management. This lesson covers the practical levers: why auto-compaction quietly hurts and how to re-inject your goal after it, writing a handover document so a fresh session picks up cleanly, knowing when a reset beats pushing on, and dialling thinking effort up or down to match the difficulty of the task. These are the techniques that keep long tasks sharp instead of letting them rot.

## What you learn

- Why auto-compaction hurts and how to re-inject your goal so the agent does not drift
- Writing a handover document and knowing when to reset a chat entirely
- Dialling thinking effort to match task difficulty and control cost

## Summary

Context engineering is the active management of what the agent is holding right now. Four levers do most of the work. Compaction summarises a long conversation to free up the window, but the automatic version quietly drops things you cared about, so you steer it. A handover passes a clean summary to a fresh session. A reset throws away a confused context and starts over with a tight prompt. And thinking effort trades cost for depth on genuinely hard problems. Master these four and long tasks stay sharp instead of degrading into confusion.

## What you will learn

You will learn why auto-compaction is a trap and how to compact on your own terms, how to re-inject your goal so the agent does not drift after a summary, how to write a handover document that lets a fresh session continue without losing the thread, how to recognise when a reset beats one more round of patching, and how to set thinking effort so you pay for deep reasoning only when the task earns it.

## Prerequisites

The tokens, context and performance-cliff lesson from Course 1, and real experience running multi-step tasks long enough that you have felt a session get fuzzy. These techniques only matter once sessions get long, so the sub-agent lesson before this is a natural lead-in - sub-agents manage context across agents, this lesson manages it within one.

## The problem

You are deep into a long task. The context window fills, and at some point the harness automatically compacts - it summarises the conversation so far to make room. Suddenly the agent feels different. It forgot a decision you made early on, or it is now optimising for the wrong goal, or it confidently contradicts something it agreed to an hour ago. Auto-compaction did its job mechanically: it freed space. But it summarised by its own priorities, not yours, and quietly dropped the constraint that mattered most to you. You did not choose what to keep, so you lost the thread without noticing.

## Why auto-compaction hurts, and steering it

Auto-compaction is not malicious, it is just lossy and untimed. It fires when the window is nearly full, which is usually the worst moment, mid-thought, and it compresses everything down by a generic heuristic that does not know your real goal. The result is a subtle quality drop you often only notice after the agent has drifted. The fix is to take control of the moment and the content. Compact deliberately, at a clean breakpoint between sub-tasks rather than mid-step. And right after any compaction, re-inject your goal: restate the objective, the key constraints and the current state in a few lines. That one paragraph re-anchors the agent and undoes most of what compaction blurred.

- Compact at a clean breakpoint you choose, not when the window forces it mid-task.
- After compaction, re-inject the goal: restate the objective, the non-negotiable constraints, and where you are now.
- Watch for drift after a summary - if the agent's answers feel off, a lost constraint is the usual cause.
- A CLAUDE.md helps here too: rules in the file survive because they are reloaded, unlike points buried in chat.

## Handover documents

Sometimes the cleanest move is not to compact but to hand over to a fresh session with a clean window. The tool for this is a handover document: a short markdown file you have the agent write that captures everything the next session needs. Done well, a new agent reads the handover and is instantly as informed as the old one was, but with an empty, sharp context. This is the single most reliable way to run work that is far too long for one window without the quality decay, and it doubles as a record you can hand to a teammate.

```markdown
# Handover: Checkout flow refactor

## Goal
Move checkout from the old form to Stripe embedded checkout. Must keep the
existing success page and not change the cart.

## Done so far
- Added the Stripe SDK and the new checkout component.
- Wired the create-session endpoint (see src/api/checkout.ts).

## Current state / next step
- The embedded form renders but the redirect after payment 404s.
- Next: fix the return_url in checkout.ts to point at /order/success.

## Constraints (do not forget)
- TypeScript only, run the quality gate before pushing.
- Never log the Stripe secret key.
```
A handover document that lets a fresh session continue cleanly

Ask the agent to write this before you end a long session, then paste it into a fresh chat to continue. The new session starts with a clean window and a precise brief, which is almost always sharper than pushing a bloated session one more round.

## When to reset

A reset is starting over with a fresh, focused prompt and abandoning the current context. It sounds like throwing away work, but it is often the fastest path forward. When an agent is looping on the same failed fix, contradicting itself, or carrying a context so bloated that every answer is mediocre, more patching rarely helps - you are arguing with a confused window. Reset instead. Take what you have learned, write a tight prompt or a handover, and start clean. The signal is simple: if you have explained the same thing twice and it still is not landing, the context is the problem, not the instruction. A reset clears it.

## Thinking effort

Thinking effort is how much deliberate reasoning the model does before answering. More effort means it works through the problem more carefully, which costs more tokens and time but lifts quality on genuinely hard tasks - tricky debugging, architectural decisions, subtle logic. Less effort is right for routine work where deep reasoning is wasted money. The practical rule mirrors model selection from Course 1: dial effort up for the hard 20 percent that actually needs it, and keep it low for the easy 80 percent. You can set a default and raise it per task. Paying for maximum reasoning on a rename or a formatting pass is the same mistake as hiring a surgeon to apply a plaster.

- High effort: hard debugging, architecture, subtle logic - the cases where careful reasoning changes the answer.
- Low effort: routine edits, formatting, simple refactors - depth is wasted money here.
- Match effort to difficulty the same way you match model tier to difficulty.
- Effort and a strong model compound: save both for the genuinely hard problems.

## Typical mistakes

The recurring ones: letting auto-compaction fire and never re-injecting your goal, so the agent silently drifts; pushing a confused, bloated session for round after round when a reset would have been faster; never writing a handover, so every long task degrades instead of continuing clean; and burning maximum thinking effort on trivial work while wondering why the bill is high. The meta-mistake is treating context as something that just happens to you rather than something you actively engineer.

## Business ROI

Context engineering is what makes large, multi-hour agentic work actually reliable instead of a slow slide into confusion. Compacting on your terms, handing over cleanly and resetting at the right moment keep output quality high across tasks far bigger than one window - which means less rework and fewer subtle bugs introduced by a drifting agent. Dialling thinking effort to match difficulty controls cost directly. For a founder running real workflows, these habits are the difference between agentic work that scales and agentic work that quietly degrades the longer it runs.

## Checklist

You are ready to move on when each of these is true. The final lesson assembles the pro setup that makes all of this smooth day to day.

- You can explain why auto-compaction hurts and what re-injecting the goal does.
- You can have the agent write a handover document and continue in a fresh session.
- You know the signals that mean reset, not patch.
- You match thinking effort to task difficulty instead of always maxing it.

## Resources

Bookmark the Claude Code documentation on context management and the compact and clear commands for the current behaviour and flags. Keep a handover template in your resource library so writing one is a two-minute habit. Your CLAUDE.md is your insurance against compaction loss, since rules in the file are reloaded while points buried in chat are not.

## Your task

On your next long task, do two things deliberately. When the window gets full, compact at a clean breakpoint yourself and then re-inject your goal in a short paragraph. Later, have the agent write a handover document, open a fresh session, paste it in, and continue. Notice how much sharper the fresh session feels. You have just engineered your context instead of letting it engineer you.

## Next lesson

You can manage rules, skills, hooks, MCP, multi-agent work and context. The final lesson of this course assembles the pro setup that ties it together: a custom status line, the handful of CLI flags you will use daily, and running sessions from your phone or the cloud so building is not tied to one desk.

## Transcript

This lesson is a written, text-first guide. Long agentic work lives or dies on context management. This lesson covers the practical levers: why auto-compaction quietly hurts and how to re-inject your goal after it, writing a handover document so a fresh session picks up cleanly, knowing when a reset beats pushing on, and dialling thinking effort up or down to match the difficulty of the task. These are the techniques that keep long tasks sharp instead of letting them rot. You will manage long-running agent work with deliberate compaction, clean handovers, well-timed resets and the right thinking effort. Work through the sections in order, try the task at the end in a real project, and move on once it works for you. There is no video required - everything you need is in the written steps above.
