Skip to content

fix(a2a): prevent task lifecycle races - #3828

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
guslegend0510:fix/a2a-runner-cache-race
Oct 29, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
guslegend0510:fix/a2a-runner-cache-race

Conversation

@guslegend0510

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT (based on 7653eb7ec)

Description

This fixes two related lifecycle races when the same A2A task ID is stopped and restarted:

  • atomically register the per-task ReActAgent with putIfAbsent
  • remove cached agents only when the terminating stream still owns that exact instance
  • roll back the cache entry when stream creation fails synchronously
  • track the exact Reactive Streams subscription for each execution
  • prevent an old stream from removing or cancelling a replacement subscription

Regression tests cover concurrent starts, old-stream cleanup after restart, synchronous stream creation failure, and replacement subscriptions created during cancellation.

Testing

  • mvn -B -T1C -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-a2a/agentscope-extensions-a2a-server -am test (186 A2A Server tests)
  • mvn -B -T1C clean verify (99-module reactor)

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing
  • Javadoc comments are complete and follow project conventions
  • Related documentation is not required for this internal concurrency fix
  • Code is ready for review

Use atomic cache registration and identity-aware cleanup for agents and subscriptions so an old stream cannot remove or cancel a restarted task.
@jujn
jujn merged commit 431031a into agentscope-ai:main Oct 29, 2026
5 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.

3 participants