DSHGuide

Chapter 5 — Sessions, Context, and Memory

4 min read · 814 words · 12 sections

What You Will Learn

  • Understand Session and Context Window;
  • Know why the Agent forgets;
  • Separate in-session memory from cross-session memory;
  • Use files, AGENTS.md, and Skills as long-term memory;
  • Manage context so the conversation does not become slow or expensive.

5.1 What a Session Is

A Session is one continuous conversation.

Within a Session:

  • Your messages, the Agent's replies, and tool results form a history;
  • The Agent can refer to earlier content;
  • The history is not infinite.

A new Session usually does not inherit the full chat history. It may read the workspace, AGENTS.md, and available Skills, but it starts a new meeting.

Think of a Session as one meeting. A new meeting does not remember every sentence unless you leave notes.


5.2 Context Window: The Agent's Working Memory

A model can process only a limited amount of text at once. That limit is the Context Window.[1]

Context includes:

  • System prompt;
  • Tool definitions;
  • Skill content;
  • Your messages;
  • Previous replies;
  • Tool results;
  • File contents that were read.

When the context fills up:

  • Responses slow down;
  • Cost rises;
  • Early information is forgotten;
  • Compaction or truncation may occur;
  • The Agent may confidently continue with incomplete information.

Warning signs

  • It repeats questions;
  • It cites the wrong file;
  • It forgets a rule you set;
  • Replies become long and unfocused.

5.3 DSH Does Not Automatically Remember Everything

This is the most common beginner misconception.

DSH keeps a session log, but that is not the same as cross-session long-term memory.[2]

  • Within a Session: it remembers the chat;
  • A new Session: it usually does not remember every previous message;
  • It may read workspace files, AGENTS.md, or Skills;
  • If you install a memory plugin, you may get extra cross-session recall.

Important information should be written to files:

  • Project background → PROJECT.md;
  • Rules → AGENTS.md;
  • Progress → TODO.md or a task list;
  • Decisions → DECISIONS.md;
  • Deliverables → output files.

If a file can remember it, do not rely on the chat to remember it.


5.4 New Session vs. Continue

Situation Recommendation
A completely new task New Session
Continuing the same task Continue the current Session
The Session is long and confused Summarize to a file, then start a new one
A different project Change workspace and start a new Session
A quick independent question New Session, to avoid polluting context

For long tasks

  1. Ask the Agent to write progress to PROGRESS.md;
  2. List done / not done / next;
  3. Start a new Session;
  4. Ask it to read PROGRESS.md and AGENTS.md first.

This is more reliable than stretching one Session forever.


5.5 Use Files as Long-Term Memory

A simple structure:

project/
  AGENTS.md        # rules
  PROJECT.md       # background
  DECISIONS.md     # key decisions
  PROGRESS.md      # progress
  TODO.md          # tasks
  notes/           # source material
  output/          # deliverables

At the start of a new Session:

Read AGENTS.md, PROJECT.md, and PROGRESS.md first.
Then summarize the current state in three sentences.
Do not modify anything before that summary.

Now the Agent does not need to remember the entire chat.


5.6 Context Hygiene

  • Do not read large amounts of unrelated material;
  • Search first, then read only what is needed;
  • Read long documents in sections;
  • Ask for summaries when tool output is large;
  • Write conclusions into files;
  • Do not mix unrelated tasks in one Session.

Useful prompt:

Read only the three files most relevant to the task.
If you need more, explain why first.
Do not read the entire directory at once.

5.7 Memory Plugins Are Not Magic

Some plugins provide cross-session memory:

  • Extract facts automatically;
  • Store them locally or in the cloud;
  • Recall them in later conversations.

They are useful, but:

  • They can recall the wrong thing;
  • They can treat old information as current;
  • They add context and cost;
  • They require privacy and permission review.

For beginners, start with files and AGENTS.md. Add a memory plugin only when you have a clear need.


Try It

  1. Ask the Agent to write PROJECT.md with the current goal and constraints;
  2. Start a new Session;
  3. Ask it to read PROJECT.md and restate the goal;
  4. Observe whether it can continue without the old chat history.

Common Pitfalls

  • Expecting a new Session to remember the old one: it usually does not.
  • Dumping all material into context: slow and expensive.
  • Changing requirements endlessly in one Session: context pollution.
  • Saying "remember this" without writing it down: it will be gone.
  • Trusting memory recall as truth: recall can be wrong.

Summary

  • Session = one conversation; Context Window = working memory.
  • Context fills up; when it does, the Agent forgets, slows down, and costs more.
  • DSH does not automatically remember everything across Sessions.
  • Write important information to files; summarize long tasks before starting a new Session.
  • Memory plugins are a supplement, not a replacement.

References

  1. DeepSeek API token usage
  2. DeepSeek Harness GitHub repository

All links are public sources; product behavior may change between versions.


↑