session_learnings), and enriches the graph so future sessions recall from it. Surfaced in the UI as Self-improvement.
This page covers the Cloud endpoint and how it fires automatically for connected agents. For the concept and SDK walkthroughs, see Session Distillation (guide), the Self-Improvement Quickstart, and the improve operation.
Improve
POST /api/v1/improve — Enrich the graph and, when session_ids is passed, bridge those sessions into it.
session_ids, the call runs default graph enrichment only. With session_ids, it runs the full session-to-graph pipeline described above for each session.
Request body
Either
dataset_name or dataset_id is required. extraction_tasks, enrichment_tasks, and data are power-user overrides most callers never set.Error responses
Automatic distillation for agent sessions
You rarely call this endpoint directly. When you connect a coding agent through the Agent Integrations, the plugin fires it for you. The Cognee coding-agent plugins (Claude Code, Codex) run session distillation for you — you never callimprove() by hand. A distillation pass fires on three triggers:
Overlapping triggers are safe. A per-session improve lock on the server serializes concurrent runs, and unchanged session content dedups server-side by content hash — so a repeat improve over content that hasn’t changed is a cheap no-op, not duplicated work.
Configuration
All triggers are tuned through environment variables read by the plugin. The defaults are chosen so distillation stays out of your way; you rarely need to change them.Turning it down or off
- Stop idle-triggered improves: set
COGNEE_IDLE_DISABLED=1before launching the agent. Session-end and per-turn improves still run. - Reduce mid-session improves: raise
COGNEE_AUTO_IMPROVE_EVERYto a large value so the per-turn trigger effectively never fires within a session. - Session-end distillation always runs when the plugin is active — it’s how a finished session reaches permanent memory.
Confirming it happened
- Cloud UI: the Self-improvement card at the top of a session on the Sessions page shows the status of the last graph enrichment and the dataset it wrote to.
- Plugin hook log: each automatic run emits an
improve_firedevent you can grep for when debugging (in local SDK mode, where the plugin calls the library directly instead of the HTTP endpoint, look forauto_improve_firedinstead). improve-unsupported.jsonmarker: if this file appears in the plugin’s shared state directory (24h TTL), the server rejected the improve endpoint and the plugin fell back to the legacyrememberbridge for that window — a signal the server predates session-aware improve.