Skip to content

fix: handle incomplete JSON in parse_response for Structured Output (…#7

Open
LuminaX-alt wants to merge 1 commit into
mainfrom
LuminaX-alt-patch-7
Open

fix: handle incomplete JSON in parse_response for Structured Output (…#7
LuminaX-alt wants to merge 1 commit into
mainfrom
LuminaX-alt-patch-7

Conversation

@LuminaX-alt
Copy link
Copy Markdown
Owner

openai#2486)

Summary

Fixes openai#2486 by improving parse_response to gracefully handle incomplete/truncated JSON when using Structured Output.

Changes

  • Added IncompleteResponseError for partial JSON responses.
  • Enhanced error detection for truncated responses.
  • Improved error messaging for structured output failures.

Why

Previously, parse_response failed silently with a generic JSONDecodeError, leaving users without actionable context. This fix makes errors explicit and easier to debug.

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Additional context & links

…penai#2486)

### Summary
Fixes openai#2486 by improving `parse_response` to gracefully handle incomplete/truncated JSON when using Structured Output. 

### Changes
- Added `IncompleteResponseError` for partial JSON responses.
- Enhanced error detection for truncated responses.
- Improved error messaging for structured output failures.

### Why
Previously, parse_response failed silently with a generic JSONDecodeError, leaving users without actionable context. This fix makes errors explicit and easier to debug.
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.

Incomplete responses are not handled by parse_response when using Structured Output

1 participant