fix: _is_trivial_response no longer skips valid JSON responses (#24)#35
Closed
fazalpsinfo-cmyk wants to merge 1 commit into
Closed
fix: _is_trivial_response no longer skips valid JSON responses (#24)#35fazalpsinfo-cmyk wants to merge 1 commit into
fazalpsinfo-cmyk wants to merge 1 commit into
Conversation
…raLabs#24) Removed the naive text.startswith('{') and text.startswith('[') checks that caused all JSON-formatted responses to be classified as trivial. Lowered the code_char density threshold from 0.6 to 0.5 so that highly-symbolic but non-JSON responses like '{ } ( ) = ; : # | \ > <' are still correctly caught as trivial, while valid JSON is not. Updated test assertions to match new behavior. Fixes AltioraLabs#24
fazalpsinfo-cmyk
force-pushed
the
fix/is-trivial-response-json
branch
from
July 16, 2026 09:15
8cec33c to
12bff9d
Compare
abhay-2108
reviewed
Jul 16, 2026
abhay-2108
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for submitting this fix! We really appreciate the contribution. We have another open PR (#31) addressing the same issue that implements a deeper JSON parser check (_json_prose_word_count). This allows us to keep skipping pure data payloads like {"key": "value"} (to save on extraction LLM costs) while still extracting from JSONs containing actual natural language prose.
Because of that, we will be closing this PR in favor of #31, but thank you again for your time and help!
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.
_is_trivial_response()usedtext.startswith("{") or text.startswith("[")to classify all JSON responses as trivial — even valid structured data like{"answer": "..."}.Fix: Removed the two naive
startswithchecks. Responses with a high density of code/symbol characters ({}()=;:|#|\\><) are still correctly caught by the existingcode_count / len(text) > 0.6check on lines 170-174.Updated tests: The
test_is_trivial_json_starttest now assertsFalsefor valid JSON, matching the corrected behavior.Closes: #24
If you find this useful, consider supporting my work: https://buymeacoffee.com/muhamedfazalps