text
stringlengths
0
59.1k
title: Feedback
---
# Feedback
Feedback lets you capture user ratings and comments tied to a trace. VoltAgent can create signed feedback tokens for each trace and attach them to assistant message metadata so you can submit feedback later from the UI.
<video controls loop muted playsInline style={{width: '100%', height: 'auto'}}>
<source src="https://cdn.voltagent.dev/docs/feedbacks-demo.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
<br/>
<br/>
## How it works
- Feedback is always linked to a trace_id.
- When feedback is enabled, VoltAgent requests a short-lived token from the VoltOps API and returns metadata.
- The metadata is added to the last assistant message so you can show a UI control and submit later.
Feedback metadata shape:
```json
{
"traceId": "...",
"key": "satisfaction",
"url": "https://api.voltagent.dev/api/public/feedback/ingest/...",
"tokenId": "...",
"expiresAt": "2026-01-06T18:25:26.005Z",
"provided": true,
"providedAt": "2026-01-06T18:30:00.000Z",
"feedbackId": "feedback-id",
"feedbackConfig": {
"type": "categorical",
"categories": [
{ "value": 1, "label": "Satisfied" },
{ "value": 0, "label": "Unsatisfied" }
]
}
}
```
## Best-practice state model
For production apps, use a hybrid approach:
- Keep feedback records in VoltOps as the source of truth.
- Use message metadata (`provided`, `providedAt`, `feedbackId`) as fast UI state for hiding feedback controls.
- After a successful feedback submit, persist the metadata state on the stored assistant message with `agent.markFeedbackProvided(...)`.
This keeps UX responsive and prevents feedback controls from reappearing after conversation reloads.
## Feedback keys (registry)
Feedback keys let you register a reusable schema for a signal (numeric, boolean, or categorical). The system stores keys per project and uses them to resolve `feedbackConfig` when you only pass `key`.
- If a key exists with `feedback_config`, it is reused when `feedbackConfig` is omitted.
- If a key does not exist and you pass `feedbackConfig`, the key is created automatically.
- If a key exists, the stored config wins. Update the key if you need to change the schema.
Manage feedback keys in the Console UI under Settings.
## Enable feedback in the SDK
You can enable feedback at the agent level or per request. A VoltOps client must be configured (environment or explicit) so tokens can be created.
### Agent-level default
```ts
import { Agent } from "@voltagent/core";
import { openai } from "@ai-sdk/openai";
const agent = new Agent({
name: "support-agent",
instructions: "Help users solve issues",
model: openai("gpt-4o-mini"),
feedback: true,
});
```
### Per-call feedback options
```ts
const result = await agent.generateText("Help me reset my password", {
feedback: {
key: "satisfaction",
feedbackConfig: {
type: "categorical",
categories: [
{ value: 1, label: "Satisfied" },
{ value: 0, label: "Unsatisfied" },
],
},
expiresIn: { hours: 6 },
},
});
const feedback = result.feedback;