Skip to content

fix: stream array-root JSON extraction#2308

Open
pragnyanramtha wants to merge 2 commits into
567-labs:mainfrom
pragnyanramtha:codex/stream-json-array-root
Open

fix: stream array-root JSON extraction#2308
pragnyanramtha wants to merge 2 commits into
567-labs:mainfrom
pragnyanramtha:codex/stream-json-array-root

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Describe your changes

Fixes the streaming JSON extractor so markdown/plain streaming responses whose root JSON value is an array are preserved as arrays instead of starting at the first object inside the array. The sync and async extractors now track both object and array delimiters while preserving the existing string/escape handling.

Added regression coverage for chunked markdown JSON streams with array roots in both sync and async paths.

Issue ticket number and link

N/A

Validation

  • uv run --extra dev pytest tests/test_utils.py tests/test_json_extraction.py tests/test_json_extraction_edge_cases.py tests/dsl/test_gemini_tools_async_streaming.py -q -> 63 passed, 2 skipped
  • uv run ruff format --check instructor/utils/core.py tests/test_utils.py -> passed
  • uv run ruff check instructor/utils/core.py tests/test_utils.py -> passed
  • git diff --check -> passed

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests.
  • If it is a core feature, I have added documentation.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 03:05
Copilot AI review requested due to automatic review settings May 17, 2026 03:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

…rray-root

# Conflicts:
#	instructor/utils/core.py
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