Reject incomplete structured LLM streams - #85
Merged
Conversation
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.
Problem
OpenRouter could end a streamed structured response after only a JSON prefix such as
{ "character":. StobeServer treated any non-empty HTTP 200 stream as successful, then fell back to speaking and persisting the raw fragment.Root cause
error,finish_reason, andnative_finish_reasonmetadatamessageChanges
Compatibility
No database migration or configuration change. Existing plain-text fallback and usable partial structured responses remain supported.
Validation
connector/openaijson.php,lib/chat_helper_functions.php,tests/structured_dialogue_contract_regression.phplengthand Gemini-styleMAX_TOKENSSTOBE_DB_NAME=stobe_test php tests/structured_dialogue_contract_regression.phpSTOBE_DB_NAME=stobe_test php tests/rechat_flow_regression.phpSTOBE_DB_NAME=stobe_test php tests/chat_flow_regression.phpgit diff --checkDeployment
Not deployed.
Untested limits
No live OpenRouter request or in-game Kenshi retest was performed. If a provider fails after complete dialogue sentences have already streamed, those earlier sentences cannot be retracted; the failed completion is still rejected and no raw JSON fallback is accepted.