---
name: long-session-check
description: Check how an agent or a working session handles long conversations, covering tool-result clearing, compaction, what gets written to files, when to start a new session, and how memory is scoped. Use when a long session starts forgetting constraints, after several compactions, or when reviewing an agent's compaction and memory design.
title: long-session-check
canonical_url: https://skilld.dev/gh/minimax-ai/mcode-stack/long-session-check
last_updated: 2026-10-29T09:48:02.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install minimax-ai/mcode-stack/long-session-check`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/long-session-check`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/minimax-ai/mcode-stack/long-session-check) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/long-session-check`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/long-session-check --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/long-session-check --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Long Session Check

The context window is a workbench, not a warehouse. Compaction answers "it
does not fit right now"; memory answers "will we remember next time". Both are
lossy. The safe pattern is to get anything important into human-readable
files early, and to treat compaction as tidying the workbench, not as the only
safety net.

Companion to MCode Engineering Notes 03, "Keeping long sessions sharp".
Plain-text checklist: `checklists/long-session.md`.

This skill has two modes. Pick the one that matches the request.

## Mode A - the session you are in right now

1. **Sort what is in context into three bins.**
   - *Drop*: things you can fetch again or no longer need (large file reads,
     test logs, search results, abandoned attempts).
   - *Summarize*: this-session-only story (where we are, next step, open bugs
     and leads, files recently touched).
   - *Write to a file*: anything that would hurt if lost or is needed in a
     later session (decisions and their reasons, progress, todos, acceptance
     criteria, long-lived rules).
2. **Write the third bin down now**, in the project's progress or design doc,
   or via `handoff-doc`.
3. **Choose the next move:**
   - Same task, history just long: compact, and say what comes next and what
     must be kept (for example "focus on the auth refactor, drop the test
     debugging").
   - New task: start a new session.
   - Compacted several times and drifting, or repeating questions already
     answered, or breaking earlier constraints: write a hand-off doc and start
     fresh with it.
   - Went the wrong way: rewind to before the mistake instead of compacting,
     so the wrong attempt does not end up in the summary.

## Mode B - reviewing an agent's design

Read the agent's code and configuration and answer each item with evidence
(file and line, config key, or observed behaviour):

1. Are old tool results cleared before resorting to a full summary?
2. Are tool calls and their results kept in pairs when results are cleared?
   Many model APIs reject orphaned calls.
3. Do key decisions and constraints get written to files, not only kept in
   the conversation?
4. Does manual compaction accept instructions about what to keep and what
   comes next?
5. Does automatic compaction trigger early enough to leave room for output
   and for the summary itself? Can the session continue if compaction fails
   (quota, smaller model)?
6. Can the compaction request reuse the prompt cache? Does compaction run so
   often that it keeps invalidating the cache?
7. Does compaction change only what the model sees, leaving the user's visible
   history intact? Is it kept out of user-facing budgets such as step limits?
8. Is the model told that context is managed automatically, so it does not
   stop half way to "continue next turn"?
9. Is project memory (`AGENTS.md` or similar) short and limited to stable
   rules?
10. Is memory scoped (session, project, user)? Are temporary progress and
    todos kept out of long-term memory?
11. When memory exceeds its injection budget, is truncation visible, and are
    the most important rules guaranteed to load?
12. Can a human open, edit and switch off the memory? Rules that must be
    enforced belong in hooks, not in memory.

## Output

For Mode A: the three bins, what you wrote to which file, and the chosen next
move. For Mode B: a table of the items with pass / fail / unknown, the
evidence, and the top fixes in priority order.
