Repository navigation
Description
Describe the bug
Toolkit.callTool(ToolCallParam) returns a ToolResultBlock whose id and name are null, while Toolkit.callTools(...) stamps both correctly for the same tool and the same call.
Root cause: the two public entry points do not share the stage that stamps them.
Toolkit.callTools(...)→ToolExecutor.executeAll(...)→executeWithInfrastructure(...), which applies.map(result -> result.withIdAndName(toolCall.getId(), toolCall.getName())).Toolkit.callTool(param)→ToolExecutor.execute(param)directly, which bypassesexecuteWithInfrastructure(...)entirely.
withIdAndName(...) is called in exactly two places in ToolExecutor, both inside executeWithInfrastructure(...), so nothing on the callTool path ever stamps the result.
This matters because the id and name are what pair a result back to its call: ToolResultMessageBuilder.buildToolResultMsg(...) and the tool-call pairing model both key off them. A caller following the usage example in Toolkit.callTool's own javadoc gets back a block it cannot correlate.
To Reproduce
- Add the following test to
agentscope-core/src/test/java/io/agentscope/core/tool/CallToolIdNameReproTest.java:
package io.agentscope.core.tool;
import io.agentscope.core.message.ToolResultBlock;
import io.agentscope.core.message.ToolUseBlock;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
/** Repro: Toolkit.callTool vs Toolkit.callTools — id/name stamping on the returned block. */
class CallToolIdNameReproTest {
static class EchoTools {
@Tool(name = "echo", description = "Echoes back")
public String echo() {
return "ok";
}
}
private static ToolUseBlock call(String id) {
return ToolUseBlock.builder()
.id(id).name("echo").input(Map.of()).content("{}").build();
}
@Test
void compare() {
Toolkit toolkit = new Toolkit();
toolkit.registerTool(new EchoTools());
ToolResultBlock viaCallTool = toolkit
.callTool(ToolCallParam.builder().toolUseBlock(call("call-single")).build())
.block();
List<ToolResultBlock> viaCallTools =
toolkit.callTools(List.of(call("call-batch")), null, null, null).block();
ToolResultBlock batch = viaCallTools.get(0);
System.out.println("REPRO callTool id=" + viaCallTool.getId()
+ " name=" + viaCallTool.getName() + " state=" + viaCallTool.getState());
System.out.println("REPRO callTools id=" + batch.getId()
+ " name=" + batch.getName() + " state=" + batch.getState());
}
}- Run it from the repository root:
mvn -pl agentscope-core test -Dtest=CallToolIdNameReproTest -Dsurefire.failIfNoSpecifiedTests=false
Expected behavior
Both entry points stamp the result identically:
REPRO callTool id=call-single name=echo state=RUNNING
REPRO callTools id=call-batch name=echo state=RUNNING
Error messages
No exception is thrown. Actual output on main at c5db8f72:
REPRO callTool id=null name=null state=RUNNING
REPRO callTools id=call-batch name=echo state=RUNNING
Environment (please complete the following information):
- AgentScope-Java Version: 2.0.3-SNAPSHOT (reproduced on
mainat commitc5db8f72) - Java Version: 25 (the issue is version-independent)
- OS: macOS (the issue is OS-independent)
Additional context
The stale javadoc on ToolExecutor.execute(...) suggests how the paths drifted apart — it still reads:
/**
* Execute a single tool call with full infrastructure support.
*/
Mono<ToolResultBlock> execute(ToolCallParam param) {but execute(...) is the method that applies none of it; executeWithInfrastructure(...) is where the infrastructure lives, and it is private. This looks like an incomplete extraction: executeAll(...) was repointed at the new wrapper and Toolkit.callTool(...) was left on the inner method.
Beyond the missing id/name, the same divergence means the callTool path also skips applyScheduling, applyTimeout, applyRetry and applyShutdownGuard. The practical consequences are that a configured ExecutionConfig timeout and retry policy are silently inert for direct calls, and a tool invoked this way is not covered by the graceful-shutdown guard. I have kept this report scoped to the id/name defect because it is unambiguous and independently verifiable; the retry behaviour overlaps with #2829, whose author notes they are preparing a fix in this area.
Two notes for whoever picks this up:
- If the intended contract is that
Toolkit.callTool(...)is a deliberately thin, infrastructure-free entry point, then the id/name stamping and theexecute(...)javadoc should still be corrected, and the difference documented onToolkit.callTool(...)so callers are not surprised. - Repointing
Toolkit.callTool(...)atexecuteWithInfrastructure(...)would fix all of the above at once, but it is an observable behaviour change for external callers currently relying on the no-timeout semantics, so it likely belongs in a minor release rather than a patch.
Nothing in the repository calls Toolkit.callTool(...) today — the only occurrences are the usage examples in its own javadoc — so the exposure is entirely to external users following the documented example.
Activity
oss-maintainer commentedon Sep 12, 2026
Issue Evaluation
Category:
bug| Status: ConfirmedVerified against
main@7399ed61.Root cause: the two public entry points in
Toolkitdo not share the stage that stampsid/name.agentscope-core/src/main/java/io/agentscope/core/tool/Toolkit.java:490-492—callTool(ToolCallParam)delegates straight toToolExecutor.execute(param).Toolkit.java:511-525→ToolExecutor.java:323-324,340-341—callTools(...)goes throughexecuteAll(...), which routes each call throughexecuteWithInfrastructure(...).agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java:398—withIdAndName(toolCall.getId(), toolCall.getName())is applied only insideexecuteWithInfrastructure(...); theexecute()/executeCore()path (lines 167-291) never stamps the block.ToolExecutor.java:391-394—applyScheduling,applyTimeout,applyRetry,applyShutdownGuardlive in the same wrapper, so thecallToolpath skips them too: a configuredExecutionConfigtimeout/retry is silently inert and the call is outside the graceful-shutdown guard.ToolExecutor.java:162— the stale javadoc ("Execute a single tool call with full infrastructure support") confirms the extraction was left half-done, as the report suggests.Your analysis of the divergence is accurate, including that
ReActAgentusescallTools(...)(ReActAgent.java:3453,3467), so nothing in-tree hits the broken path today.Impact: latent — zero in-repo callers, but external users following the javadoc example on
Toolkit.callTool(...)get aToolResultBlockthey cannot correlate back to the tool call, sinceToolResultMessageBuilder.buildToolResultMsg(...)and tool-call pairing key offid/name. Severity: medium (low while latent, high once the documented API is adopted).One decision needed before a fix is proposed — which contract is intended?
callTool(...)is a full-featured entry point: repoint it atexecuteWithInfrastructure(...). This fixes id/name, timeout, retry and shutdown guard in one change, but it is an observable behaviour change for callers that currently get no-timeout semantics.callTool(...)stays deliberately thin: stamp id/name on theexecute(...)path only, correct theToolExecutor.execute(...)javadoc, and document the infrastructure gap onToolkit.callTool(...).We would rather not pick for you: option 1 may belong in a minor release rather than a patch, and option 2 leaves the timeout/retry surprise in place. Retrying on tool failure is deliberately out of scope here since it overlaps #2829.
Please reply with the intended option (or
needs-discussion) and we will generate a fix proposal accordingly.Automated evaluation by github-manager-bot
anirbandas18 commentedon Sep 13, 2026
needs-discussion
KIM406-CMD commentedon Sep 24, 2026
Quick update: after discussion in #3130, the intended approach is the minimal fix first — the single-call path will preserve id/name on the returned ToolResultBlock, keeping the public callTool error contract unchanged. The full-infrastructure routing will follow in a separate PR. This issue will close automatically once #3130 merges.
fix(Toolkit): route callTool through executeWithInfrastructure so id/…
fix(Toolkit): route callTool through executeWithInfrastructure so id/…
fix(Toolkit): route callTool through executeWithInfrastructure so id/…
fix(Toolkit): route callTool through executeWithInfrastructure so id/…
aiyili commentedon Oct 21, 2026
Hi, I'd like to work on this. The evaluation pins the root cause:
Toolkit.callTool(ToolCallParam)bypassesexecuteWithInfrastructure, so id/name are never stamped. Plan: route the single-call path through the same stamping stage (or stamp at theToolExecutor.executeboundary), keeping infrastructure behavior identical between the two entry points, plus a regression test assertingcallToolreturns a block with non-null id/name matching the call. PR coming shortly.KIM406-CMD commentedon Oct 21, 2026
@aiyili Hi @aiyili, thanks for offering to take this on.
I already opened PR #3130 for this issue: #3130
It follows the same approach you outlined — routing the single-call path through
executeWithInfrastructuresoid/nameare populated consistently, plus regression tests assertingcallToolreturns a block with non-nullid/namematching the call.The PR is linked with
Closes #3114, and I'm currently resolving the remaining merge conflict inToolkitTest.java. Would you be open to collaborating by reviewing #3130 or suggesting changes there? That way we can avoid duplicate PRs. Happy to incorporate your feedback.fix(Toolkit): route callTool through executeWithInfrastructure so id/…
fix(core): route callTool through shared tool infrastructure (#3130)