cognee.recall()
Description
recall() is the main retrieval entry point in Cognee v1.0.
- It auto-routes queries by default when you do not specify
query_type. Routing is rule-based (no LLM call) and falls back toGRAPH_COMPLETIONwhen no cue matches — see Auto-routing behavior for the full cue-to-search-type mapping and when to override. - It can search the permanent graph, session memory, or both.
- It returns
RecallResponseitems sourced from graph retrieval, session retrieval, or both depending on the request.
Prerequisites
recall() only reads from memory that already exists — it does not initialize anything on its own. Populate memory first with remember() (or the legacy add() + cognify() sequence). The first ingestion run creates the relational, vector, and graph databases and the default user.
Parameters
str
required
Natural-language query to run against memory.
SearchType | None
default:"None"
Forces a specific retrieval strategy instead of using auto-routing.
list[str] | None
default:"None"
Restricts graph retrieval to the named datasets. Dataset names are resolved only against datasets owned by the current user. When both
datasets and dataset_ids are omitted, retrieval spans every dataset the current user has read access to — not just a single default dataset. Pass this to narrow the search to specific datasets.list[UUID] | None
default:"None"
Restricts graph retrieval by dataset UUIDs instead of names. Use this for shared datasets that the current user can access but did not create. When provided, this takes precedence over
datasets and the name-to-UUID lookup is skipped. Leaving both datasets and dataset_ids unset searches all of the user’s readable datasets.int
default:"15"
Maximum number of results to return.
bool
default:"True"
When
True, Cognee chooses a retrieval strategy automatically if query_type is not set, using the rule-based query router. Set it to False to always use GRAPH_COMPLETION. An explicit query_type always takes precedence over routing.str | list[str] | None
default:"None"
Controls whether retrieval uses
session, graph, or the default automatic combination logic.Additional keyword options
Return value
recall() returns a list of RecallResponse items. Depending on the request, results may come from session memory, permanent graph retrieval, or both.
These items are Pydantic objects, not plain dictionaries — read fields with attribute access (result.text), not result.get("text") or result["text"]. Calling .get() on a result raises AttributeError: 'ResponseGraphEntry' object has no attribute 'get'.
The concrete type of each item is set by its source field (import from cognee.modules.recall.types.RecallResponse):
Source provenance in metadata
For chunk and summary results (CHUNKS, CHUNKS_LEXICAL, SUMMARIES), the metadata dict carries stable source identifiers so you can map a result back to the data you ingested and inspect the exact cited chunk. Only the keys present in the underlying payload are included:
Completion-style results (e.g.
GRAPH_COMPLETION) carry an empty metadata dict; for those, the same ids are surfaced inline in the Evidence: block instead (see include_references). When include_references=True, each evidence bullet is rendered as - chunk N of document NAME (data_id: …, chunk_id: …): "snippet". This is an additive response-schema change — no DB migration is required, since document_id is already stored on chunks.
The
text_result, context_result, and objects_result keys come from the legacy search(verbose=True) API, which returns plain dicts. recall() does not produce those keys. For a graph-backed recall item, result.text is the display-ready value. result.raw preserves the normalized payload for that item; for completion-style searches, it is not the same thing as objects_result.