Skip to content

Memory and context

Cosine maintains context across sessions through two mechanisms: repository-level memory files and session memories saved by the agent during conversation.

An AGENTS.md file in your repository root serves as persistent context that the agent reads at the start of every session. Use it to document:

  • Project architecture and conventions
  • Build and test commands
  • Team preferences and coding standards
  • Non-obvious setup steps

Initialize one with:

Terminal window
cos init

During a conversation, the agent can save reusable facts using the save_memory tool — things like build fixes, project conventions, or user preferences. These are stored in .cosine/agents.md and automatically loaded in future sessions.

Good candidates include:

  • Stable project conventions
  • User or team preferences
  • Recurring setup fixes
  • Reusable context that should persist across runs

Cosine models have a limited context window. Cosine manages this by:

  • Loading relevant files on demand rather than all at once
  • Using LSP operations (go-to-definition, find references) to narrow scope
  • Summarising earlier conversation turns when sessions grow long
  • Consulting memory files for high-priority conventions

You can configure how Cosine recalls memories:

[config]
memory_recall_mode = "every" # "every" or "first"
memory_recall_detail = "snippet" # "snippet" or "full"

See Memory for surface-specific configuration.