C.W.K.
Stream
Lesson 03 of 05 · published

Context Layers: Prompt, Memory, Retrieval, Tools

~25 min · memory, retrieval, tools

Level 0Window Watcher
0 XP0/50 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

Four layers, four lifetimes

Instructions are stable intent. Conversation is recent working state. Retrieval is selective background. Tools expose the outside world. Durable memory is what should survive beyond the window. Confusing these layers is how teams create giant prompts that are expensive, stale, and still incomplete.

A rule that must always apply belongs in a durable project instruction. A fact needed for one answer belongs in retrieved context or a tool read. A current plan belongs in a handoff board. A one-time stack trace belongs in the session only until it is diagnosed.

Move facts to the right lifetime

Context management is often not about summarizing harder. It is about promoting the right facts out of the window and demoting transient noise out of attention. A single permanent rule pasted into every chat is wasted budget. A handoff that lives only in the latest message is one accidental compaction away from being lost.

The decision habit

Every time something important shows up in chat, ask the lifetime question: should this survive the next session, the next week, or only the next reply? That question, asked dozens of times in a long project, is what separates a tidy AI workflow from a runaway prompt graveyard.

Code

Choose the right lifetime·python
fact_lifetime = {
  "forever rule":         "project/vault instruction file (.md / CLAUDE.md)",
  "team policy":          "shared system prompt block",
  "current task state":   "handoff board (committed file)",
  "source material":      "indexed file or retrieval corpus",
  "one command result":   "current session only",
  "human decision":       "explicit note before compaction",
  "transient noise":      "drop on next checkpoint",
}
Promote, demote, drop·yaml
lifetime_actions:
  promote_to_durable:
    - "do not push without human approval"
    - "always run pytest before commit"
  keep_in_session:
    - latest tool result waiting for review
    - draft answer being refined
  drop_after_use:
    - one-time stack trace once root cause is found
    - banner timestamps from the system

External links

Exercise

Take a messy AI session and classify ten facts by lifetime: system rule, project rule, handoff state, retrievable reference, or throwaway noise.
Hint
If a future agent must obey it, it should not live only in chat history.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.