# Record feedback

Capture an end-user reaction to a specific reply — a thumbs-up/down, a rating, a reason — as a structured brizz.feedback event. Note: it emits telemetry only, and does not yet drive the session feedback badges, Positive/Negative filters, or the Overview feedback chart — those need the system-event mapping on the User feedback page.

`record_feedback` / `recordFeedback` captures an end-user's reaction to a specific reply — a 👍/👎, a numeric rating, a reason, a comment — as a structured `brizz.feedback` event. Because it's anchored by a [message id](/docs/instrument/message-ids.md) and/or a session id, the reaction can arrive out-of-band: minutes or days after the reply, even once the original trace has closed.

:::info
**Emitting vs. surfacing.** `record_feedback` / `recordFeedback` emits a structured `brizz.feedback` event into your telemetry — that is what it does today. It is **not** yet wired into the session feedback badges, the Positive/Negative session filters, or the Overview feedback chart. Those dashboard surfaces are driven by the system-event mapping flow on the [User feedback](/docs/instrument/user-feedback.md) page and don't consume `brizz.feedback` automatically.
:::

## Record feedback

Pair it with the message id you set on the turn. With a message in context, feedback defaults to that message.

:::tabs
:::tab[Python]

```python
from brizz import record_feedback, set_message_id, start_session

with start_session("session-123"):
    set_message_id(message.id)  # the id you'll reference this reply by

    reply = agent.run(prompt)
    record_feedback("thumbs_up")  # defaults to the current message
```

:::tab[Node.js]

```typescript
import { startSession, setMessageId, recordFeedback } from '@brizz/sdk';

await startSession('session-123', async () => {
  setMessageId(message.id); // the id you'll reference this reply by

  const reply = await agent.run(prompt);
  recordFeedback('thumbs_up'); // defaults to the current message
});
```

:::

## Out-of-band feedback

Feedback often arrives after the turn — a user clicks 👎 an hour later. Pass the `message_id` and/or `session_id` explicitly to attach it, from anywhere; no session scope needed.

:::tabs
:::tab[Python]

```python
from brizz import record_feedback

record_feedback("thumbs_down", message_id=message.id, session_id=session_id, reason="inaccurate")
```

:::tab[Node.js]

```typescript
import { recordFeedback } from '@brizz/sdk';

recordFeedback('thumbs_down', { messageId: message.id, sessionId, reason: 'inaccurate' });
```

:::

## Fields

- **`type`** *(required)* — canonical reaction, e.g. `"thumbs_up"` / `"thumbs_down"`. Emitted as `brizz.feedback.type`.
- **`score`** *(optional)* — numeric rating, e.g. 1–5. Emitted as `brizz.feedback.score`.
- **`reason`** *(optional)* — a category, e.g. `"inaccurate"` / `"unhelpful"` / `"unsafe"`.
- **`comment`** *(optional)* — free-text comment, masked like normal telemetry.
- **`source`** *(optional)* — origin, e.g. `"user"` / `"system"` / `"evaluator"`.
- **`message_id` / `messageId`** *(optional)* — target message. Defaults to the message in context; an explicit value wins.
- **`session_id` / `sessionId`** *(optional)* — target conversation. Defaults to the active session; an explicit value wins.
- **`attributes`** *(optional)* — arbitrary categorical facts, each emitted as `brizz.feedback.<key>`. Named fields above win on key collision.

If neither a message nor a session can be resolved, the call still emits but logs a warning — the feedback can't be attributed to a message or conversation.

## See also

- [Message IDs](/docs/instrument/message-ids.md) — tag the reply feedback attaches to.
- [User feedback](/docs/instrument/user-feedback.md) — the event-mapping flow that powers session badges, filters, and the Overview feedback chart today.
