Skip to content

[Bug]: When user provides only part of the tool call result, ReactAgent still executes the all tools #649

@wuji1428

Description

@wuji1428

AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.

Describe the Bug

When ReactAgent starts HITL, it returns tools pending confirmation. If the user only provides partial tool call results(e.g., the user needs to cancel part of the tool call).

ReactAgent directly enters the acting function. Within the acting function's logic, all tools from the previous round are invoked again, which may lead to unexpected calls.

public static List<ToolUseBlock> extractRecentToolCalls(List<Msg> messages, String agentName) {
if (messages == null || messages.isEmpty()) {
return List.of();
}
for (int i = messages.size() - 1; i >= 0; i--) {
Msg msg = messages.get(i);
if (msg.getRole() == MsgRole.ASSISTANT && msg.getName().equals(agentName)) {
List<ToolUseBlock> toolCalls = msg.getContentBlocks(ToolUseBlock.class);
if (!toolCalls.isEmpty()) {
return toolCalls;
}
break;
}
}
return List.of();
}

Potentially problematic scenarios:

  1. The user only wants to cancel the invocation of some tools.
  2. Some tools are invoked successfully, while others are suspended; the user only provides partial tool results.

Unexpected Result

When resuming, all tools are still executed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions