Memory and context
Cosine maintains context across sessions through two mechanisms: repository-level memory files and session memories saved by the agent during conversation.
AGENTS.md
Section titled “AGENTS.md”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:
cos initSession memories
Section titled “Session memories”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.
What belongs in memory
Section titled “What belongs in memory”Good candidates include:
- Stable project conventions
- User or team preferences
- Recurring setup fixes
- Reusable context that should persist across runs
Context window
Section titled “Context window”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
Customising memory
Section titled “Customising memory”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.
Related pages
Section titled “Related pages”- How the agent works — The agent loop
- Customising Memory — Per-surface memory settings