Skip to main content
Session distillation bridges a conversation from the short-lived session cache into your permanent knowledge graph: it weights existing memories by the session’s feedback, persists the Q&A and agent traces, distills durable guidance into reusable lessons (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.
Without 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 call improve() 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.
The plugin READMEs document additional advanced knobs — timing (poll deadlines, busy-retry intervals for a held session lock), session-sync retries, and the update-notification variables (COGNEE_UPDATE_CHECK, COGNEE_UPDATE_CHECK_INTERVAL). You almost never need them — reach for the table above first.

Turning it down or off

  • Stop idle-triggered improves: set COGNEE_IDLE_DISABLED=1 before launching the agent. Session-end and per-turn improves still run.
  • Reduce mid-session improves: raise COGNEE_AUTO_IMPROVE_EVERY to 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_fired event you can grep for when debugging (in local SDK mode, where the plugin calls the library directly instead of the HTTP endpoint, look for auto_improve_fired instead).
  • improve-unsupported.json marker: 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 legacy remember bridge for that window — a signal the server predates session-aware improve.