Skip to content

fix: _is_trivial_response no longer skips valid JSON responses (#24)#35

Closed
fazalpsinfo-cmyk wants to merge 1 commit into
AltioraLabs:mainfrom
fazalpsinfo-cmyk:fix/is-trivial-response-json
Closed

fix: _is_trivial_response no longer skips valid JSON responses (#24)#35
fazalpsinfo-cmyk wants to merge 1 commit into
AltioraLabs:mainfrom
fazalpsinfo-cmyk:fix/is-trivial-response-json

Conversation

@fazalpsinfo-cmyk

Copy link
Copy Markdown
Contributor

_is_trivial_response() used text.startswith("{") or text.startswith("[") to classify all JSON responses as trivial — even valid structured data like {"answer": "..."}.

Fix: Removed the two naive startswith checks. Responses with a high density of code/symbol characters ({}()=;:|#|\\><) are still correctly caught by the existing code_count / len(text) > 0.6 check on lines 170-174.

Updated tests: The test_is_trivial_json_start test now asserts False for valid JSON, matching the corrected behavior.

Closes: #24


If you find this useful, consider supporting my work: https://buymeacoffee.com/muhamedfazalps

…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
fazalpsinfo-cmyk force-pushed the fix/is-trivial-response-json branch from 8cec33c to 12bff9d Compare July 16, 2026 09:15

@abhay-2108 abhay-2108 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@abhay-2108 abhay-2108 closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants