Repository navigation
fix(server): report cut-off /v1/responses replies as incomplete - #360
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
The Responses handlers ignored the backend finish_reason and always answered with status "completed". A reply stopped by the token limit or a content filter now has status "incomplete" with incomplete_details, and the stream ends with response.incomplete. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the backend stops a reply early (
finish_reasonlengthorcontent_filter),POST /v1/responsesstill answers"status": "completed", and the stream ends withresponse.completed. A client cannot tell a truncated answer, or truncated tool call arguments, from a full one.Cause:
buildResponsesToolResponsereceives a hardcoded"completed",writeResponsesToolStreamhardcodes both the status and the final event, and neither readsfinish_reason.Fix: both paths now follow the Responses API shape for a cut-off reply:
status: "incomplete"incomplete_details.reason:max_output_tokensforlength,content_filterotherwiseresponse.incompleteinstead ofresponse.completedReplies that finish with
stoportool_callsare unchanged. The status of the individual output items is also unchanged. The fallback branch for engines withoutChatCompletionProxieris not touched, since it gets no finish reason.Test:
TestResponsesReportsCutOffReplyAsIncompletecovers both builders; itslengthandcontent_filtercases fail without the change.go test ./internal/server -run Responsespasses.This change was prepared with AI assistance (Claude Code).