WEEK 9 · LESSON 1 · TOPIC 2 OF 6 · How It Works

How It Works

Lesson progress

0% Complete

SECTION 1 OF 1

In this topic · 1 sections
  1. Overview

Overview

A new session begins with the system prompt and any instructions that are always loaded. The agent then usually moves through four broad stages:

  1. It starts from the persistent system instructions.
  2. It explores the codebase and gathers relevant information.
  3. It implements a change.
  4. It runs tests, type checks, or other feedback loops.

Every stage adds tokens. As the context grows, attention relationships become increasingly strained. A practical operating marker is to treat roughly 100,000 tokens as the boundary beyond which coding quality may begin to decline, even when the nominal context window is much larger. A million-token window may be useful for retrieving information from a very large body of text, but that does not mean the entire window is equally effective for difficult coding decisions.

The system prompt deserves special attention because it is present at the start of every session. A bloated system prompt can place the agent deep into the context budget before it has explored or implemented anything. Persistent instructions should therefore be kept as small as possible.

There are two basic ways to deal with a long session:

  • Clear the context. This discards the conversation and returns the agent to the same known

starting state.

  • Compact the context. This turns the session into a written history and continues from that

summary.

Compaction preserves continuity, but each compacted summary adds another layer of accumulated interpretation. Repeated compaction creates sediment: summaries of prior work become part of the next session, even when some details are no longer useful or accurate. A workflow that can repeatedly clear and restart from a stable base is easier to reason about because every new session begins from the same state.

Subagents provide another way to protect the main context. A subagent receives an isolated context window, performs a delegated exploration or analysis task, and returns only a concise summary to the parent agent. The delegated agent may consume a large number of tokens without filling the orchestrating agent's context with every intermediate detail.