Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ private Mono<PreCallEvent> handlePreCall(PreCallEvent event) {

// Inject memory message at the beginning
List<Msg> enhancedMessages = new ArrayList<>();
enhancedMessages.addAll(inputMessages);
enhancedMessages.add(memoryMsg);
enhancedMessages.addAll(inputMessages);
event.setInputMessages(enhancedMessages);

return Mono.just(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,7 +34,7 @@ class ToolGroupManager {

private final Map<String, ToolGroup> toolGroups = new ConcurrentHashMap<>(); // group -> tools
private final Map<String, Set<String>> tools = new ConcurrentHashMap<>(); // tool -> groups
private List<String> activeGroups = new ArrayList<>();
private final List<String> activeGroups = new CopyOnWriteArrayList<>();

/**
* Create tool groups and record them in the manager.
Expand Down Expand Up @@ -324,7 +325,8 @@ public List<String> getActiveGroups() {
* @param activeGroups List of group names to mark as active
*/
public void setActiveGroups(List<String> activeGroups) {
this.activeGroups = new ArrayList<>(activeGroups);
this.activeGroups.clear();
this.activeGroups.addAll(activeGroups);

// Mark corresponding groups as active
for (String groupName : activeGroups) {
Expand Down Expand Up @@ -374,7 +376,8 @@ void copyTo(ToolGroupManager target) {
}

// Copy activeGroups list
target.activeGroups = new ArrayList<>(this.activeGroups);
target.activeGroups.clear();
target.activeGroups.addAll(this.activeGroups);
}

private boolean removeGroupFromToolIndex(String toolName, String groupName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.agentscope.core.message.MsgRole;
import io.agentscope.core.message.ToolUseBlock;
import java.util.List;
import java.util.Objects;

/**
* Utility methods for message processing and extraction.
Expand Down Expand Up @@ -51,7 +52,7 @@ public static List<ToolUseBlock> extractRecentToolCalls(List<Msg> messages, Stri

for (int i = messages.size() - 1; i >= 0; i--) {
Msg msg = messages.get(i);
if (msg.getRole() == MsgRole.ASSISTANT && msg.getName().equals(agentName)) {
if (msg.getRole() == MsgRole.ASSISTANT && Objects.equals(msg.getName(), agentName)) {
List<ToolUseBlock> toolCalls = msg.getContentBlocks(ToolUseBlock.class);
if (!toolCalls.isEmpty()) {
return toolCalls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ void testOnEventWithPreReasoningEventAndRetrievedMemories() {
resultEvent -> {
List<Msg> messages = resultEvent.getInputMessages();
assertEquals(2, messages.size());
assertEquals(MsgRole.SYSTEM, messages.get(1).getRole());
assertEquals(MsgRole.SYSTEM, messages.get(0).getRole());
assertTrue(
messages.get(1)
messages.get(0)
.getTextContent()
.contains("<long_term_memory>"));
assertTrue(
messages.get(1)
messages.get(0)
.getTextContent()
.contains("User prefers dark mode"));
})
Expand Down
Loading