Skip to content

fix(core,harness): backport progressive tool call events to 2.0.x (#4429) - #4430

Merged
chickenlj merged 2 commits into
agentscope-ai:2.0.xfrom
Acerola-1:backport/2.0.x-pr3712
Nov 30, 2026
Merged

chickenlj merged 2 commits into
agentscope-ai:2.0.xfrom
Acerola-1:backport/2.0.x-pr3712

Conversation

@Acerola-1

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.6-SNAPSHOT (targeting 2.0.x)

Description

Fixes #4429
Backports #3712 (db0b67eb8, addressing #3223) from main to 2.0.x as a fix release, with 2.0.x compatibility adaptations and an AsyncToolMiddleware regression fix.

Changes

  • agentscope-core:
    • Added ToolExecutionCallback (onStart, onProgress, onResult) and Toolkit.callToolsWithCallback(...) while keeping existing callTools(...) overloads compatible.
    • Updated ToolExecutor to emit onStart at subscription/turn arrival and onResult before ordered batch aggregation (outside retry, preserving isTimeoutManaged()), and deferred ToolExecutor.execute(...) with Mono.defer(...) so NoopTracer does not evaluate executeCore(...) eagerly at assembly time.
    • Updated ReActAgent to emit tool start/delta/end events progressively via per-batch ToolResultCallback while keeping PostActing, context settlement, and the next reasoning step synchronized at the batch boundary. Preserved 2.0.x event compatibility (chunkedToolIds suppression for ToolEmitter chunks and ToolResultEndEvent(RUNNING) for suspended external tools; no fix(core): carry tool progress on its own event type #3331 / fix(core): stop fabricating tool results for suspended external tool calls #3435 / feature flag).
    • Handled batch-level error fallback safely: resolved/suspended calls keep their results without duplicate events, and queued calls (e.g., behind a failure in sequential mode) receive idempotent ToolResultStartEvent before synthetic error deltas/end.
  • agentscope-harness:
    • Fixed AsyncToolMiddleware so tools that complete before offloadTimeout keep their real result in agent context in original call order, do not emit duplicate placeholder events, and are excluded from AsyncToolRegistry registration/completion/failure and background inbox notifications.
  • Tests & Docs:
    • Added ToolExecutionCallbackTest and ProgressiveToolResultTest; updated ReActAgentToolkitConcurrencyTest and AsyncToolMiddlewareTest (including an end-to-end ReActAgent + AsyncToolMiddleware regression test).
    • Updated docs/v2/{en,zh}/docs/building-blocks/{message-and-event.md,tool.md} to reflect 2.0.x progressive tool event behavior.

Verification

  • mvn -T1C -pl agentscope-core,agentscope-harness spotless:check passed.
  • Targeted agentscope-core tests (ToolExecutionCallbackTest, ProgressiveToolResultTest, ReActAgentToolkitConcurrencyTest, ReActAgentNewLoopReplyTest, ToolExecutorTest, ToolkitCallToolIdentityTest): 313/313 passed.
  • Targeted agentscope-harness test (AsyncToolMiddlewareTest): 5/5 passed.
  • agentscope-extensions-agui (551), agentscope-extensions-studio (91), agentscope-extensions-a2a-client (144), agentscope-extensions-a2a-server (133) passed.
  • Docs checks (npm test, npm run validate, npm run broken-links) passed.
  • Note: on local macOS JDK 17, pre-existing symlink tests JsonFileAgentStateStoreTest.sessionOperationsShareLocksThroughRootSymlink (8 errors) and MemoryFlushSandboxIndependenceTest.hostMemoryRejectsNamespacePrefixAndEscapingInternalSymlinks (1 failure) failed due to /tmp / /var symlink behavior; please check Linux/Windows CI results on the PR.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@mintlify

mintlify Bot commented Nov 26, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit a2fbf14.

Approve preview

@Acerola-1
Acerola-1 changed the base branch from main to 2.0.x November 26, 2026 06:01
@Acerola-1 Acerola-1 closed this Nov 26, 2026
@Acerola-1 Acerola-1 reopened this Nov 26, 2026
@Acerola-1

Copy link
Copy Markdown
Contributor Author
Note: `build (windows-latest)` failed on an unrelated pre-existing test in `2.0.x`
(`SkillBoxTest$UploadContainment.preservesLegacyNamesWithRelativeNonNormalizedWorkDirectory` calling
`Path.of("").toAbsolutePath().relativize(tempDir)` across `D:` workspace and `C:` `@TempDir` from
commit `508d5e277`), which also cancelled `build (ubuntu-latest)` due to `fail-fast`.

Use original tool results for foreground settlement and hand off the acting batch once at timeout. Route lifecycle execution through existing Toolkit overrides and cover both offload timings.
@chickenlj
chickenlj merged commit f9095b3 into agentscope-ai:2.0.x Nov 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backport 2.0.x]: Progressive tool call events (#3712) and AsyncToolMiddleware offload fix

2 participants