AgentScope is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the bug
When using ReActAgent with parallel_tool_calls=True and AsyncSQLAlchemyMemory, I'm encountering a database integrity error when multiple tool calls execute concurrently. The error occurs because multiple _acting coroutines call memory.add() simultaneously, resulting in duplicate primary key conflicts.
To Reproduce
- Create a ReActAgent with
parallel_tool_calls=True
- Configure it to use
AsyncSQLAlchemyMemory
Expected behavior
Solve this problem
Error messages
sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'user_913e9801-user_913e9801_itinerary-dEvmWpbijBSmoA84LoK4RY' for key 'PRIMARY'")
[SQL: INSERT INTO message (id, msg, session_id, `index`) VALUES (%s, %s, %s, %s)]
[parameters: [('user_913e9801-user_913e9801_itinerary-dEvmWpbijBSmoA84LoK4RY', '{"id": "dEvmWpbijBSmoA84LoK4RY", "name": "system", "role": "system", "content": [{"type": "tool_result", "id": "call_ab693550cc4b4499b74d47", "name": ... (9 characters truncated) ... light", "output": [{"type": "text", "text": "\\u67e5\\u8be2\\u822a\\u73ed\\u6210\\u529f"}]}], "metadata": {}, "timestamp": "2026-03-28 16:05:41.744"}', 'user_913e9801_itinerary', 9), ('user_913e9801-user_913e9801_itinerary-3k9tYqZvmze59zZJ4GEnHC', '{"id": "3k9tYqZvmze59zZJ4GEnHC", "name": "system", "role": "system", "content": [{"type": "tool_result", "id": "call_3f95f8ff924e43aaaaccc0", "name": ... (1 characters truncated) ... "plan", "output": [{"type": "text", "text": "\\u89c4\\u5212\\u884c\\u7a0b\\u6210\\u529f"}]}], "metadata": {}, "timestamp": "2026-03-28 16:05:41.752"}', 'user_913e9801_itinerary', 9)]]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
Environment (please complete the following information):
- agentscope==1.0.16
- fastapi[standard]==0.135.1
- uvicorn[standard]==0.41.0
- pydantic==2.12.5
- aiomysql==0.3.2
- pyyaml==6.0.1
- qdrant-client==1.17.0
- Python Version: [e.g. 3.12]
- OS: [e.g. windows]
Additional context
Add any other context about the problem here.
AgentScope is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the bug
When using ReActAgent with
parallel_tool_calls=Trueand AsyncSQLAlchemyMemory, I'm encountering a database integrity error when multiple tool calls execute concurrently. The error occurs because multiple _acting coroutines call memory.add() simultaneously, resulting in duplicate primary key conflicts.To Reproduce
parallel_tool_calls=TrueAsyncSQLAlchemyMemoryExpected behavior
Solve this problem
Error messages
Environment (please complete the following information):
Additional context
Add any other context about the problem here.