Skip to content

fix(process_response): use issubclass instead of isinstance for ParallelBase check#2058

Open
Mr-Neutr0n wants to merge 1 commit into567-labs:mainfrom
Mr-Neutr0n:fix/parallel-tools-isinstance-check
Open

fix(process_response): use issubclass instead of isinstance for ParallelBase check#2058
Mr-Neutr0n wants to merge 1 commit into567-labs:mainfrom
Mr-Neutr0n:fix/parallel-tools-isinstance-check

Conversation

@Mr-Neutr0n
Copy link

Summary

Fixes the bug where ParallelTools fails with:

'generator' object has no attribute '_raw_response'

Root Cause

In process_response.py, the code uses isinstance(response_model, ParallelBase) but response_model is a class (type), not an instance. Using isinstance() on a class type checks if that class object itself is an instance of a metaclass, which is not the intended behavior.

Before (incorrect):

if isinstance(response_model, ParallelBase):

After (correct):

if inspect.isclass(response_model) and issubclass(response_model, ParallelBase):

Changes

  • instructor/processing/response.py: Fixed both occurrences (line 266 and 384) of the incorrect isinstance check

Test Plan

This should resolve the error when using ParallelTools with models like Qwen3-VL.

Fixes #2049

…lelBase check

The response_model parameter is a class (type), not an instance. Using
isinstance() on a class checks if that class is an instance of a type,
which always returns False for user-defined classes.

Changed from:
  if isinstance(response_model, ParallelBase):

To:
  if inspect.isclass(response_model) and issubclass(response_model, ParallelBase):

This fixes the "'generator' object has no attribute '_raw_response'" error
when using ParallelTools with models like Qwen3-VL.

Fixes 567-labs#2049
@Mr-Neutr0n
Copy link
Author

Friendly follow-up - is there anything I can improve in this PR? Happy to address any feedback.

@Mr-Neutr0n
Copy link
Author

Friendly bump! Let me know if there's anything I should update or improve to help move this forward.

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.

bug in ParallelTools call, model: Qwen3-VL-4b-instruct, server: LM-Studio 0.4.1

1 participant