Skip to content

Managing Agent Context with Folders

One of the most important shifts when moving from a chat interface (like ChatGPT) to an agent like Cosine is understanding context persistence. In a chat, every conversation starts from zero. With the Cosine CLI, your agent’s memory lives on disk — inside folders.

Think of each folder on your machine as a project for a specific agent. When you run cos inside a folder, the agent can read everything in that directory. Any research it saves, notes it writes, or files it creates become part of its persistent context for all future sessions in that folder.

This means:

  • You can close the CLI and come back days later.
  • The agent picks up exactly where it left off.
  • You don’t have to re-explain your preferences or context every time.
  1. Create a folder for your project:

    Terminal window
    mkdir ~/social-posts
    cd ~/social-posts
  2. Run cos init to create an agent.md file in that folder:

    Terminal window
    cos init

    The agent.md file defines the rules, persona, and behaviour for the agent whenever you work in this folder. Think of it as the agent’s standing instructions. See Quickstart if you haven’t set up the CLI yet.

  3. Open the CLI inside that folder:

    Terminal window
    cos

The agent is now configured for this specific project context. Any work it does — research files, notes, drafts — will be saved here and available in every future session.

A key technique for maximising future value is explicitly instructing the agent to persist its work to disk. For example:

“During research, save your findings as .md files in this folder so I can retrieve them later.”

You can add this instruction directly to your agent.md, so the agent always does this automatically — you never have to ask again.

  • Each folder is a self-contained agent with its own memory and context.
  • cos init creates an agent.md that defines the agent’s behaviour for that folder.
  • Saving research and notes to disk means your context accumulates over time rather than resetting.
  • When you return to a folder weeks later, the agent remembers everything.

Next: Navigating Between Sessions