-
Notifications
You must be signed in to change notification settings - Fork 2.8k
gracefully stop AgentTask and parent agents when session close #4730
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
base: main
Are you sure you want to change the base?
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.
| await self._activity.pause(blocked_tasks=blocked_tasks or []) | ||
| await activity.pause(blocked_tasks=blocked_tasks or []) | ||
|
|
||
| self._activity = self._next_activity |
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.
does it matter if there is a concurrent _aclose_impl call?
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.
this is a good question.
between the old activity close/pause to the new activity start/resume is sync codes, the closing guard is added in between to allow to close/pause the old activity since it has a lock internally and it's safe to close an activity twice.
if the session.aclose is called during next activity start/resume, the session._activity is already changed to the next activity, the aclose impl will also try to close the next activity, and since the start/resume acquired lock first, it will be started/resumed then closed immediately.
btw, I moved the closing guard to before adding agent handoff items so it won't be recorded as an handoff.
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.
One follow-up: we could still have double calls to drain though, right? Should we guard that as well?
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.
that's a good point, updated to avoid duplicated calls to the on_exit in drain.
Uh oh!
There was an error while loading. Please reload this page.