fix(memory): serialize concurrent writes in AsyncSQLAlchemyMemory#1390
Open
umerkhan95 wants to merge 1 commit intoagentscope-ai:mainfrom
Open
fix(memory): serialize concurrent writes in AsyncSQLAlchemyMemory#1390umerkhan95 wants to merge 1 commit intoagentscope-ai:mainfrom
umerkhan95 wants to merge 1 commit intoagentscope-ai:mainfrom
Conversation
Add asyncio.Lock via a _write_session() context manager to serialize all mutating operations on the shared AsyncSession. This prevents the IntegrityError caused by concurrent _acting() coroutines in ReActAgent when parallel_tool_calls=True (agentscope-ai#1381).
|
|
qbc2016
reviewed
Apr 2, 2026
Member
qbc2016
left a comment
There was a problem hiding this comment.
Please sign our CLA and merge the latest main branch to pass the unittests.
Author
|
I am not able to authenticate the license agreement, its really buggy and does not authenticate through my Github account, I tried multiple times but the trigger to authentication is not hitting. The error: upstream connect error or disconnect/reset before headers. reset reason: connection termination This error comes after I authenticate to the license agreement. |
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.
AgentScope Version
1.0.18
Description
Fixes #1381 —
AsyncSQLAlchemyMemoryraisesIntegrityErrorwhenReActAgentruns withparallel_tool_calls=Truebecause multiple_acting()coroutines callmemory.add()concurrently on a sharedAsyncSession.This PR adds an
asyncio.Lockwrapped in a_write_session()async context manager that serializes all mutating session operations (add,clear,delete,delete_by_mark,update_messages_mark) with automatic commit/rollback. Internal helpers remain lock-free since they're only called from within_write_session(). Read-only methods are left unlocked.Includes
test_concurrent_addthat fires 20 concurrentasyncio.gather-basedadd()calls and verifies message count and index contiguity.Checklist
pre-commit run --all-filescommand