Skip to main content
Feedback on search answers is handled via Sessions: you record Q&A in a session, then attach feedback to specific entries using cognee.session.add_feedback and cognee.session.delete_feedback. Before you start:

Record feedback on a session Q&A

  1. Run a search with session_id so the interaction is stored.
  2. Get the session history with cognee.session.get_session and identify the qa_id of the entry you want to rate.
  3. Call cognee.session.add_feedback with that qa_id, and optionally feedback_text and feedback_score (1–5).
  4. To clear feedback, use cognee.session.delete_feedback(session_id=..., qa_id=...). Both add_feedback and delete_feedback return True on success, False if 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.
import cognee
from cognee import SearchType

# Search with a session so the Q&A is stored
results = await cognee.search(
    query_text="What are the main themes in my data?",
    query_type=SearchType.GRAPH_COMPLETION,
    session_id="my_session",
)
print(results)

# Get session history; entries are chronological, so latest is entries[-1]
entries = await cognee.session.get_session(session_id="my_session", last_n=5)
latest = entries[-1]
qa_id = latest.qa_id

# Add feedback for that Q&A (feedback_score must be 1–5)
ok = await cognee.session.add_feedback(
    session_id="my_session",
    qa_id=qa_id,
    feedback_text="Very helpful and accurate",
    feedback_score=5,
)
# ok is True if the entry was found and updated