Skip to content

fix: handle GEMINI_TOOLS in async streaming paths#2135

Merged
jxnl merged 1 commit into567-labs:mainfrom
aerosta:fix/gemini-tools-async-streaming
Mar 17, 2026
Merged

fix: handle GEMINI_TOOLS in async streaming paths#2135
jxnl merged 1 commit into567-labs:mainfrom
aerosta:fix/gemini-tools-async-streaming

Conversation

@aerosta
Copy link
Copy Markdown
Contributor

@aerosta aerosta commented Mar 8, 2026

Summary

This fixes a sync/async inconsistency in streaming JSON extraction for Mode.GEMINI_TOOLS.

In both PartialBase and IterableBase, the sync streaming path applies JSON extraction for both Mode.MD_JSON and Mode.GEMINI_TOOLS, but the async streaming path only handled Mode.MD_JSON. That means async Gemini tools streaming could skip the same extraction step that the sync path already applies.

Changes

  • updated instructor/dsl/partial.py so the async streaming path handles Mode.GEMINI_TOOLS
  • updated instructor/dsl/iterable.py so the async streaming path handles Mode.GEMINI_TOOLS

Tests

Added tests/dsl/test_gemini_tools_async_streaming.py covering:

  • sync JSON extraction from code blocks
  • async JSON extraction from code blocks
  • sync Mode.GEMINI_TOOLS triggering JSON extraction
  • async Mode.GEMINI_TOOLS triggering JSON extraction
python3 -m pytest tests/dsl/test_gemini_tools_async_streaming.py -v -p no:deepeval

@jxnl jxnl merged commit 41f050c into 567-labs:main Mar 17, 2026
@aerosta
Copy link
Copy Markdown
Contributor Author

aerosta commented Mar 17, 2026

Thank you

conjon42 pushed a commit to conjon42/instructor that referenced this pull request May 7, 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