> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cogniagent.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Context & memory

> How a worker's context is assembled, automatically compacted, and remembered — so long tasks stay coherent from first turn to last.

A worker only knows what's currently in its context — the instructions, files, and conversation it can "see" in a given turn. CogniAgent assembles that context automatically, compacts it when a task runs long, and layers in memory so a worker doesn't lose the thread or repeat work it already finished.

## What's in a worker's context

Every turn, a worker's context is assembled from a few layers, from most stable to most specific. The stable layers — identity, instructions, and the skills index — are the same across all of a worker's tasks; the volatile ones — files, conversation, and the task's goal — change task to task.

<AccordionGroup>
  <Accordion title="Identity and instructions" icon="id-badge">
    Who the worker is and how it should operate: its persona, plus the rules and conventions you gave it when you [set it up](/cowork/workers/overview). This is the closest thing a worker has to a job description, and it's present in every task the worker runs.
  </Accordion>

  <Accordion title="Available skills" icon="wand-magic-sparkles">
    A lightweight index of the worker's [skills](/cowork/workers/skills) — just names and short descriptions. A skill's full instructions load on demand only when the worker actually decides to use it, so having many skills doesn't bloat every turn's context.
  </Accordion>

  <Accordion title="Files" icon="folder-open">
    The documents and code the worker is working with in its [sandbox](/cowork/tasks/execution) for this task, read as needed rather than loaded all at once.
  </Accordion>

  <Accordion title="Conversation history" icon="comments">
    The back-and-forth for this task: what you asked, what the worker did, and what it found — the part of context that grows the fastest, and the part [compaction](#automatic-compaction-keeps-long-tasks-running) manages.
  </Accordion>

  <Accordion title="What the task is trying to accomplish" icon="bullseye">
    The goal for this specific task, kept close at hand so the worker doesn't drift from what you actually asked for.
  </Accordion>
</AccordionGroup>

This layering is also what the [agentic loop](/cowork/loop/agentic-loop) reads from at every plan, act, and observe step — the stable layers give the worker its identity and capabilities, the volatile ones tell it what's happening right now.

The stable and volatile layers also differ in who sees them. Identity, instructions, and skills live on the worker, so they're shared by every [task](/cowork/tasks/overview) that worker runs. Conversation history, files, and the task's goal are private to the task and visible only to the person who started it.

<Tip>
  A worker's context is assembled once when a task starts and carried forward from there. If you edit a worker's instructions or skills while a task is already running, the change won't reach that task mid-flight — it takes effect the next time you start a new task with that worker. [Hooks](/cowork/loop/hooks) are the one deliberate exception: they're re-read live at the start of every turn, so fixing a broken hook takes effect on the very next turn of an already-running task.
</Tip>

## Automatic compaction keeps long tasks running

A model can only hold so much conversation in context at once. As a task's conversation grows, CogniAgent watches how much room it's using and, before it runs out, automatically **compacts**: it folds the older parts of the conversation into a structured checkpoint summary, while your most recent turns are kept exactly as they happened.

```mermaid theme={null}
flowchart LR
    A[Conversation grows<br/>during a long task] --> B{Getting close<br/>to the limit?}
    B -- Not yet --> C[Keep working as normal]
    B -- Yes --> D[Fold older turns into<br/>a checkpoint summary]
    D --> E[Keep the most recent<br/>turns verbatim]
    E --> F[Worker continues<br/>the task seamlessly]
```

The checkpoint carries forward what matters most from the folded turns — the goal, decisions made, key facts and values, files touched, and what's still outstanding — so nothing important gets silently dropped. You don't have to do anything to trigger this; it happens automatically as part of running the task, and the worker keeps going without you needing to re-explain where things stand.

## The checkpoint is reference-only

A compacted checkpoint is background, not a new to-do list. The worker treats it as a summary of what already happened — not as work still waiting to be done. That distinction matters: without it, a worker could misread its own summary as an outstanding request and redo steps it already completed, for example re-creating a file or re-running a step that the checkpoint says is already done.

A task can be compacted more than once over its lifetime. Each new checkpoint absorbs the previous one along with whatever's been folded in since, so the worker is always working from one current summary plus its most recent turns — never a stack of old, conflicting checkpoints to reconcile.

## Memory that grows with the worker

Context inside a single task is temporary — it's scoped to that conversation. Memory is what a worker can carry forward *between* tasks. CogniAgent structures this in tiers:

| Memory type                | What it holds                                                                                                                                                                       | Availability                                                                                                                             |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Working memory             | The live conversation for the current task — recent turns, files touched, the current plan                                                                                          | Available now — managed automatically via context and compaction                                                                         |
| Procedural memory          | Reusable, packaged know-how for a specific procedure                                                                                                                                | Available now, as [skills](/cowork/workers/skills) you or your team author                                                               |
| Semantic & episodic memory | Standing facts and preferences that carry across tasks — jotted live during a task, or proposed by the [improvement reviewer](/cowork/autonomy/self-improvement) after one finishes | Available now, but human-reviewed: live notes are yours to edit anytime, and reviewer proposals wait for your approval before they stick |

<Note>
  What's on the roadmap is a worker fully forming and refining this memory on its own, without you writing or approving anything. See [self-improvement & learning](/cowork/autonomy/self-improvement) for the full picture of what ships today versus what's ahead.
</Note>

## Why this matters

Together, layered context and automatic compaction are what let a worker stay on a long, multi-step task without you babysitting it. You don't need to keep the conversation short, re-paste earlier decisions, or restart when things get long — the worker keeps the thread itself, checkpoint after checkpoint, until the task is done.

## Next steps

<CardGroup cols={2}>
  <Card title="The agentic loop" icon="repeat" href="/cowork/loop/agentic-loop">
    See how context feeds each plan, act, and observe step.
  </Card>

  <Card title="Skills" icon="wand-magic-sparkles" href="/cowork/workers/skills">
    Package reusable know-how a worker loads on demand.
  </Card>

  <Card title="Execution, sandbox & files" icon="folder-open" href="/cowork/tasks/execution">
    Where the files a worker works with actually live.
  </Card>

  <Card title="Self-improvement & learning" icon="seedling" href="/cowork/autonomy/self-improvement">
    How memory notes and skills are proposed, reviewed, and approved today.
  </Card>
</CardGroup>
