Repository navigation
fix(core): route callTool through shared tool infrastructure - #3130
Conversation
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Routes the single-call path Toolkit.callTool through executeWithInfrastructure (new ToolCallParam-taking overload) so results keep id/name, plus two regression tests. The bug is real and the direction is right, but the change also swaps the error contract, threading, timeout and retry behaviour of a public API — please confirm the blast radius and cover the param-preservation claim in tests.
Findings
- [Warning]
Toolkit.java:495— publiccallToolsemantics change: errors become results, 5-min timeout + shutdown guard + scheduler switch, and retry enabled from toolkit config (double-execution risk for non-idempotent tools). - [Warning]
ToolkitTest.java:1308— no test forinput/param preservation (the overload's stated purpose); the error-path test does not exerciseonErrorResume; timeout/retry on this path untested. - [Info]
Toolkit.java:490— document the new behaviour on this public method. - [Info]
ToolExecutor.java:400— the two overloads are asymmetric in field preservation; clarify or unify. - [Info]
Toolkit.java:492— the merged config could be resolved once and shared withcallTools.
Suggestions
- Keep the good part minimal if you prefer a low-risk change: apply
.map(r -> r.withIdAndName(...))(and the matching error mapping) insideToolkit.callTool/ToolExecutor.execute(param)without pulling in scheduling/timeout/retry, then open a separate PR (with changelog + migration notes) for the full-infrastructure routing. - Note the merge order here differs from
callTools: no agent-levelExecutionConfigparticipates — worth stating explicitly so per-request config is not expected to apply. - CI is currently
BLOCKED(missing required review); CLA status is not reported by any commit status check on this head, so a maintainer may want to confirm the contributor has signed before merge.
Automated review by github-manager-bot
| ExecutionConfig.mergeConfigs( | ||
| config.getExecutionConfig(), ExecutionConfig.TOOL_DEFAULTS); | ||
|
|
||
| return executor.executeWithInfrastructure(param, effectiveConfig); |
There was a problem hiding this comment.
[Warning] Compatibility — callTool semantics change silently for a public API.
Routing callTool through executeWithInfrastructure does more than populate id/name: it also (a) converts failures into a successful Mono carrying ToolResultBlock.error(...) (onErrorResume in executeWithInfrastructure), so caller-side onErrorResume / retryWhen / try-catch around callTool(...).block() no longer sees exceptions; (b) applies the 5-minute TOOL_DEFAULTS timeout and applyShutdownGuard; (c) moves execution onto the toolkit scheduler via applyScheduling; (d) enables retry if config.getExecutionConfig() carries maxAttempts > 1 — that can double-execute non-idempotent tools for callers that never had retries on this path before.
The id/name regression itself is real and worth fixing. Could you make the blast radius explicit: split "attach id/name" from "apply full infrastructure", or at minimum document the new behavior in the javadoc + changelog so downstream (harness / extensions / studio) callers are not caught by surprise?
| @@ -488,7 +488,11 @@ | |||
| * @return Mono containing execution result | |||
| */ | |||
| public Mono<ToolResultBlock> callTool(ToolCallParam param) { | |||
There was a problem hiding this comment.
[Info] Please extend the javadoc of this public method. It currently only says "Execute multiple tools..." style docs; after this change callTool applies scheduling, timeout, retry and shutdown guard and returns errors as results rather than Mono.error. Worth one paragraph, plus a note that the effective config is mergeConfigs(toolkitConfig, TOOL_DEFAULTS) (i.e. no agent-level config is honoured here, unlike callTools).
| */ | ||
| Mono<ToolResultBlock> executeWithInfrastructure( | ||
| ToolCallParam param, ExecutionConfig executionConfig) { | ||
| ToolUseBlock toolCall = param.getToolUseBlock(); |
There was a problem hiding this comment.
[Info] The two overloads are now asymmetric in field preservation. The 4-arg overload still rebuilds a fresh ToolCallParam from toolCall/agent/runtimeContext (so any input/emitter attached to an existing param is not carried through), while the new overload preserves the param verbatim. That is fine for today's call sites (executeAll only has the ToolUseBlock), but the doc comment here ("preserving all fields ... not silently discarded") reads as if the batch path had the same guarantee. Consider adding a note that the batch path intentionally constructs the param, or unify both to accept a ToolCallParam.
| .build(); | ||
|
|
||
| ToolResultBlock result = | ||
| toolkit.callTool(ToolCallParam.builder().toolUseBlock(toolCall).build()).block(); |
There was a problem hiding this comment.
[Warning] Tests cover the symptom but not the stated motivation. Both new tests assert id/name only. The PR description motivates the second overload by "preserving all fields from the original ToolCallParam (including input)" — there is no test that a ToolCallParam carrying input (or preset parameters / emitter) still reaches the tool unchanged, which is exactly the regression the overload guards against. Two more cases worth adding:
input/preset-parameter preservation throughcallTool(guards the overload split).- Timeout/retry actually taking effect on the
callToolpath (e.g. toolkit config with a smalltimeoutand a slow tool, asserting the error result still carriesid/name).
Also error_tool in SampleTools throws RuntimeException, so executeCore returns ToolResultBlock.error(...) for the caught case — the second test therefore does not really exercise the onErrorResume branch; a tool that propagates an error Mono would.
| public Mono<ToolResultBlock> callTool(ToolCallParam param) { | ||
| return executor.execute(param); | ||
| ExecutionConfig effectiveConfig = | ||
| ExecutionConfig.mergeConfigs( |
There was a problem hiding this comment.
[Info] Nit: effectiveConfig is recomputed on every call. config.getExecutionConfig() looks immutable here, so this could be resolved once (field or lazily-cached) and reused; the same merge is repeated in callTools. A small shared private helper would keep the two paths from drifting.
|
CLA Not Signed The Contributor License Agreement (CLA) check is currently pending on this PR ( @KIM406-CMD please sign the CLA via the CLA assistant badge in the comment above, or visit https://cla-assistant.io/agentscope-ai/agentscope-java. Once signed, the Automated check by github-manager-bot |
|
Thanks for the update — a quick correction on the CLA gate and the CI signal on this head. CLA: CI: the two failing jobs are Worth one re-run before concluding it is yours; if it reproduces on a clean Still open from my review (unchanged,
No action needed on the CLA item. Feel free to @mention me for a re-review once the above is addressed. Automated review by github-manager-bot |
|
This PR now conflicts with git fetch origin
git checkout fix
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseCI on this head also shows a failing/cancelled check — please re-run it after the rebase. This is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
|
Thanks for the detailed review and the follow-up — all points noted.
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
@oss-maintainer rebased onto upstream/main, ToolkitTest conflict resolved (kept both upstream's MCP propagateMeta tests and our callTool id/name tests). CI is fully green — ready for re-review! |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review after the rebase onto main (head f15d7894). The rebase is clean and CI is green, and the fix itself is correct: callTool was bypassing executeWithInfrastructure, so single-call results lost the withIdAndName(...) decoration the batch path applies, and the two new tests pin exactly that. CLA signed, no conflicts, and the ToolkitTest merge kept both upstream's propagateMeta cases and the new callTool ones.
I owe the author a correction from my previous review on this PR: I claimed routing through the infrastructure layer changes the error contract so that "errors become results". That was wrong — executeCore already ends in onErrorResume(...) → ToolResultBlock.error(...) plus a switchIfEmpty, both before this PR, so tool exceptions were already materialised as error values here. What the wrapping genuinely adds is the timeout / retry / shutdown-guard / scheduler layers, which is what the first finding below now describes.
- [Warning]
Toolkit.java:496—callToolnow inherits a timeout and, for toolkits configured withmaxAttempts > 1, a retry policy it previously never had. BecauseapplyTimeoutis applied beforeapplyRetry, a merely slow non-idempotent tool can be re-subscribed and run twice. DefaultTOOL_DEFAULTSismaxAttempts(1), so nothing changes out of the box, but it is an invisible semantic change on a public API. - [Warning]
ToolkitTest.java:1384— both new tests setinputon theToolUseBlock, soparam.getInput()is empty andexecuteCoretakes the fallback branch; theparam.input(...)precedence branch that the new overload's javadoc says it is protecting is untested. - [Info]
ToolkitTest.java:1301— the rebase drops an upstream comment line intestRegistrationPropagateMetaOverridesWrapperwith nothing replacing it.
None of these is a defect in the change itself, so this stays a COMMENT rather than a block: the first is a docs/test request, the second coverage hygiene, the third a one-line restore. Happy to approve once the timeout/retry semantics are stated on the method.
Automated review by github-manager-bot
| ExecutionConfig.mergeConfigs( | ||
| config.getExecutionConfig(), ExecutionConfig.TOOL_DEFAULTS); | ||
|
|
||
| return executor.executeWithInfrastructure(param, effectiveConfig); |
There was a problem hiding this comment.
[Warning] Routing callTool through executeWithInfrastructure also hands it a timeout and a retry policy it never had before. Worth being explicit about the real blast radius, because it is narrower but stranger than "errors become results":
- Tool exceptions are unaffected.
executeCorealready converts them intoToolResultBlock.error(...)values (and empty completions viaswitchIfEmpty) before any of these operators wrap it, so the newonErrorResumehere only catches what escapes outsideexecuteCore. TOOL_DEFAULTSismaxAttempts(1), andapplyRetryreturns the source unchanged formaxAttempts <= 1, so nothing changes for the default toolkit.- The risk is for a toolkit built with
ToolkitConfig.executionConfig(...)carryingmaxAttempts > 1(previously honoured only by the batch path). There, a tool that is merely slow now times out at 5 minutes and gets re-subscribed, so a non-idempotent tool can execute twice wherecallToolused to attempt it exactly once. Timeouts are the one signal that does reachapplyRetry, sinceapplyTimeoutis applied before it.
That is probably the behaviour you want, but it is a semantic change on a public API that a caller cannot see from the signature. Could you say so in the method javadoc (and the release notes) in one line, and add a test that pins maxAttempts > 1 + a slow tool on this path?
There was a problem hiding this comment.
Great point — you're right this is a meaningful semantic change worth calling out explicitly. Quick breakdown of what actually shifts:
Default behavior is identical: ExecutionConfig.TOOL_DEFAULTS.maxAttempts=1 → applyRetry returns the source unchanged. TOOL_DEFAULTS.timeout is also null by default. Users building toolkits with default configs see zero retry/timeout behavior change — these were silently ignored before, and now they're an explicit no-op.
The blast radius is narrow but real: A toolkit with executionConfig(...).maxAttempts(n) where n > 1 would previously see retry/timeout applied only to callTools(...) (batch). After this PR, callTool(...) inherits the same ExecutionConfig — consistency fix between the two paths, but that's exactly where your non-idempotent-tool concern lands: applyTimeout runs before applyRetry, so a slow non-idempotent call can get re-subscribed and execute twice, where before it would have been attempted exactly once.
Error handling was already consistent: You're right to correct my earlier "errors become results" framing — executeCore wraps exceptions in ToolResultBlock.error(...) before any of these operators touch it. onErrorResume here only catches what escapes outside executeCore, which is unchanged.
Action plan:
✅ I'll add a javadoc note to callTool(...) explicitly stating it now inherits the toolkit's ExecutionConfig (timeout + retry), matching callTools(...) semantics — this is the main gap.
🤔 For a maxAttempts > 1 + slow-tool test — that would introduce timing sensitivity to the CI suite. Would the javadoc clarification be sufficient here, or do you think a retry test is worth the CI cost? I'm happy to add it either way, just want to avoid flaky tests.
📝 Release notes note: agreed, that should mention the semantic change for anyone upgrading.
There was a problem hiding this comment.
@oss-maintainer Re the maxAttempts > 1 pinning test suggestion — I'd lean toward deferring this one. ExecutionConfig.TOOL_DEFAULTS is maxAttempts(1), and ToolExecutor.applyRetry short-circuits to the source unchanged for maxAttempts <= 1, so a default-constructed Toolkit will never hit the retry branch. Only users who explicitly set ToolkitConfig.executionConfig() with maxAttempts > 1 would observe it.
That means:
The vast majority of callers won't see a behaviour change (timeout is still 5 min, retry is a no-op)
A pinning test would need to mock a slow tool + a custom ToolkitConfig — fairly brittle
The single-param overload now shares the same executeWithInfrastructure path as the batch callTools; if we ever want retry coverage, testing it once on the batch path is sufficient
I see timeout/retry as a ToolkitConfig-level cross-cutting concern, so I'd rather not add per-entry-point pinning tests for it. WDYT?
| ToolUseBlock.builder() | ||
| .id("call-single-001") | ||
| .name("add") | ||
| .input(Map.of("a", 2, "b", 3)) |
There was a problem hiding this comment.
[Warning] Neither new test exercises the thing this overload's javadoc says it protects. Both build ToolCallParam.builder().toolUseBlock(toolCall).build(), so param.getInput() is empty and executeCore takes the else if (!toolCall.getInput().isEmpty()) branch at ToolExecutor.java:249 — the param.getInput() precedence branch at line 247 is never run.
So the tests correctly pin the id/name fix (the user-visible bug), but "preserving all fields from the original ToolCallParam (including input)" is currently guaranteed only by the fact that the new overload forwards param instead of rebuilding it from the ToolUseBlock. A future caller that reaches the 4-arg overload instead would silently drop a param-level input and every test here would still pass. A third case — same toolUseBlock, plus param.input(...) overriding one key — would make the claim actual rather than aspirational.
There was a problem hiding this comment.
Great catch — fixed with a new test testCallToolSingleParamInputPrecedenceOverToolUseBlock that now hits the exact precedence chain at ToolExecutor.java:247-249:
ToolUseBlock.input = {a:2, b:3} → would produce 5 if used
ToolCallParam.input = {a:100, b:200} → should win
Asserts 300 via ToolTestUtils.extractContent(...), plus verifies id/name are still correctly propagated
This is no longer just "forwarding param happens to preserve input" — the test forces both sources to disagree so a regression (silently dropping param.input) would fail immediately. javadoc's "preserving all fields from the original ToolCallParam (including input)" is now backed by a real execution path, not just the current implementation detail. Latest push has it.
| McpClientWrapperTestSupport.mockWrapper("external-mcp-client", true); | ||
| when(mcpClientWrapper.initialize()).thenReturn(Mono.empty()); | ||
| // Wrapper explicitly allows propagation; registration-level setting must win | ||
|
|
There was a problem hiding this comment.
[Info] This hunk is unrelated to the fix and looks like fallout from resolving the ToolkitTest conflict: it deletes a comment line belonging to upstream's propagateMeta test (// Wrapper explicitly allows propagation; registration-level setting must win) with nothing replacing it. The code below still depends on that intent, so the explanation is just lost.
Please restore it so the rebase doesn't quietly remove coverage documentation from someone else's test — easy to re-add by accident on the next conflict resolution.
There was a problem hiding this comment.
Done — restored // Wrapper explicitly allows propagation; registration-level setting must win above the propagateMeta(false) call. It's back in the latest push so the upstream test's intent is documented again.
77649a2 to
09fbe9f
Compare
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
The rebase adds an "Execution semantics" javadoc paragraph to callTool, restores the upstream propagateMeta comment, and strengthens ToolkitTest with .content(...) fields plus a new ToolCallParam.input precedence test. The previous documentation blocker is only partially cleared: the new javadoc covers timeout/retry/shutdown guard but still omits the exception-as-result contract and misattributes the global shutdown guard to ExecutionConfig. Verdict: comment.
Previous round's findings
Toolkit.java:496—callToolinherits timeout/retry/shutdown guard it previously lacked — resolved (now documented in the new "Execution semantics" javadoc).ToolkitTest.java:1384— newcallTooltests did not exerciseparam.inputprecedence — resolved (addedtestCallToolSingleParamInputPrecedenceOverToolUseBlock).ToolkitTest.java:1301— rebase dropped the upstreampropagateMetacomment — resolved (comment restored abovepropagateMeta(false).apply()).Toolkit.javajavadoc did not document scheduling/timeout/retry/shutdown-guard semantics and the exception-as-result contract — partially resolved (semantics paragraph added, but exception-as-result is still missing and shutdown guard is wrongly tied toExecutionConfig).
Findings
- [Warning]
agentscope-core/src/main/java/io/agentscope/core/tool/Toolkit.java:540— The added "Execution semantics" javadoc still omits the exception-as-result contract (errors and retry-exhausted timeouts are materialised asToolResultBlock.error(...)), and it incorrectly implies the shutdown guard is part of the toolkit'sExecutionConfigrather than the globalGracefulShutdownManager.
Verified good
callToolnow routes throughexecuteWithInfrastructureand mergesconfig.getExecutionConfig()withExecutionConfig.TOOL_DEFAULTS(Toolkit.java:568-573).TOOL_DEFAULTS.maxAttempts(1)makesapplyRetrya no-op by default (ExecutionConfig.java:163-164; ToolExecutor.java:543).applyTimeoutruns beforeapplyRetry, so a timeout can indeed trigger a retry whenmaxAttempts > 1(ToolExecutor.java:503-506).executeWithInfrastructurecatches remaining errors viaonErrorResumeand returnsToolResultBlock.error(...)(ToolExecutor.java:510 and the newToolCallParamoverload).ToolkitTestretains all upstreampropagateMetatests and addscallToolid/name, error id/name, andparam.inputprecedence coverage (ToolkitTest.java:1296-1448).
Automated review by github-manager-bot
| * | ||
| * <p><b>Execution semantics</b>: This method routes through the same | ||
| * infrastructure as {@code callTools}, so it inherits the toolkit's | ||
| * {@link ExecutionConfig} (timeout, retry, shutdown guard). Previously |
There was a problem hiding this comment.
The added 'Execution semantics' javadoc still omits the exception-as-result contract (errors and retry-exhausted timeouts are materialised as ToolResultBlock.error(...)), and it incorrectly implies the shutdown guard is part of the toolkit's ExecutionConfig rather than the global GracefulShutdownManager.
There was a problem hiding this comment.
@oss-maintainer Both points fixed in 0e646a4:
Shutdown guard → now correctly attributed to global GracefulShutdownManager (not ExecutionConfig)
Exception-as-result → added new paragraph documenting all three error paths funnel into ToolResultBlock.error(...)
Thanks for catching both!
|
@oss-maintainer The failing Windows build is unrelated to this PR — diff only touches agentscope-core/ (ToolExecutor, Toolkit javadoc, ToolkitTest). Ubuntu build ✅ passed. The failure is ManagedDefinitionMaterializerTest with FileSystemException: link: 客户端没有所需的特权。 — a Windows symlink permission issue that also reproduces on current upstream/main. |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-reviewed at 0e646a49. The delta over the head I reviewed last round is a single docs-only commit, and it clears the last outstanding item: the callTool javadoc now states the shutdown guard comes from the global GracefulShutdownManager (not ExecutionConfig) and documents the exception-as-result contract. The routing change itself is unchanged and correct. Verdict: approve.
Previous round's findings
Toolkit.java:540— javadoc omitted the exception-as-result contract and misattributed the shutdown guard toExecutionConfig— resolved by the new commit.
Verification
- Both claims in the new javadoc match the implementation:
applyShutdownGuardraces the execution againstGracefulShutdownManager.getInstance().getShutdownTimeoutSignal()(ToolExecutor.java:560-568), and every error path — including retry-exhausted timeouts — lands inonErrorResume(...)and returnsToolResultBlock.error(...)rather than signalling upstream (ToolExecutor.java:479-488and the newToolCallParamoverload). - The merged config is
ToolkitConfig.executionConfig()overExecutionConfig.TOOL_DEFAULTS;TOOL_DEFAULTSismaxAttempts(1), soapplyRetryshort-circuits and the default path adds the 5-minute timeout only (ExecutionConfig.java:163-164,ToolExecutor.java:514-518). The "no-op for retry by default" wording is accurate. - Docs-only delta: the previous head
d90b86b3of this PR was windows-green, so no behavioural change is introduced by this push.
CI note (not caused by this PR)
The current head shows build (windows-latest) failing on service-dataplane in ToolConfirmationCoordinatorTest.nonOwnerPersistsDecisionButOwnerPollerAloneReleasesContinuation ("Expecting value to be false but was true", 0.028s). The diff touches only Javadoc under agentscope-core/src/main/java/.../tool/, and the immediately preceding head of this same PR was green on that job, so this looks like a pre-existing timing-sensitive failure rather than a regression here. Worth a re-run before merge.
Non-blocking observation
The javadoc lists timeout, retry and shutdown-guard participation but not the scheduling hop: applyScheduling now subscribes the call on the toolkit executor (or boundedElastic), where Toolkit.callTool previously ran without that hop. Callers that pin context to the calling thread are affected, so mentioning it in the same paragraph would make the semantics section complete.
Automated review by github-manager-bot
|
Thanks for the thorough review and the approve! I'll add the scheduling hop note to the javadoc as well. |
|
@oss-maintainer The Windows CI is flaky — this same PR was green on d90b86b (docs-only), and the three subsequent commits are all javadoc changes with zero behavioural delta, yet Windows keeps failing. Ubuntu build ✅ passed. Review is APPROVED. Could you re-run the Windows job, or is this flaky check safe to skip? |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-reviewed at 9d6a4093. The delta over the head I approved (0e646a49) is a single javadoc-only commit adding the "Scheduling hop" paragraph to Toolkit.callTool — exactly closing the non-blocking observation from my approve review. Verdict: approve.
Verification
- The new paragraph matches the implementation:
ToolExecutor.applySchedulingsubscribes onSchedulers.boundedElastic()when no executor is configured (ToolExecutor.java:523-524) and onSchedulers.fromExecutor(executorService)otherwise (ToolExecutor.java:526);callTool(ToolCallParam)routes throughexecutor.executeWithInfrastructure(Toolkit.java:585-590), which applies that scheduling (ToolExecutor.java:473). - The thread-local caveat ("no longer visible on the execution thread") is the correct migration guidance for callers.
- Docs-only: no behavior change vs. the approved head; no test or API surface touched.
CI status on this head
build (ubuntu-latest)and the other checks are green — includingservice-dataplanetests (BUILD SUCCESS).build (windows-latest)fails inToolConfirmationCoordinatorTest.managedTimeoutWaitsForControlPlaneCancelledDecision(:350). That test lives inagentscope-service/service-dataplane, is not modified by this PR, passes on Ubuntu on this exact head, and the failing step follows two javadoc-only pushes; it reads as a Windows timing flake, not a regression from this PR. Triggering a re-run of the failed job.
Automated review by github-manager-bot
|
@oss-maintainer All checks are green now — ready to merge whenever you have a moment |
|
@oss-maintainer Just a gentle bump. I've synced the latest main branch into this PR and re-ran the CI. All checks are still passing. Let me know if there's anything else needed before merging. Thanks! |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
PR 3130 routes the single-call Toolkit.callTool through a new package-private ToolExecutor.executeWithInfrastructure(param, config) overload so single calls get id/name stamping plus the same timeout/retry/scheduling/shutdown-guard layers as the batch path, while the batch overload used by ReActAgent is behaviorally unchanged (comment and visibility tweaks only). From the permission-engine/approval-flow angle the change is safe: the allow/approve/deny gate lives in ReActAgent.evaluatePermissions (PermissionEngine.checkPermission) upstream of Toolkit.callTools and is untouched, the single path's core execution still runs the identical execute(param) -> executeCore chain with the same ToolRequestConfig resolution, group-activation gate, external-tool suspension, and preset injection as before, and withIdAndName preserves state/metadata so suspended external-execution results keep their marker through the new stamping. Both Toolkit entry points sit below the permission engine by pre-existing design (this PR neither introduces nor widens a bypass, and the new javadoc's "same infrastructure as callTools" claim is accurate at Toolkit level), and the default ASK / DENY-under-DONT_ASK fallback is untouched, so no new bypass or default-deny regression exists. One info-level nit remains: the stale "full infrastructure support" javadoc on ToolExecutor.execute(ToolCallParam) — cited in the PR description itself as the original smoking gun — is left unfixed.
Re-reviewed at head cce3584689; CLA: signed.
Automated review by github-manager-bot
Additional notes (not anchored to a changed line)
- [INFO]
agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java:158— The javadoc onexecute(ToolCallParam)still reads "Execute a single tool call with full infrastructure support", but after this PR it is the pure execution path (Tracer +executeCoreonly — no scheduling, timeout, retry, or shutdown guard), while the new siblingexecuteWithInfrastructure(param, executionConfig)at line 497 is the full-infrastructure path. The PR description itself cites this stale sentence as the original evidence thatcallToolwas misrouted, yet the diff leaves it unfixed. Now that both methods coexist, a future in-tree call site routed throughexecute(param)on the strength of this javadoc would silently get none of the infrastructure layers — exactly the divergence class this PR fixes. Suggest a one-line correction, e.g. "Execute a single tool call (core execution only; useexecuteWithInfrastructurefor timeout/retry/scheduling/shutdown guard)." Package-private surface, so info severity. (Permission-flow angle verified clean: the allow/approve/deny gate lives inReActAgent.evaluatePermissionsupstream ofToolkit.callTools, which this diff does not alter, and the single path'sexecuteCorechain is unchanged.) (line outside diff)
|
Thanks for catching this — it is indeed the stale javadoc that the PR description itself cites as the original smoking gun for the misrouting, and it was an oversight that the diff left it unfixed. I took the opportunity to do a full cross-check of the entire execute* family to align all descriptions, which turned up a few more inconsistencies: execute(ToolCallParam) (line ~158) — rewrote from the now-false "with full infrastructure support" to a precise description of its actual role (Tracer + executeCore only, no scheduling / timeout / retry / shutdown guard), plus a {@link} pointer to the correct executeWithInfrastructure overload. This fixes the exact nit you flagged. |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review of 6ba1699b (javadoc-only). The rewrite is a genuine improvement — execute(ToolCallParam) is now correctly described as the core-only path and executeWithInfrastructure as the full pipeline — and it matches what this PR actually changes for callTool. Two sentences still misdescribe the code, so leaving a comment rather than approving on this commit.
Findings
- [Warning]
ToolExecutor.java:462— "only the tool use block, agent, and runtime context are available" contradicts the six-parameterexecuteWithInfrastructure(...)signature linked in the same commit. - [Info]
ToolExecutor.java:159— the exclusion list omits id/name stamping, which is exactly the gap this PR closes forcallTool.
Suggestions
Thanks for picking up the javadoc cleanup on top of the functional fix — that kind of detail helps the next reader a lot. Suggested wording: for line 462, drop the enumeration and say the overload receives the same arguments the infrastructure pipeline is configured with; for line 159, add "and ToolResultBlock id/name stamping" to the list of what the core-only path does not do.
Automated review by github-manager-bot
| * guard), and stamps the result with the tool call's id/name. | ||
| * | ||
| * <p>This overload is used by the batch path ({@link #executeAll(List, boolean, | ||
| * ExecutionConfig, Agent, RuntimeContext)}) where only the tool use block, agent, and |
There was a problem hiding this comment.
The retained phrase "where only the tool use block, agent, and runtime context are available" contradicts the signature this same commit links to in executeAll's javadoc — executeWithInfrastructure(ToolUseBlock, ExecutionConfig, Agent, RuntimeContext, ToolRequestConfig, BiConsumer) — which also receives an execution config, a per-call request config, and a chunk callback. Rewrite the sentence so it does not misstate what the batch path passes to this overload.
| /** | ||
| * Execute a single tool call with full infrastructure support. | ||
| * Execute a single tool call (core execution only: Tracer + {@link #executeCore}; | ||
| * no scheduling, timeout, retry, or shutdown guard). Use |
There was a problem hiding this comment.
The exclusion list "no scheduling, timeout, retry, or shutdown guard" omits id/name stamping, which this commit's executeAll and executeWithInfrastructure docs identify as part of the infrastructure pipeline. Add it so readers of the core-only path know ToolResultBlock id/name are not populated here (the gap PR #3130 fixed via callTool).
…name, timeout, retry and ShutdownGuard are all applied callTool(ToolCallParam) was delegating straight to ToolExecutor.execute(param), a pure-execution path that bypassed executeWithInfrastructure entirely. As a result the returned ToolResultBlock had null id and null name, and any ExecutionConfig (timeout, retry) plus the graceful-shutdown guard were silently ignored for single calls. callTools(...) always went through the wrapper and worked correctly. Changes: - ToolExecutor: added executeWithInfrastructure(ToolCallParam, ExecutionConfig) overload that preserves every field of the original param (notably input). The existing 4-param overload (used by the batch path) now delegates to it, so executeAll behaviour is unchanged. Visibility widened from private to package-private. - Toolkit.callTool: merges ExecutionConfig (toolkit-default > TOOL_DEFAULTS) and routes through the new 2-param overload instead of execute(). - ToolkitTest: added two tests covering success and error paths to assert id and name are populated on the returned ToolResultBlock. Refs: agentscope-ai#3114 # Conflicts: # agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java
Upstream PR agentscope-ai#3283 added ToolValidator.validateInput which uses toolCall.getContent() for schema validation. The three new callTool single-param tests only set .input(Map) but omitted .content(String), causing silent validation failures (error ToolResultBlocks still get id/name attached by executeWithInfrastructure, so the first two tests passed by accident). Align ToolUseBlock construction with upstream convention by setting .content(JsonUtils.getJsonCodec().toJson(input)).
Routing callTool through executeWithInfrastructure now inherits the Toolkit's ExecutionConfig (timeout, retry, shutdown guard). This is a semantic change from before where the single-param overload had no timeout or retry. Document the blast radius in javadoc so callers can see the change from the API surface. Note that the default TOOL_DEFAULTS uses maxAttempts(1), so retry is a no-op for standard toolkits.
…ion and add exception-as-result contract Previous revision wrongly listed shutdown guard under ExecutionConfig; it is a global GracefulShutdownManager concern. Also document that all errors (tool exceptions, exhausted retry timeouts, shutdown fires) are converted into ToolResultBlock.error(...) via onErrorResume, never propagated.
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-reviewed the increment since my APPROVE on 18968336. The only new commit is 016626af — "test: verify mergeConfigs inherits NO_TIMEOUT when primary timeout is null" — touching just agentscope-core/src/test/java/io/agentscope/core/model/ExecutionConfigTest.java (+13/-0). Test-only delta, correct, and it completes the merge precedence matrix. Approving on the new head.
New test verified against the implementation at head 016626af:
// ExecutionConfig.mergeConfigs(...)
builder.timeout(primary.timeout != null ? primary.timeout : fallback.timeout);
// ExecutionConfig.isTimeoutDisabled()
return NO_TIMEOUT.equals(timeout);ExecutionConfig.builder().build()leavestimeout == null(theExecutionConfig(Builder)ctor assigns fields verbatim, no implicit default), somergeConfigsfalls through tofallback.timeout, which isNO_TIMEOUThere.Builder.timeout(...)rejects negative/zero durations except the exactNO_TIMEOUTsentinel, so the inherited sentinel passes validation instead of throwing.- Hence
merged.isTimeoutDisabled()istruebecause of real inheritance, not an incidental pass. TheBuild and Teststep is green on this head, confirming it. - Style matches the sibling tests (
@DisplayName+ assertion message), and placing it right aftermergeConfigsPositiveTimeoutPrimaryOverridesNoTimeoutkeeps the matrix readable:(noTimeout, timeout),(timeout, noTimeout),(null, noTimeout)plus the twoBuilder.timeout()rejection cases.
CI — the red leg is not a defect in this PR, re-run triggered
The failing step on run 37245503908 is Upload coverage reports to Codecov; Build and Test with Coverage, Check License and Check Module Sync had already passed:
==> Fork detected, tokenless uploading used
Error: write EPROTO ... error:0A000410:SSL routines:ssl3_read_bytes:ssl/tls alert handshake failure
This matches your diagnosis: a TLS handshake failure between the runner and Codecov's endpoint, surfaced as a job failure because the action runs with fail_ci_if_error: true. build (windows-latest) ended cancelled as a sibling of the same leg.
Action taken: re-ran the failed jobs — the workflow is now attempt 2, in_progress. No action needed from you, @KIM406-CMD. If attempt 2 fails identically at the upload step again, I will treat it as an infra flake in the workflow itself (a maintainer-side follow-up worth considering: fail_ci_if_error: false, or a retry wrapper around codecov-action@v4), not as something this PR has to fix.
State at review time
| Item | Value |
|---|---|
| Head | 016626af |
| Delta vs last approved commit | 1 commit, 1 test file, +13/-0 |
license/cla |
signed |
mergeable |
MERGEABLE (mergeStateStatus: UNSTABLE, caused by the coverage-upload leg) |
| Review decision | APPROVED |
Merging stays with the maintainers.
Automated review by github-manager-bot
|
@oss-maintainer |
|
Re-ran the failed job on What was re-run: workflow run Why this is not a PR defect: the failure is in the coverage-upload network hand-shake ( Status: this PR is already |
|
Re-ran coverage upload on Attempt 3 of run
So compile + the full test suite are green on your head; only the coverage upload to This is not specific to this PR and it is not a flake that a retry can clear — it is a deterministic egress failure. Two other PR heads are red on exactly the same step right now: Nothing to change on your side. From a code standpoint this PR stays Automated follow-up by github-manager-bot |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-reviewed the delta pushed since 621faef6 (14 commits up to 016626af). All three blocking points from my previous round are addressed and now pinned by tests: isTimeoutDisabled() compares against the NO_TIMEOUT sentinel instead of accepting any negative duration, Builder.timeout(...) rejects stray negatives/zero, and both remaining direct consumers (EmbeddingUtils in rag-simple, the SDK client timeout in openai-official) now honour the sentinel. Good round of work.
What keeps this at COMMENT rather than approval:
- [Warning]
Builder.timeout(...)now throws where it previously accepted any duration, andmergeConfigsroutes through that same builder — anExecutionConfigcreated by an older library version with aZERO/negative timeout will throw at merge time after an upgrade instead of degrading quietly. This is a runtime-visible behaviour change inagentscope-core, which cascades to harness/distribution/extensions, so it needs either a lenient path inmergeConfigsor an explicit changelog note. - [Warning] the model-flux path still has no test that exercises production
ModelUtils.applyTimeoutAndRetry; the guard was added to the test's private copy of that method, which is the divergence I flagged last round. - [Warning/Info]
noTimeout()now means "unbounded" on the tool/model-flux paths and "SDK default timeout" on openai-official. The warn log and javadoc are honest, but a maintainer should decide whether that per-provider split is acceptable for a public sentinel.
CI status on 016626af: Check License / Check Module Sync green, build (ubuntu-latest) red on the Upload coverage reports to Codecov step only (Build and Test with Coverage [Linux] succeeded) — same infra flake already confirmed in the re-run attempts on this PR, not a code defect; build (windows-latest) cancelled. CLA signed, mergeable, mergeStateStatus=UNSTABLE (failing check, no conflict). None of my earlier inline comments are regressed by this delta.
Automated review by github-manager-bot
| // Apply timeout if configured | ||
| Duration timeout = executionConfig.getTimeout(); | ||
| if (timeout != null) { | ||
| if (timeout != null && !executionConfig.isTimeoutDisabled()) { |
There was a problem hiding this comment.
[Warning] The NO_TIMEOUT behaviour on the model-flux path is still not pinned by any test that runs production code. This test keeps its own private copy of applyTimeoutAndRetry and the guard was added to the copy (!executionConfig.isTimeoutDisabled()), so if the real ModelUtils.applyTimeoutAndRetry lost the guard tomorrow this suite would stay green. The tool path now has a genuine behavioural test (testNoTimeoutOverridesShortToolkitTimeout) and EmbeddingUtilsTest / OpenAIResponsesChatModelTest cover their paths — this is the one remaining path with only a mirrored-implementation test.
Could you either drive the assertion through ModelUtils.applyTimeoutAndRetry(...) directly, or add one StepVerifier case in ExecutionConfigE2ETest that builds a ReActAgent/model with noTimeout() and a delayed fake response? The duplication of production logic inside a test helper is exactly what my earlier round flagged as drifting; tightening the copy keeps it drifting silently.
There was a problem hiding this comment.
@oss-maintainer
Done. Added shouldSkipTimeoutWithNoTimeoutSentinelInProductionCode that drives the assertion through ModelUtils.applyTimeoutAndRetry(...) directly with a delayed Flux and noTimeout() config.
| if (timeout != null | ||
| && (timeout.isNegative() || timeout.isZero()) | ||
| && !NO_TIMEOUT.equals(timeout)) { | ||
| throw new IllegalArgumentException( |
There was a problem hiding this comment.
[Warning] Throwing from Builder.timeout(...) turns a previously accepted value into a hard failure, and this builder is reached through mergeConfigs (line 315: builder.timeout(primary.timeout != null ? primary.timeout : fallback.timeout)). Any config that already exists with a stray negative/zero timeout — built before this change, or assembled by third-party code that constructs ExecutionConfig reflectively/deserialised — will now throw at merge time rather than at configuration time, i.e. deeper inside the request path where the stack trace won't point at the offending builder call.
Two things worth doing before merge:
- Note the behaviour change in the PR description / changelog — users who today pass
Duration.ZERO(or a negative) and effectively get "no timeout applied" now get anIllegalArgumentExceptioninstead. - Include the rejected value in the message ("timeout must be positive, got " + timeout) so the failure is self-describing;
maxAttempts/backoffMultiplierhave the same weakness but this one is newly enforced on a previously-valid input, so it is the one users will hit.
There was a problem hiding this comment.
Done. The error message now includes the rejected value: "timeout must be positive, got " + timeout + "; use NO_TIMEOUT or noTimeout() to disable it".
| // When timeout is disabled, pass null so the SDK uses its own default. | ||
| // This differs from the tool / model-flux paths where noTimeout() is genuinely | ||
| // unbounded — here it degrades to the SDK's own default request timeout. | ||
| Duration clientTimeout = null; |
There was a problem hiding this comment.
[Warning] noTimeout() means two different things depending on which model provider is configured: genuinely unbounded on the tool and model-flux paths, and "SDK default request timeout" here. The log.warn plus the comment are honest, but the public javadoc of NO_TIMEOUT (which now lists the supported paths) is where a user reading ExecutionConfig.noTimeout() will look, and it currently says this path must "apply the same guard" — which in effect means "this path cannot honour it".
Suggested alternatives, in order of preference:
- Check whether the OpenAI SDK accepts an effectively-unbounded timeout and, if so, pass that instead of
null, so the sentinel means the same thing everywhere. - Otherwise state the divergence explicitly in the
NO_TIMEOUTjavadoc bullet ("openai-official: degrades to the SDK default, it is not unbounded") rather than only in an inline comment at the call site, and keep the warn.
Either way this is worth a decision by a maintainer rather than a silent per-provider difference — the sentinel is a public API on agentscope-core, so every extension inherits the contract.
There was a problem hiding this comment.
Done. The NO_TIMEOUT javadoc now explicitly documents that openai-official degrades to the SDK's own default request timeout rather than being truly unbounded, with a log.warn emitted when this occurs.
| clientTimeout = effectiveOptions.getExecutionConfig().getTimeout(); | ||
| } else if (effectiveOptions.getExecutionConfig() != null | ||
| && effectiveOptions.getExecutionConfig().isTimeoutDisabled()) { | ||
| log.warn( |
There was a problem hiding this comment.
[Info] Readability nit: both branches re-evaluate effectiveOptions.getExecutionConfig() != null, and the else if can only be reached when that check is already true, so the second != null is dead. Hoisting the config once would make the intent obvious:
ExecutionConfig exec = effectiveOptions.getExecutionConfig();
Duration clientTimeout = null;
if (exec != null) {
if (exec.isTimeoutDisabled()) {
log.warn("...", modelName);
} else {
clientTimeout = exec.getTimeout();
}
}Also modelName is resolved from effectiveOptions at line 111 — fine here, just confirm the builder path has it populated when this runs (the new tests build through the same path, so it looks covered).
There was a problem hiding this comment.
Done. Hoisted ExecutionConfig exec = effectiveOptions.getExecutionConfig() to eliminate the redundant null check in the else if branch.
| // Apply timeout if configured (skip when NO_TIMEOUT sentinel is set) | ||
| Duration timeout = config.getTimeout(); | ||
| if (timeout != null) { | ||
| if (timeout != null && !config.isTimeoutDisabled()) { |
There was a problem hiding this comment.
[Info] Guard is correct and now covered by testNoTimeoutSentinelSkipsTimeout / testShortTimeoutExpiresSlowMono — that is exactly the shape I asked for. One follow-up so the pattern is not re-lost later: isTimeoutDisabled() is only reachable via ExecutionConfig, but the neighbouring consumers that read getTimeout() straight out of their own config type (HayStackClient/RAGFlowClient in rag-haystack/rag-ragflow, McpServerRegistrar, JevAutoConfiguration) do not use ExecutionConfig at all, so they are unaffected — worth stating once in the PR description so nobody goes looking for a missing guard there.
There was a problem hiding this comment.
Acknowledged. Confirmed that HayStackClient/RAGFlowClient in rag-haystack/rag-ragflow, McpServerRegistrar, and JevAutoConfiguration use their own config types (not ExecutionConfig) and are unaffected.
…on-code noTimeout test, NO_TIMEOUT javadoc openai-official divergence, hoist config reference in OpenAIResponsesChatModel
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-reviewed the delta pushed since 016626af (8b1d6aaf + 6bed4723, head 6bed4723e) in response to my round-10 comments. Two of the three open points are properly resolved and one is narrowed to a docs follow-up.
Resolved
- No production-code coverage of the
NO_TIMEOUTguard on the model-flux path —ModelTimeoutRetryTest.java:370now callsModelUtils.applyTimeoutAndRetrydirectly withExecutionConfig.builder().noTimeout().build()and a delayed source. Had the guard atModelUtils.java:90regressed totimeout != nullalone, Reactor would receiveDuration.ofNanos(-1)and the subscription would not complete. Real regression pin, not a restatement of the implementation. - Redundant re-evaluation + undocumented per-provider divergence —
OpenAIResponsesChatModel.java:362hoists theExecutionConfigreference, andExecutionConfig.NO_TIMEOUTjavadoc now enumerates both extension consumers, explicitly saying the openai-official path degrades to the SDK default timeout and emits a warning. Consistent with theEmbeddingUtils(rag-simple) behaviour, which honours the sentinel.
Still open (non-blocking)
Builder.timeout(...)is a behaviour change on a public API inagentscope-core, reached throughmergeConfigs, with no changelog entry. It cascades to harness/distribution/extensions, so it deserves one line indocs/v2/{en,zh}/docs/change-log.md. The exception message now includes the offending value, so the failure is diagnosable; that is why this is an[Info]rather than a blocker.
CI on 6bed4723e — Check License / Check Module Sync green; build (windows-latest) cancelled; build (ubuntu-latest) red on the Upload coverage reports to Codecov step only (Exception: Request failed after too many retries. URL: https://ingest.codecov.io/... — fail_ci_if_error: true), i.e. the same codecov-ingest infra flake already seen repeatedly on this PR. The Maven build-and-test step itself completed successfully, so the new test is genuinely verified. Not a code defect.
CLA signed (license/cla: success), mergeable, mergeStateStatus=UNSTABLE from that failing check alone, no merge conflict. Approval stands at this head; the changelog line can land here or in a follow-up. Thanks for the responsiveness across eleven rounds — the diff is in good shape and it is the last first-time-contributor PR in the merge-ready set.
Automated review by github-manager-bot
| @DisplayName( | ||
| "Should skip timeout when NO_TIMEOUT sentinel is configured in production" | ||
| + " ModelUtils.applyTimeoutAndRetry") | ||
| void shouldSkipTimeoutWithNoTimeoutSentinelInProductionCode() { |
There was a problem hiding this comment.
[Info] Resolved — this is what I asked for on the previous round. shouldSkipTimeoutWithNoTimeoutSentinelInProductionCode drives the real ModelUtils.applyTimeoutAndRetry with a noTimeout() config against a 500 ms delayed source, so the guard at ModelUtils.java:90 is now pinned by production code instead of a private copy of the method. Verified green: on 6bed4723e the Build and Test with Coverage [Linux] step completed, so this test compiled and passed.
| // When timeout is disabled, pass null so the SDK uses its own default. | ||
| // This differs from the tool / model-flux paths where noTimeout() is genuinely | ||
| // unbounded — here it degrades to the SDK's own default request timeout. | ||
| ExecutionConfig exec = effectiveOptions.getExecutionConfig(); |
There was a problem hiding this comment.
[Info] Resolved — the hoist removes the duplicated getExecutionConfig() != null re-evaluation, and the NO_TIMEOUT javadoc in ExecutionConfig now states plainly that on this provider the sentinel degrades to the SDK's own default request timeout rather than being unbounded. That is the honest documentation of the per-provider split; whether the split itself is acceptable for a public sentinel is a maintainer call, not a code defect.
| * for {@link #noTimeout()} and is therefore rejected | ||
| * @return this builder instance | ||
| * @throws IllegalArgumentException if timeout is a negative duration other than | ||
| * {@link #NO_TIMEOUT}, or if timeout is {@code Duration.ZERO} |
There was a problem hiding this comment.
[Info] One item from the previous round is still open, and it is documentation rather than logic: Builder.timeout(...) now rejects values it used to accept (Duration.ZERO and any negative duration other than the sentinel), and that rejection fires on the mergeConfigs path too — so code written against an earlier agentscope-core can start throwing IllegalArgumentException after an upgrade, at config-merge time rather than at the call site. The message improvement (got <value>) makes it diagnosable, which helps a lot. Could you add a line to docs/v2/en/docs/change-log.md + docs/v2/zh/docs/change-log.md noting the stricter validation and pointing at noTimeout()? That is the only thing I would still like to see here; I am not blocking the review on it.
|
@oss-maintainer |
|
@oss-maintainer
Commit: e63fede |
|
@oss-maintainer hello |
|
Impressive turnaround — 25 commits incorporating all ten review rounds (timeout sentinel semantics, registry atomicity, javadoc corrections, changelog) and now mergeable against current Closing my #3686 as superseded per my earlier note. One small thing worth keeping from my thread if it's not already covered: the regression test asserting |
|
Thanks for the thorough review across all ten rounds — really appreciate the patience. On the callTool/callTools parity test: yes, it's covered by the per-call coverage tests in this branch. Closing #3686 as superseded sounds right. Thanks again! |
|
Done. Thanks for the thorough review and the help getting this across the line! |
Summary
Closes #3114.
Route
Toolkit.callTool(ToolCallParam)through the same infrastructure pipeline used byToolkit.callTools(...):ToolResultBlock.id/namestampingThis fixes #3114: direct
callToolcalls no longer return tool results whoseidandnamearenull, including success, tool error, missing-tool, and validation-failure paths.The existing 4-argument
executeWithInfrastructure(...)batch entry point now delegates to a shared implementation, so direct and batch execution use the same infrastructure and no longer drift.A new overload is added:
It merges configuration as:
callTools(...)now reuses the same configuration-resolution helper, so both entry points keep the same merge semantics.Breaking changes
Toolkit.callTool(ToolCallParam)now matchescallTools(...)semantics instead of running as a thin, infrastructure-free path.This is observable behavior change:
TOOL_DEFAULTS, which applies a 5-minute timeout by default.boundedElasticor the configured executor; caller-threadThreadLocalstate is no longer visible to the tool.ToolResultBlock.error(...).ExecutionConfig.maxAttempts > 1, timeout failures can be retried; normal tool exceptions are still converted to tool results before retry.Tools that legitimately run longer than five minutes must configure a longer timeout at toolkit level or pass one through the new per-call overload.