Skip to main content
Version: v2.0

Rate an agent's answers

People who chat with an agent in Agenta can rate each of its answers with a thumbs up or a thumbs down and add a comment. Agenta stores each rating as an annotation. An annotation is a record that judges another record, such as an answer in a chat. You can read all annotations of one chat through the API.

Rate an answer in the chat​

When the agent finishes an answer, the row of buttons under the answer shows a thumbs up ("Good answer") and a thumbs down ("Bad answer") after the other buttons. Like the other buttons, they appear when you point at the answer or give it focus. On a phone, tap the answer. They are hidden while the answer is still streaming. An answer that failed or that you stopped also has them.

Click a thumb to rate the answer. The thumb fills, and Agenta saves the rating at once. A box opens under the row: "Want to say why? (optional)". Type a comment and click Send, or click Skip. The rating is saved in both cases. A filled thumb shows your comment when you point at it. If the save fails, the row shows "Could not save your feedback. Try again."

To change your rating, click the other thumb. Your comment stays. To remove your rating and its comment, click the filled thumb again. When you open the chat again later, your own thumbs are filled as you left them. You see only your own feedback in the chat. Other people in a shared chat give their own feedback on the same answers.

How feedback is stored​

Each person has one feedback on each answer. Changing the rating or the comment edits that feedback. Removing it deletes it. In rare cases, two saves at the same moment (for example, from two open tabs) can leave a second feedback record on the same answer.

The feedback is an annotation on one turn of the chat. A turn is one message from a person and the agent's answer to it. A chat is a session in the API. The feedback has these fields:

FieldValue
ag.references.evaluator.slugchat-feedback. Agenta creates this evaluator in the project the first time someone in the project rates an answer.
ag.annotation.scopeturn
ag.session.idThe id of the chat. It also fills the session_id column.
ag.turn.idThe id of the rated turn. It also fills the turn_id column.
ag.data.outputs.ratinggood or bad
ag.data.outputs.commentThe comment. It is "" when the person wrote none.
ag.annotation.authorThe person who gave the feedback: {"type": "person", "user_id": "<user id>"}.

Agenta also links the feedback to the span that the turn started from, and copies the references of the agent that answered (application, application_variant, application_revision). Tracing describes the general fields of all annotations.

The ag attributes of one feedback look like this (the ids are invented):

{
"annotation": {
"scope": "turn",
"author": {"type": "person", "user_id": "019d952f-0000-0000-0000-000000000001"},
"actor": {"type": "person", "user_id": "019d952f-0000-0000-0000-000000000001"}
},
"session": {"id": "4f0c2a1e-7b7d-4c55-9d0e-2b8f3f1a9c10"},
"turn": {"id": "9a8e6c2d-1f4b-4a7e-8c3d-5e6f7a8b9c0d"},
"data": {"outputs": {"rating": "bad", "comment": "I asked for one tool, not three."}},
"references": {
"evaluator": {"slug": "chat-feedback", "id": "019d952f-0000-0000-0000-000000000002"}
}
}

Read all feedback of one chat​

To read every annotation of one chat, query the spans that have the chat's session id and the ag.annotation attribute. The condition on ag.annotation leaves out the spans of the agent's runs, which have the same session id.

curl -X POST "$AGENTA_HOST/api/spans/query" \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey $AGENTA_API_KEY" \
-d '{
"filtering": {
"operator": "and",
"conditions": [
{"field": "session_id", "operator": "is", "value": "<session id>"},
{"field": "attributes", "key": "ag.annotation", "operator": "exists"}
]
}
}'

The response has a flat spans list. Each span carries the fields of the table above under attributes.ag.

  • The result holds chat feedback and every other annotation of the chat. To keep only chat feedback, keep the spans where attributes.ag.references.evaluator.slug is chat-feedback.
  • To read one turn only, add the condition {"field": "turn_id", "operator": "is", "value": "<turn id>"}.
  • A page holds 100 spans by default. When more spans remain, the response has a windowing object. Send it as windowing in the next request, and repeat until a response has no windowing. See Windowing.
  • A removed feedback is not in the result. A changed feedback appears once, with its latest values.

Who can see feedback​

Every project member whose role can read traces can read all feedback of the project through the span query. This includes feedback on private chats. A person with the role Member cannot read traces and sees only their own feedback, in the chat. See Role-Based Access Control.