Skip to content

Conversation

@longcw
Copy link
Contributor

@longcw longcw commented Feb 6, 2026

  • clean up the old agent's activity when the session is closed during an AgentTask
  • fix deadlock issue when session closes during tool execution but before waiting for AgentTask

Open with Devin

@chenghao-mou chenghao-mou requested a review from a team February 6, 2026 06:14
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 6 additional findings.

Open in Devin Review

await self._activity.pause(blocked_tasks=blocked_tasks or [])
await activity.pause(blocked_tasks=blocked_tasks or [])

self._activity = self._next_activity
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

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.

2 participants