Skip to content

fix(a2a): cancel streams registered after call cleanup - #4418

Open
CryoThrust wants to merge 1 commit into
agentscope-ai:mainfrom
CryoThrust:fix/a2a-late-stream-cancellation
Open

CryoThrust wants to merge 1 commit into
agentscope-ai:mainfrom
CryoThrust:fix/a2a-late-stream-cancellation

Conversation

@CryoThrust

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT (main@5a315a9af)

Description

Fixes #4416.

The default A2A call owns a fresh StreamTrackingHttpClient, and endCall drains its tracked futures. If cleanup happens while the delegate is still returning an SSE future, that future is registered after the drain and remains open. Closing the JSON-RPC transport alone does not close its event stream.

Retain a terminal cancellation flag before draining the queue and recheck it after registering each future. This closes both already tracked and late-registered streams without adding a lock around delegate calls or callbacks. The wrapper remains package-private and per-call; remote task cancellation and custom client transports are unchanged.

Tests cover a deterministic reentrant cleanup boundary, late GET registration, completed-future preservation, repeated cleanup, latch-controlled concurrent POST registration, the existing real HTTP disconnect and normal request delegation. English and Chinese documentation distinguish local stream cleanup from confirmation that remote work stopped.

Verification

The new late-registration regression fails on the unchanged base; the five tracking-client cases pass after the fix without skips. The HTTP disconnect case uses a local server, not a remote model provider.

On Java 17:

mvn -o -B -T1C -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-a2a/agentscope-extensions-a2a-client,agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-a2a/agentscope-extensions-a2a-server -am clean verify

The seven-module clean verification passed in 1:47: 3,932 tests, zero failures/errors, 11 skipped. Both A2A client (175 cases) and server (228 cases) ran with no skips. This is scoped module/dependency verification, not a whole-repository claim. Selecting only the A2A parent POM does not run its children; that initial aggregator-only command is not counted as test verification.

Documentation checks passed from docs/: npm test, npm run validate, npm run broken-links.

Checklist

  • Code formatted with Spotless
  • All repository tests pass (not claimed; scoped results above)
  • Javadoc conventions preserved; no public API added
  • Related English and Chinese documentation updated
  • Code is ready for review

@mintlify

mintlify Bot commented Nov 25, 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 7a71f57.

Approve preview

This branch has not been deployed

No deployments
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.

A2A call cleanup misses SSE futures registered after stream cancellation

1 participant