fix(task): use acall for output conversion in async paths#5696
Merged
greysonlalonde merged 1 commit intomainfrom May 4, 2026
Merged
fix(task): use acall for output conversion in async paths#5696greysonlalonde merged 1 commit intomainfrom
greysonlalonde merged 1 commit intomainfrom
Conversation
iris-clawd
approved these changes
May 4, 2026
Contributor
iris-clawd
left a comment
There was a problem hiding this comment.
Clean async conversion pipeline. Reviewed the full diff:
Good:
_aexport_output→async_convert_to_model→ato_pydantic/ato_json— mirrors the sync dispatch exactly, just withacallinstead ofcall.- Shared logic refactored into
_build_messages,_coerce_response_to_pydantic, and_unpack_model_output— reduces duplication between sync/async paths nicely. asyncio.to_threadfor the function-calling JSON path (InternalInstructor.to_json) is the right call since that's sync-only.- Tests properly assert
acallis used (notcall) and that theto_threadoffload happens.
One nit: missing trailing newline at end of test_async_task.py (last line is mock_to_thread.assert_awaited_once_with(instructor.to_json) with no newline). Won't break anything but some linters care.
LGTM ✅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5230
Note
Medium Risk
Touches task execution/output conversion paths and adds new async conversion code; mistakes could cause incorrect structured outputs or unexpected blocking/behavior differences under async workloads.
Overview
Fixes async task output conversion to be natively non-blocking: async task execution and async guardrail retries now export structured outputs via new
Task._aexport_output()instead of the sync_export_output().Adds an async conversion pipeline in
utilities/converter.py(ato_pydantic,ato_json,async_convert_to_modeland helpers) that usesllm.acalland offloads the sync-onlyInternalInstructor.to_jsonviaasyncio.to_thread, plus refactors shared validation/unpacking logic.Extends async tests to assert the async conversion path never calls blocking
llm.calland that function-calling JSON conversion is threaded.Reviewed by Cursor Bugbot for commit d61dae8. Bugbot is set up for automated code reviews on this repo. Configure here.