cognee.session.add_feedback and cognee.session.delete_feedback.
Before you start:
- Complete Quickstart and Sessions
- Run searches with a
session_idso that Q&A entries are stored - Ensure caching is enabled
Record feedback on a session Q&A
- Run a search with
session_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 clear feedback, use
cognee.session.delete_feedback(session_id=..., qa_id=...). Bothadd_feedbackanddelete_feedbackreturnTrueon success,Falseif the entry was not found or the cache is unavailable.
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.
Feedback API Reference
add_feedback()
Attach a rating and optional text comment to a stored Q&A entry.
| Parameter | Type | Description |
|---|---|---|
session_id | str | Target session that contains the Q&A entry. |
qa_id | str | Target entry ID. You can get this value from entry.qa_id on a SessionQAEntry returned by get_session(). |
feedback_text | Optional[str] | Optional free-form feedback comment. |
feedback_score | Optional[int] | Optional integer rating from 1 to 5. |
user | Optional[User] | Optional session owner; resolves automatically when None. |
True if feedback was stored successfully, False if the entry was not found or the cache is unavailable.
delete_feedback()
Clear both feedback_text and feedback_score for an existing Q&A entry without deleting the entry itself.
| Parameter | Type | Description |
|---|---|---|
session_id | str | Target session that contains the Q&A entry. |
qa_id | str | Target entry ID whose feedback should be cleared. |
user | Optional[User] | Optional session owner; resolves automatically when None. |
True if feedback was cleared, False if the entry was not found or the cache is unavailable.
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.
Example
Sessions
Enable conversation memory with sessions
Sessions and Caching
How sessions and caching work