> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Feedback System

> Step-by-step guide to using feedback with Cognee sessions

Feedback on recall 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:**

* Complete [Quickstart](/getting-started/quickstart) and [Sessions](/guides/sessions)
* Run `recall()` with a `session_id` so that Q\&A entries are stored
* Ensure [caching](/core-concepts/sessions-and-caching) is enabled

## Record feedback on a session Q\&A

1. Run `recall()` 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 make feedback influence future retrieval, run [`improve()`](/core-concepts/main-operations/improve) with the relevant `session_ids`. If you are already writing new content with [`remember()`](/core-concepts/main-operations/remember), `self_improvement=True` can trigger this in the background automatically.
5. 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.

```python theme={null}
import cognee
from cognee import SearchType

# Run recall with a session so the Q&A is stored
results = await cognee.recall(
    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

# Push feedback into the graph
await cognee.improve(
    dataset="main_dataset",
    session_ids=["my_session"],
)

# Recall again with feedback_influence > 0 to surface the weighted results
improved_results = await cognee.recall(
    query_text="What are the main themes in my data?",
    query_type=SearchType.GRAPH_COMPLETION,
    feedback_influence=0.5,
)
print(improved_results)
```

## 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`.                                                   |

Returns `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`. |

Returns `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

```python theme={null}
cleared = await cognee.session.delete_feedback(
    session_id="my_session",
    qa_id="some-qa-id",
)
print("Feedback cleared:", cleared)
```

<Columns cols={3}>
  <Card title="Sessions" icon="message-square" href="/guides/sessions">
    Enable conversation memory with sessions
  </Card>

  <Card title="Sessions and Caching" icon="brain" href="/core-concepts/sessions-and-caching">
    How sessions and caching work
  </Card>

  <Card title="Improve" icon="sparkles" href="/core-concepts/main-operations/improve">
    Enrich the graph and bridge session memory
  </Card>
</Columns>
