Skip to content

Comments

fix(llms): prevent parse_partial_json from dropping incomplete string values#20631

Open
jackjin1997 wants to merge 3 commits intorun-llama:mainfrom
jackjin1997:fix/parse-partial-json-drop-content
Open

fix(llms): prevent parse_partial_json from dropping incomplete string values#20631
jackjin1997 wants to merge 3 commits intorun-llama:mainfrom
jackjin1997:fix/parse-partial-json-drop-content

Conversation

@jackjin1997
Copy link

Fixes #20541. The current logic misclassified incomplete string values as keys in partial JSON objects, causing content loss during streaming. This update adds context-aware parsing to correctly handle partial values.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 5, 2026
if is_inside_string:
# Check if we are in an object and this is a key
prefix = new_s[: new_s.rindex('"')].rstrip()
print(f"DEBUG: prefix='{prefix}'")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: remove debug prints

check_import.py Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

You committed some debug scripts

Copy link
Collaborator

Choose a reason for hiding this comment

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

Im not sure if you meant to commit these changes

@logan-markewich
Copy link
Collaborator

Theres already a PR open for this actually, the other fix seems a bit more straightforward
#20542

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Feb 6, 2026
@logan-markewich
Copy link
Collaborator

@jackjin1997 Why do you have two PRs open for the same issue? lmao

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: parse_partial_json misclassifies incomplete string values and drops existing content

2 participants