-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow cancel out of the streaming result #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@handrew looks good! You can add unit tests to the tests/
directory. If you use codex/cursor/windsurf/chatgpt, they can suggest tests and probably even help you write them. You can run the tests locally via make tests
src/agents/result.py
Outdated
@@ -174,6 +185,7 @@ async def stream_events(self) -> AsyncIterator[StreamEvent]: | |||
try: | |||
item = await self._event_queue.get() | |||
except asyncio.CancelledError: | |||
self.cancel() # Ensure tasks are cleaned up if the coroutine is cancelled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary? cleanup still occurs outside of the loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose not, though the AI thought it was 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this
Thanks for the tip @rm-openai , I'll be sure to do that in the future, pretty neat. Anyway, added the test! |
@handrew Test looks good, but it doesn't look like the test is passing - seems like its an infinite loop. You may need to use Also lint is failing - could you fix plz? |
Used Thanks @rm-openai , this was fun. Any idea when I might be able to |
… of the loop anyway
@handrew I'm merging the PR now. Will probably cut a new release tomorrow morning, so should be able to upgrade then. You can also temporarily directly install from the latest code in this repo if you want, which will include your change
|
Fix for #574
@rm-openai I'm not sure how to add a test within the repo but I have pasted a test script below that seems to work