The Agents Active Memory
An agent can only pay attention to so much at one time. This module shows what fills that attention, why it matters, and how to keep it useful.
Lesson 2.1
Context is a shared budget
An agent is a language model that can keep working in a loop: read the request, decide what to do, use tools, look at the result, and decide again. In any single moment, everything it can use lives in one place: its context window.
Think of the context window like the agent's desk. The system prompt, your conversation, tool results, opened files, and loaded skills all have to fit on that desk at the same time. If the desk gets crowded, the agent has more to sort through and less room for the actual problem.
-
System prompt + AGENTS.mdalways loadedYou are an agent. Tools: read, edit, bash… Follow the house rules. Be concise.
-
Skill Libraryalways loaded
Available Skills
design-guide: Apply the house visual system… coding-standards: Applies the coding standards… commit-message-format: Shows the agent how to format commit message -
User inputyour turn> Add a dark-mode toggle to the settings page.
-
Agent thinkinggrows as it worksThe toggle needs a saved preference… read
settings.js→ found themeContext select coding-standards reads the body of the skill editingsettings.js… readtheme.js,storage.js, 38 more files… multiple user/agent interactions - dozens of tool results, reasoning over many turns -
Compactionreplaces the conversation↺ user input & agent thinking summarized: “built dark-mode toggle, wired to themeContext, tests green” system prompt & skills stay; the bulky turns are folded away
When the window gets close to full, the harness can compact the conversation. That means it replaces older, bulky turns with a shorter summary so the agent can keep working.
Usually kept in detail: the system prompt, your original goal, important decisions, and recent turns. Usually summarized: long file reads, old tool results, and earlier step-by-step work whose conclusion is already known.
The trade-off is real: compaction buys room, but it loses detail. The more often a long conversation compacts, the more earlier texture gets flattened into summary. That is why a lean context window matters.
The window is finite. Here is the idea that shapes every decision in this course: everything you add to an agent competes for that same space. A capability that loads a thousand lines of instructions up front is a thousand lines the model has to carry while solving the real problem. Starting a fresh conversation for a fresh task is one simple way to keep that space cleaner.
Add only what the agent does not already have, and only when it needs it. Every token you introduce has to earn its space. This one principle is why skills, subagents, slash commands, and hooks are shaped the way they are.
Keep this image in mind: not "how do I give the agent more?" but "how do I give it the right thing at the right moment, and nothing else?"
Lesson 2.2
Primitives
Skill: reusable knowledge, on demand
A skill is a folder with instructions the agent loads only when a task calls for it. It's the default building block, and most of this course. A skill teaches a procedure once so you never have to paste it again. Reach for it when you keep re-explaining the same how-to.
Subagent: a worker with its own window
A subagent is a delegated assistant with its own context window, its own tools, and often a cheaper model. Whatever it reads and produces stays in its window, not yours. Reach for it when a side task would otherwise flood your main conversation with output you'll never look at again.
Slash command: a skill you trigger by name
A slash command is not a separate thing to learn: it's simply a skill you invoke directly, by typing its name. Same file, same format; you just pull the trigger instead of waiting for the agent to decide it's relevant. Reach for it when you want to run something on demand.
Commands and skills used to be separate. They've been merged: a skill you can call by name is the slash command. So learn one primitive, not two; you'll see exactly how in Module 2.
Hook: a guarantee, run by the harness
A hook is deterministic code that fires on lifecycle eventsLifecycle events: specific moments in a process, like startup, before a tool runs, or after a file is saved.: before a tool runs, after a file is saved, when a session starts. Crucially, the harnessHarness: the surrounding software that runs the agent and controls its tools, permissions, and events. runs a hook, not the model. That's the whole point: the model can forget or decide not to; a hook happens every time. Reach for it when something must be guaranteed.
You need the agent to grepgrep: a command-line search tool for finding text inside files. a huge log, producing thousands of lines you'll never read again. Which primitive fits best?
Pick one. You'll get instant feedback.
Lesson 2.3
Choosing between them
You don't need to memorize a table. Almost every choice comes down to four questions, asked in order:
- Is it recurring knowledge or a procedure? → a skill.
- Does it need isolation: its own context, tools, or a cheaper model? → a subagent.
- Must it happen deterministically, every single time? → a hook.
- Do you want to trigger it yourself, by name? → a skill, invoked as a command.
Across these modules we'll build one thing: a design-guide helper. It starts as a simple skill, learns to keep its own reference material out of the way, gets a sharp description so the agent actually reaches for it, and finally grows a subagent and a hook. Watch it evolve: each module adds one real capability.
Hands-on
Name the primitive
Three quick calls. Read each situation and decide which primitive earns its place; the goal is to make the four questions above feel automatic.
1. Every week you paste the same 40 lines explaining your team's commit-message format.
2. You must never let the agent run rm -rf without a confirmation, no exceptions.
1. The context window is a shared, finite budget: spend it deliberately.
2. Four primitives: skill (knowledge on demand), subagent (isolated worker), slash command (a skill you trigger), hook (a guarantee).
3. Choose by asking: recurring? isolate? guarantee? trigger?
Finished The Agents Active Memory?
Mark it done to track your progress across the course.