Concurrent turns in the same session #790
halfpasttense
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Yes, ADK does not support concurrent turns at the same time. We will put some enforcement in the session service, since the lock needs to be implemented at the server-side. @DeanChensj FYI |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Can we talk about how concurrent turns in the same session (user sends more than one message before previous message responses are fully completed) really don't work unless the agent is extremely basic and doesn't use state at all? I use state to pass data between my agents, so in a concurrent turn it just turns into a race condition where one turn clobbers the state of another turn.
The simplest fix to this is to not allow concurrent turns in the same session at all, and given how this doesn't work at all correctly with the current state of ADK, this should really be the default right now. But there isn't even a built in way to do this. So I made NonConcurrentRunner that simply uses a dictionary of locks keyed by the user+sessionId to serialize any concurrent turns.
To actually support concurrent turns ADK would need to create a copy of the state and event history when a turn starts that is used exclusively by that turn. Then at the end of the turn this copied state and event history would need to be merged back into the global source of truth. Merging events should be rather simple, but solving merge conflicts in state would not be. It could just default to last in, and then maybe provide a callback that developers could use to handle merge conflicts however they want.
Beta Was this translation helpful? Give feedback.
All reactions