fix(sdk): support async generator functions in control() decorator#116
Open
KazChe wants to merge 1 commit intoagentcontrol:mainfrom
Open
fix(sdk): support async generator functions in control() decorator#116KazChe wants to merge 1 commit intoagentcontrol:mainfrom
KazChe wants to merge 1 commit intoagentcontrol:mainfrom
Conversation
The control() decorator silently broke on streaming (async generator) functions — the standard pattern for LLM response streaming.This adds an async_gen_wrapper path that runs pre-check before the first chunk, yields chunks in real-time while accumulating output, and runs post-check on the full accumulated output after the stream completes. fixes agentcontrol#113
Author
|
Hihi, sdk-ts-ci check failin due to a missing SPEAKEASY_API_KEY secret that'snot available to fork PRs and unrelated to the changes in this PR (python sdk only) |
abhinav-galileo
approved these changes
Mar 13, 2026
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.
Summary
control()decorator, fixing crashes and silent bypasses when applied toasync deffunctions withyield— the standard pattern for LLM response streaming.Scope
@control()now correctly wraps async generator functions, preservinginspect.isasyncgenfunction()identityasync_gen_wrapperpath incontrol()that runs pre-check before first chunk, yields chunks in real-time while accumulating, and runs post-check on full accumulated output after stream completesRisk and Rollout
Testing
make check(lint + typecheck pass; server tests have pre-existing postgres failures unrelated to this change)Checklist