cognee.session.add_feedback and cognee.session.delete_feedback.
Before you start:
- Complete Quickstart and Sessions
- Run
recall()with asession_idso that Q&A entries are stored - Ensure caching is enabled
Record feedback on a session Q&A
- Run
recall()withsession_idso the interaction is stored. - Get the session history with
cognee.session.get_sessionand identify theqa_idof the entry you want to rate. - Call
cognee.session.add_feedbackwith thatqa_id, and optionallyfeedback_textandfeedback_score(1–5). - To make feedback influence future retrieval, run
improve()with the relevantsession_ids. If you are already writing new content withremember(),self_improvement=Truecan trigger this in the background automatically. - To clear feedback, use
cognee.session.delete_feedback(session_id=..., qa_id=...). Bothadd_feedbackanddelete_feedbackreturnTrueon success andFalseonly when the entry was not found or caching is disabled — every other failure raises, see Return contract and errors.
get_session returns a list of SessionQAEntry objects. Each entry has: qa_id, question, answer, context, time, feedback_text, feedback_score. Entries are in chronological order (oldest first); use entries[-1] for the most recent. Pass optional user for multi-tenant or permission-scoped usage.
The per-call
feedback_influence defaults to the DEFAULT_FEEDBACK_INFLUENCE
environment variable, which is 0.0 (off) by default — so the learned feedback
signal does not change ranking until you opt in. Set DEFAULT_FEEDBACK_INFLUENCE
(e.g. 0.1) to activate the signal globally, or pass feedback_influence per call
to recall() / search() to override it. Setting it back to 0.0 restores the
prior baseline.Personalize ranking per user
The feedback weights above are a global signal: every user’s ratings move the same weights for everyone. To let one user’s ratings nudge only that user’s results, turn on per-user preference personalization:-
Enable it in your
.env— it is off by default: -
Rate answers. The same
add_feedback(..., feedback_score=1..5)call from above feeds personalization too; alternatively, withAUTO_FEEDBACKon, a rating is inferred when the user’s next message clearly judges the previous answer (“that was exactly right”). -
Run
improve()with the session — the same call that applies global feedback weights also folds the rated turns into that user’s preference weights. -
Recall again as the same user: ranking in graph, hybrid, and RAG completion is nudged toward
what they rated up, by at most
PERSONALIZATION_INFLUENCE(default0.3, i.e. 30%).
feedback_influence, there is no per-call knob: the nudge applies whenever a user is in
context and exactly one dataset resolves, and its strength is set by the
PERSONALIZATION_INFLUENCE environment variable. How ratings become weights, how they decay,
and how each retriever applies them is covered in
User Preferences.
Feedback API Reference
add_feedback()
Attach a rating and optional text comment to a stored Q&A entry.
Returns
True if feedback was stored successfully, False if the entry was not found or caching is disabled. See Return contract and errors.
delete_feedback()
Clear both feedback_text and feedback_score for an existing Q&A entry without deleting the entry itself.
Returns
True if feedback was cleared, False if the entry was not found or caching is disabled. See Return contract and errors.
When calling add_feedback(), provide at least one of feedback_text or feedback_score. If you pass feedback_score, it must be an integer between 1 and 5.
Return contract and errors
False means exactly two things: the Q&A entry was not found, or caching is disabled. It never means “something went wrong”.
Everything else raises instead of being reported as False — an unreachable cache, a misconfigured backend, or invalid parameters (an empty session_id or qa_id raises SessionParameterValidationError). Earlier releases wrapped these calls in a catch-all that returned False, so a rating recorded while the cache hiccuped was silently dropped and looked identical to a bad qa_id. The same contract applies to cognee.session.add_frequency_weights(), which records the graph nodes and edges an answer used so improve() can raise their frequency weights. Handle the two outcomes separately:
cognee-cli feedback add and cognee-cli feedback delete commands report the two cases separately and exit non-zero on both — a not-found entry names the ids and points at the CACHING setting, while an infrastructure failure surfaces the underlying error. Earlier releases exited 0 with a generic message in both cases, so scripts that only checked the exit status silently accepted lost feedback.
Example
Sessions
Enable conversation memory with sessions
Sessions and Caching
How sessions and caching work
Improve
Enrich the graph and bridge session memory