Answer Feedback

A thumbs up or down under an answer, with a short list of reasons for a thumbs down, and an optional Regenerate.

Pattern

≈ 603 tokens per use (tool 277 · guidance 266 · typical payload 60)How token costs are estimated

Example: Answer Feedback

What changed in the EU AI Act this year?

When to use

  • You finished a substantive answer (research, a plan, a recommendation) and want to know how it landed.
  • The host keeps ratings, or you'll use them to improve the next answer in the conversation.

When not to use

  • The reply is a line or a confirmation. A rating adds noise.
  • You're waiting for a decision. Show the Approval Request or a question instead.
  • It would appear under every message. Offer it once per substantive answer.

How it works

Two icon buttons (and a third for Regenerate, when you set regenerate). A thumbs up sends at once. A thumbs down opens a short list of reasons as chips, and Send sends the ones the user ticked, or none. After a rating the row is replaced by a one-line record, like "Thanks. Too long, Out of date.", and focus moves to it.

The reasons are a closed list, so the next turn gets something typed to act on instead of a bare "unhelpful". The defaults are Not accurate, Wrong source, Too long and Out of date; set reasons to what could actually be wrong with this answer (for a sourced answer: wrong source, out of date).

How the agent should use it

  • Name the likely failures in reasons, 2–6 of them, a few words each.
  • On a down rating, fix what was named (shorten, re-check sources, refresh) and don't ask why again.
  • On regenerate, answer the question afresh, differently from before. Set regenerate only when a second try is cheap.
  • Echo answerId (a message id) so a stored rating points at its answer.

Interaction

ControlSendsNotes
Thumbs uprate with rating: "up"Immediately
Thumbs downOpens the reasonsToggle it to close, or press Escape
Sendrate with rating: "down" and reasons (ids)reasons is empty when none were ticked
RegenerateregenerateOnce. Only shown with regenerate: true

Each result also carries answerId when you set one.

Installation

npx shadcn@latest add https://your-site.com/r/answer-feedback.json

Usage

lib/genui-catalog.ts
import { AnswerFeedback } from "@/components/genui/answer-feedback"

export const catalog = {
  rate_answer: AnswerFeedback,
} satisfies GenUICatalog
app/api/chat/route.ts
import { tool } from "ai"
import { answerFeedbackTool } from "@/components/genui/answer-feedback.schema"

const tools = {
  // No execute(): the call is completed by the user's rating in the UI.
  [answerFeedbackTool.name]: tool({
    description: answerFeedbackTool.description,
    inputSchema: answerFeedbackTool.inputSchema,
  }),
}

Schema

PropTypeNotes
answerIdstring?Which answer this rates. Echoed in the result
reasons{ id, label }[]?2–6, labels up to 28 characters. Default: not accurate, wrong source, too long, out of date
regeneratebooleanShow Regenerate. Default false

Host props: status, onResult, result and className.

Source

On this page