feedback_keys field of the request body. The response will return a pre-signed URL for each key, which your client can use to collect user feedback for the Agent Server run.
LangSmith uses feedback to continuously improve the implementation of your agent. To learn more about how feedback works in LangSmith, refer to LangSmith feedback.
How it works
- Create a run and include
feedback_keysin the request body. For example, when callingPOST /threads/{thread_id}/runs/stream, setfeedback_keysin the request body to: - The
feedbackobject from the response contains a pre-signed URL for each key. For example, thefeedbackobject is: - Request the returned URL (e.g.
POST /api/v1/feedback/tokens/{token_id}) to associate the feedback key with the trace generated from the Agent Server run. For more details, refer to the LangSmith API reference. - LangSmith associates the submitted feedback with the run using the selected feedback key (e.g.
user_likedoruser_disliked).
Call the streaming run API with feedback_keys
Create a run and parse the feedback object from the response.
- Python SDK
- JavaScript SDK
- cURL
Handle the streamed feedback event
The stream emits a feedback event like the following:
data matches one of the values you passed in feedback_keys. Each value is a generated URL your client can call to submit feedback for that run.
Submit feedback with the generated URL
When the user chooses a feedback option,POST to the corresponding URL. GET is also supported. See the LangSmith API reference for more details.
For example, if the user clicks a thumbs down button, call the user_disliked URL:
- POST
- GET
user_disliked.
Optimize feedback data model
Theuser_liked and user_disliked keys can also be modeled under a single key such as user_score.
For example:
- Use
key="user_score"withscore=1foruser_liked - Use
key="user_score"withscore=-1foruser_disliked
user_liked, user_disliked), while others may prefer a single numeric score (user_score) or a richer rubric with multiple feedback keys.
Productionize in a client UI
A productionized solution will expose the generated feedback URLs through your frontend instead of calling them manually. Example high-level implementation:- Create the run from your backend or frontend.
- Capture the
feedbackobject and store the returned URLs. - Render feedback controls such as thumbs up/down buttons and feedback forms.
- On feedback submission,
POSTorGETa feedback URL based on the user’s feedback intent. - Optionally disable the feedback controls after submission and show confirmation to the user.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.