defaults < config.json < .env < env < code
(precedence), and can be set from code with
the config API or
cognee-cli config.
Chunking & tokenizer
Read bycrates/chunking/src/config.rs.
chunk_strategy (default PARAGRAPH) selects the chunker cognify cuts
documents with. It has no env binding; set it with
cognee-cli config set chunk_strategy …, ConfigManager::set or the TypeScript
binding’s setChunkStrategy, or per run with the CLI’s --chunker. Names are
case-insensitive, and the chunker class names (TextChunker, LangchainChunker,
CsvChunker, JsonListChunker, TextChunkerWithOverlap) are accepted too:
An unknown name logs a warning and keeps
PARAGRAPH. Under PARAGRAPH, CSV
documents are still cut row by row (csv_chunker_v1); every other strategy
applies to CSV rows as well. The overlap chunker’s ratio
(CognifyConfig::chunk_overlap_ratio, default 0.0, must be in
[0, 1)) and a custom Chunker (CognifyConfig::with_chunker, or
with_custom_chunker for a closure, whose chunks carry custom_chunker) are
code-only, so OVERLAP chosen through config cuts chunks with no overlap (cognify
logs a warning); a custom chunker overrides chunk_strategy. chunk_engine is stored
and never read.
Chunk size and overlap are env-bindable; chunk_overlap is read by the
RECURSIVE chunker only, in words, and may be at most 1024 there:
chunk_size unset means “auto-calculate at pipeline time”:
min(<embedding engine limit>, llm_max_completion_tokens / 2). The engine limit is
EMBEDDING_MAX_COMPLETION_TOKENS (default 8191) for the OpenAI-compatible and
Ollama engines and EMBEDDING_MAX_SEQUENCE_LENGTH (default 512) for the local
ONNX engine. With OpenAI-compatible embeddings at their defaults that is
min(8191, 8192) = 8191 tokens; with the local ONNX/BGE engine it is its
512-token sequence limit. Set it explicitly (env, cognee-cli config set chunk_size, or --chunk-size) to override — an explicit value is always
honoured. cognee-cli config set chunk_size null restores the auto-calculation.
The token counter is chosen by the cognify engine section (registered with the
kind sections), resolved when cognee lowers Settings into a CognifyConfig
(Settings::cognify_config; CognifyConfig::default() itself reads nothing):
Settings::cognify_config also applies the batch sizes, the graph-extraction
prompt, the extraction strategy and the summary schema:
data_per_batch (cognify.data_per_batch, COGNEE_DATA_PER_BATCH,
CognifyConfig::with_data_per_batch) has been removed: no stage read it once
temporal cognify was gone. Setting the key is now an unknown-key error under
strict config (otherwise a warning, and the value is dropped), and the env var
is ignored.
A CognifyConfig built in code with
ExtractionStrategy::Cascade { rounds: 0 } fails validation. The strategy is
ignored when a non-llm graph backend replaces LLM extraction.
COGNEE_LEGACY_PER_WORD_TOKEN_COUNT restores the legacy per-word count.
By default a chunk’s size is the tokenizer’s count of the chunk itself. Before
SDK-632 it was the sum of the counts of its words, each tokenized in isolation,
which over-states the span for sub-word tokenizers (measured 1.78x on Alice
in Wonderland: a chunk configured at 8191 tokens held 4,669, and the run made
~1.8x the LLM calls). The default now fills that budget to 8,188 of 8,191.
Setting COGNEE_LEGACY_PER_WORD_TOKEN_COUNT=1 restores the per-word count, and
its chunk boundaries, at the cost of the over-count. Only 1/true/yes/on
enable it. Full measurement record:
performance/chunk-token-overcount.md.
Edge evidence
WithEDGE_EVIDENCE_ENABLED on, each cognify storage batch records which chunk
supports which graph edge in provenance_edge_evidence, keyed by the run’s
pipeline_run_id; a search only cites rows whose run has a COMPLETED
pipeline_runs row. A run without a user records no evidence (the
ownership ledger, by contrast, falls back to the default user).
A host that records the run in pipeline_runs itself, and hands cognify a
no-op run repository, sets CognifyConfig::with_evidence_pipeline_run_id (code
only) to the id it marks COMPLETED; otherwise the rows carry the executor’s
run id, which nothing records, and no search cites them. Only the evidence rows
change: ownership, completion markers and rollback stay keyed on the executor’s
run id.
Graph extraction
Thegraph_extraction section is registered by the graph-extraction kind. It
picks the extractor cognify uses to turn chunks into graph facts.
llm is cognify’s built-in LLM extractor. auto, the default,
picks llm when an LLM is usable and gliner otherwise (see
Keyless cognify). gliner_demo means
gliner. Other kinds (GLiNER, …) are GraphExtractorFactorys that an external
crate registers with register_graph_extractor, together with their own config
sections. The setting is overridden per call by
the bindings’ extractor option and the CLI’s --extractor flag on cognify,
add-and-cognify and remember. A binding’s graphBackend cognify option (a
kind string, or {"kind": …, …tuning}) overrides both. A kind nothing is
registered under is an error; cognify never falls back to the LLM extractor
silently, and neither does auto.
Every operation that cognifies honours the setting: cognify and
add-and-cognify in the CLI and the bindings, and the operations that cognify as
a sub-step (remember, improve, and the bindings’ update). Each one resolves
the extractor before any side effect, so an unregistered kind fails before data is
ingested or deleted. The exception is cognify in the CLI and the bindings, and
add-and-cognify in the CLI and the bindings: they decide whether a run needs
the extractor (and the LLM) from the items it will actually process, after
items an earlier run completed are skipped, so over items that are all code
they resolve no extractor. They still check a selection nothing is registered
under up front (--extractor, the bindings’ options, or a configured
graph_extraction.backend other than auto), so a typo fails even on a
code-only dataset. The exception is the bindings’ cognify: over code-only
items it checks only an extractor its options name, not the configured
graph_extraction.backend. Only the keyless auto default that cannot be served is
deferred to an item that needs it (see Keyless cognify).
The bindings’ remember, improve and update still resolve the extractor up
front, even for a code project.
Library callers that build a CognifyConfig themselves get
the configured backend from ComponentManager::configured_graph_extractor (or
graph_extractor with a per-call selection) and attach it with
with_graph_backend; ComponentManager::resolve_graph_extractor returns the
resolved kind.
Keyless cognify
With no usable LLM, cognify switches to local models:- the
autograph extractor resolves togliner. Nothing in cognee-rs registers aglinerextractor, so a build without one fails cognify with an error naming the remedies: setLLM_API_KEY, register aglinerextractor, or setGRAPH_EXTRACTORto a registered kind. Only a run with a document to extract needs the extractor: code repositories and code files take the LLM-free code route, and items an earlier run completed are skipped first, socognifyandadd-and-cognify(CLI and bindings) of a code project succeed without one. Anadd-and-cognifywhose every input is a document (text, or existing non-code files) is refused before the add, so nothing is stored; one with a directory, a code file or a URL among its inputs adds them, and fails only if an added item is a document (which stays in the dataset for a retry). A selection nothing is registered under (--extractororGRAPH_EXTRACTOR) is still refused up front, except that the bindings’cognifyof code-only items does not checkGRAPH_EXTRACTOR. The bindings’improveandupdatestill fail this way, as doesrememberunlesscontent_type="code"; - an embedder with no embedding setting configured (provider and model at the
stock default, no
EMBEDDING_API_KEY, noEMBEDDING_ENDPOINT) runs on the local ONNX model (onnx,BGE-Small-v1.5, 384 dimensions). The model is downloaded on first use. The switch applies to every operation that embeds, search included, and follows the LLM: onceLLM_API_KEYis set, the configured embedder is back and no longer matches the vectors stored under the local model. Set the embedding settings explicitly to keep one embedder either way.
ComponentManager::llm_available() (see
Supported LLM providers):
the provider needs no key (LlmFactory::requires_api_key is false, as for
Bedrock; the mock LLM always counts) or LLM_API_KEY is set. Without one, setup still
succeeds and only a call that needs the LLM (a completion search, the llm
extractor chosen explicitly) fails. recall routes around the missing LLM
instead, and runs a completion type as only_context (see recall).
These settings keep the configuration as given (the LLM extractor and the
configured embedder), for runs with deliberately partial or fake provider
config:
Any
MOCK_EMBEDDING mock mode (zero, deterministic, …) keeps the
configured embedder. The
configured embedding.* values are what config get and the telemetry snapshot show,
while ComponentManager::effective_embedding (used by cognee-cli export to
label the vectors) reports the one in use.
Custom graph schema (per call)
A custom graph model is a per-call option, not a setting: there is no env var for it. The same goes forchunk_attachment.
The graph_model setting does not select it. The key registry does carry a
graph_model row (ConfigManager::set_graph_model, ConfigManager::set("graph_model", …),
cognee-cli config set graph_model …, the bindings’ config setters), but
nothing reads it: setting it succeeds and has no effect on cognify.
Pass the schema per call instead:
null and {} mean the default KnowledgeGraph. The CLI and the bindings
run CognifyConfig::validate before any side effect; a Rust caller runs it
itself. An invalid value fails with a validation error: an unknown attachment
(rejected when it is parsed), an attachment without a schema, a
schema that does not compile, or a schema combined with a graph_backend or
the cascade strategy. The bindings type-check the whole
options object: a wrongly-typed value for any known cognify option is an error,
and an unknown key is logged as a warning. See
the custom graph schema guide.
Ontology
Theontology section is registered by the ontology-resolver kind. Resolvers are
factories (OntologyResolverFactory) on the ComponentRegistry, selected by
ontology.resolver; an external crate adds one with register_ontology_resolver.
With no file path the no-op resolver is used, whatever the resolver id.
Only
rdflib is built in; an unregistered resolver id with a file path set is an
error. rdflib implements only fuzzy matching and warns on any other strategy.
The CLI’s --ontology-file overrides ontology.file_path for one run.
Code graph
Thecode_graph section is an engine section, registered with the kind
sections. It configures the deterministic code graph (cognee-code-graph),
which runs the external enola binary on
a repository and loads its snapshot as code nodes and typed edges.
Whether remote repositories may be cloned is the cognee-wide
allow_http_requests setting, and which local repository paths may be read
is allowed_local_file_roots: see
Outbound requests & local paths.
code_graph.snapshot_cache_max_entries and code_graph.snapshot_cache_ttl_secs
bound the process-wide cache of parsed code graphs the
CODE search type
reads (one entry per dataset and graph engine; least recently used evicted
first). An entry is served for the time limit unless a code-graph load, or a
delete, forget or graph prune, invalidates it first. A count of 0, or a time
limit that is not a finite positive number, falls back to the default; a
negative count is not a valid value (config set rejects it, and
CODE_GRAPH_CACHE_MAX_ENTRIES=-1 is ignored without a warning). The
cache is shared by every handle in the process: a handle whose config moves
the bounds off the defaults applies them when its search orchestrator is
built, and a handle left at the defaults does not reset bounds another handle
set.
code_graph.enola_path names the enola binary. When it is set, the file must
exist, or the load fails with EnolaNotInstalledError; a relative path is
resolved against the process’s working directory. When it is empty, enola is
looked up on PATH each time enola is run, and a missing binary
fails the same way. The Rust crates do not bundle enola: install the
enola-cli==0.5.1 wheel (pip install enola-cli==0.5.1) or the binary, and
put it on PATH or in ENOLA_PATH, wherever cognify runs.
code_graph.enola_timeout_secs bounds one enola --generate run. A run that
takes longer is killed and fails with EnolaSnapshotError. One run over a
dataset’s repositories (an enola cluster) gets this budget per repository,
capped at 3600 seconds but never below one repository’s budget. It must be a
positive number of seconds: config set accepts 0 or a negative number, but
the load then fails with a configuration error. From code, read the section with
Settings::code_graph().
code_graph.clones_dir is where remote git repositories are shallow-cloned:
the git URLs of remember(content_type="code") and the GitHub/GitLab
repository URLs add takes. It is always a local directory, even with S3
storage. Clones are reused across calls and refreshed on each; each branch
gets a directory of its own. An SDK, CLI or binding call reuses a clone whose
refresh failed. Cloning needs git on PATH.
A request a host serves over HTTP (a RepoSourceSettings with
api_request = true, Settings::api_repo_sources) is stricter: a failed
refresh is an error instead of a stale reuse; the clone directory name carries
an 8-hex hash of the credential-free URL (github.com-org-repo-1a2b3c4d), so
URLs that would otherwise map to one name (github.com/a/b-c and
github.com/a-b/c, or http:// and https://) never share a clone; git
follows no http redirect; and git is pinned (http.curloptResolve) to the
addresses the outbound check passed, so a DNS answer that changes after the
check cannot send it elsewhere. That pin needs git 2.37 or later: with an
older git such a clone is refused rather than made unpinned. A code
repository’s data id is keyed on its clone directory, so these names give
server rows ids of their own: a repository a server re-adds after upgrading is
a new row, and the old row and its old clone directory stay until the old row
is forgotten.
When a code repository row is forgotten, or its dataset deleted, the
dataset’s cluster snapshot (<repo>/.enola-<dataset_id>) is removed from the
repository, and a clone no remaining row points at is removed. Removing a
clone also removes the repository’s other branch clones beside it that no row
points at: a re-add on another branch moves the URL’s one row to that branch’s
clone and leaves the old clone in place until then. A re-add itself never
removes a clone.
Cognify failure handling
Read bycrates/cognify/src/failure.rs.
When a stage cannot process one chunk or one file it records the failure —
which stage, which file, which chunk, and why — instead of aborting the batch.
The report rides every stage output to CognifyResult.failures (on success) or
to CognifyError::RunFailed (when the run failed). Whether the run fails is
decided once, at the end, from two independent axes.
Each knob is a CognifyConfig builder, and each is also a key of the cognify
engine section, which Settings::cognify_config applies. They live in the
section, not as Settings fields, so GET /api/v1/settings keeps the response shape of Python cognee’s
settings route.
RAISE_INCREMENTAL_LOADING_ERRORS is Python’s own flag (default true), so one
.env configures both SDKs. Its polarity is Python’s: true (raise on the first
error) is FailFast, false is RunToEnd. It is a strict boolean:
true/1/yes/on is FailFast, false/0/no/off is RunToEnd, and
any other value is ignored with a warning, so a typo such as ture keeps the
FailFast default rather than silently switching to the costlier run-to-end
mode. Python raises only on a literal true (case-insensitive), so in a shared
.env use true or false: 1/yes/on (or a typo) mean FailFast in Rust
but run-to-end in Python. The other four are Rust-only (COGNEE_COGNIFY_ prefix). An unset value
leaves the default in place, and out-of-range values are ignored rather than
failing the process: a ratio outside (0, 1] or an unknown rollback scope logs a
warning, and a zero cap is dropped silently.
Axis 1 — when to stop. FailFast stops the failing stage from scheduling
further work once a failure is recorded; files that already completed still
travel down the rest of the pipeline. RunToEnd continues past failures and
decides at the end (a full run’s LLM cost for the complete failure list). Each
stage stops at its own loop boundary:
Graph extraction and summarization each send every chunk of the run through
one stream, with at most
max_parallel_extractions calls in flight and no
barrier between chunks_per_batch blocks, so they stop at the granularity of
that concurrency window. The two streams share one stop: the first failing
chunk, in either stream, closes the gate for both, so a failed extraction also
stops summary dispatch and vice versa. Undispatched chunks are skipped and
their files recorded as unreached, so a file is complete only when every one
of its chunks was dispatched and none failed. In-flight calls are not
cancelled and their results are collected, failures included, except after a
failed save that fails the run (under WholeRun or Nothing), which stops
both streams and aborts the calls in flight. Under FailedItems a failed save
fails only its file, and stops dispatch only under FailFast. On a run with fewer chunks than max_parallel_extractions,
every call is already in flight, so FailFast saves no calls. Which chunks were sent before the stop depends on timing, so the same
failing input can leave a different set of files unreached. A graph backend
(CognifyConfig::graph_backend) is still handed chunks_per_batch chunks per
call, one call at a time, and stops after the call that failed. A tolerated
summarization failure does not close the gate.
Under FailFast + FailedItems that window decides how much survives: a
file is kept only if every one of its calls finished, so every file with a
chunk beyond the window is unreached. Each file is saved — and, with
incremental_loading, marked complete — as soon as its last result is in, so
every file that completed before the stop is kept, even though the run then
errors. With 32 calls in flight, a failure at chunk 40 of a 1,500-chunk run
keeps the files whose calls had all come back by then. To keep every file that
succeeded, use RunToEnd + FailedItems
(cognify.raise_incremental_loading_errors=false).
LLM graph extraction no longer logs a Processed graph extraction batch i/n
line per batch (a graph backend still does). It logs graph extraction: N of M chunks returned (custom graph extraction: … on the custom-graph path) at
most every 30 seconds, and the default path logs one Extracted graphs from N of M chunks (K never dispatched) line at the end.
Axis 2 — what to sweep. WholeRun removes everything the run created;
FailedItems removes only the contributions of the files the run did not
complete and keeps the rest. An unset rollback_scope follows
incremental_loading: FailedItems by default, WholeRun with
incremental_loading off (nothing is marked then, so there is nothing to
keep). Set COGNEE_COGNIFY_ROLLBACK_SCOPE=whole_run for the whole-run end
state with incremental loading on. From code, CognifyConfig::rollback_scope
is an Option<RollbackScope> (None follows incremental_loading);
CognifyConfig::effective_rollback_scope() returns the resolved scope. This
is a breaking change: the default used to be WholeRun whatever
incremental_loading said, and the field was a plain RollbackScope.
Under FailedItems each file is completed as soon as it is saved: the
document stage saves a file once all its results are in and, with
incremental_loading, marks it complete right away; a code item is completed
once its graph is loaded; a DLT row only once the post-run step has written its
foreign-key edges. A completed file is kept whatever happens to the run
afterwards:
- No item failed: the run completes and returns
Ok. - An item failed, or a failure hit outside one file’s own work (a failed
post-run step, a cancellation): the run is recorded
ERROREDand returnsErrcarrying the report, and removes everything it wrote except what the files it completed own. Run-level rows no kept file stands beside, such as a DLT schema node, go too. SelectWholeRunto remove the completed files as well.
incremental_loading
nothing is marked, so kept files are processed again by the next run. The
removal also takes a type, structural edge or ontology-first entity that only
the removed files declared. It binds no list of files, so it works whatever the
number of kept or removed files: the kept files’ rows are set aside under a
holding run id, the run is removed whole, and they are moved back. The edge
evidence of the files an errored run kept is detached from that run, so
include_references still cites it.
A third variant, Nothing, removes nothing and is not
selectable from configuration (nothing/none are rejected like any unknown
value, from the env var or the cognify section key); it is reachable only via
CognifyConfig::with_rollback_scope(RollbackScope::Nothing), because a run that
wrote graph edges and died before the vector stage leaves orphans a retry does
not repair: the retry finds those edges already in the graph and only claims
them (an ownership row, no edge or vector write). Only cognee-cli edge-reindex --apply
(reindex_edge_types) writes the missing points, or a later run that writes a
new edge with the same text. After a stop — a FailFast failure or a failed
save — a Nothing run saves nothing more: the files saved before the stop
keep their artifacts and get no completion marker, and complete files waiting
behind the stop are discarded.
Any combination that sweeps and ends
ERRORED returns Err — every
combination, FailedItems included, whenever an item failed.
CognifyResult.failures of an Ok run lists only tolerated summarization
failures and items left unreached because no document type matches them. A sweep removes an artifact only when nothing outside
the swept scope still claims it (another run, another dataset, a pre-ownership
row, or a surviving file in the same run). Cancellation is swept too, though
there is no caller-facing cancel handle yet, and dropping the cognify()
future runs no sweep.
Per-stage policy.
The failure ratio (
FailureReport::chunk_failure_ratio, failed chunks over
the run’s chunks) is still reported but no longer decides anything: every
scope fails the run on any failed item, so a re-run that stops at the same bad
file never reports success. COGNEE_COGNIFY_MAX_CHUNK_FAILURE_RATIO is still
read and validated so existing configuration loads. The report cap bounds the
individual entries listed (and the error message); totals, the failed-file set and
counters are never capped. A run that dies in a persistence stage loses the
report of failures collected earlier (a persistence error that fails the run
keeps its own CognifyError variant). Under FailedItems one file’s failed
save is not such an error: it is a FailureStage::Persistence entry in the
report.
Completion markers and incremental loading
incremental_loading (default on) is live. Every data item a run finished
is marked complete on its Data row — under FailedItems as soon as the item
is saved, under WholeRun once the whole run succeeded — under
pipeline_status["cognify_pipeline"][<dataset id>] = "DATA_ITEM_PROCESSING_COMPLETED" — Python’s format byte for byte, so the two
SDKs can share a database. The next run reads those markers before it builds a
pipeline and skips items already carrying one: they are not classified, chunked,
or sent to an LLM.
- Re-cognifying an already-complete dataset is a no-op. The call returns
Okwithalready_completed = trueand empty payloads, and writes its ownSTARTED/COMPLETEDpair. (Previously every cognify re-processed everything.) - A failed run keeps only the marks of the items it completed (none under
WholeRunorNothing), and a sweep clears the markers of every item it rolled back, so the next run redoes exactly the work that was lost. - A run with failed files leaves them unmarked (and errors), so the next run has exactly the failed files to redo.
STARTED /
COMPLETED pair (a fresh pipeline_run_id; STARTED carries only the run’s
recovery_lock, COMPLETED is {}). Rust skips the items before it
builds the pipeline, so the cognify entry point writes the pair itself. There is
no pipeline-cache gate any more (use_pipeline_cache was removed; see
Serialization and recovery of pipeline runs).
To reprocess everything on every run, set with_incremental_loading(false).