fix: resolve three bugs in core agent and tool management (#1164 #1165 #1166)#1167
Open
Fruank4 wants to merge 3 commits intoagentscope-ai:mainfrom
Open
fix: resolve three bugs in core agent and tool management (#1164 #1165 #1166)#1167Fruank4 wants to merge 3 commits intoagentscope-ai:mainfrom
Fruank4 wants to merge 3 commits intoagentscope-ai:mainfrom
Conversation
|
lichuang34 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
added 2 commits
April 8, 2026 21:34
- StaticLongTermMemoryHook: inject retrieved memory at the beginning of the message list instead of appending it at the end, so the LLM receives context before the user query (fixes agentscope-ai#1164) - ToolGroupManager: replace non-thread-safe ArrayList with CopyOnWriteArrayList for activeGroups, and update setActiveGroups() and copyTo() to mutate the list in-place rather than reassigning the field, preventing race conditions in concurrent agent scenarios (fixes agentscope-ai#1165) - MessageUtils.extractRecentToolCalls: replace msg.getName().equals() with Objects.equals() to avoid NullPointerException when an assistant message has no name set (fixes agentscope-ai#1166)
The test was asserting memory message at index 1 (end), which matched the old buggy behavior. Update to assert index 0 (beginning) to align with the fix in agentscope-ai#1164.
4fcddee to
5317598
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Author
|
三个问题:空指针,并发安全,记忆反序 |
Author
|
给孩子过了吧 呜呜呜 |
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.
Summary
This PR fixes three bugs identified in the core library:
StaticLongTermMemoryHookinjects retrieved memory at the end of the message list instead of the beginning, degrading RAG qualityToolGroupManager.activeGroupsuses a non-thread-safeArrayList, causing race conditions in concurrent agent scenariosMessageUtils.extractRecentToolCallscalls.equals()onmsg.getName()without a null check, throwingNullPointerExceptionwhen an assistant message has no nameChanges
Fix #1164 —
StaticLongTermMemoryHook.javaSwap the insertion order so the memory
SYSTEMmessage is prepended before the input messages:Fix #1165 —
ToolGroupManager.javaReplace the non-thread-safe
ArrayListwithCopyOnWriteArrayListand updatesetActiveGroups()/copyTo()to mutate in-place rather than reassign the field:Fix #1166 —
MessageUtils.javaReplace
msg.getName().equals(agentName)withObjects.equals()to safely handlenullnames:Test plan
mvn test -pl agentscope-core)ConcurrentModificationExceptionwhen multiple agents modify tool groups concurrentlyNullPointerExceptionwhen assistant messages without names are present in memory