Skip to content

fix(a2a): free the task id before the run's end reaches the subscriber - #4303

Open
xseruer wants to merge 3 commits into
agentscope-ai:mainfrom
xseruer:fix/a2a-early-task-release
Open

xseruer wants to merge 3 commits into
agentscope-ai:mainfrom
xseruer:fix/a2a-early-task-release

Conversation

@xseruer

@xseruer xseruer commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • doFinally releases the task id only after the terminal signal has been delivered downstream, so a subscriber that resumes the task from its completion or error callback (e.g. after an input-required turn) hit Agent already exists for taskId.
  • Register the release through doOnTerminate/doOnCancel instead, so the id is freed before the terminal event reaches the executor's client.
  • Split out of fix(harness): report failed background subagent tasks correctly #4102 for independent review per maintainer feedback.

Test plan

  • New tests cover all three terminal paths: id freed before completion and before error reach the subscriber, and freed on cancel
  • mvn -pl agentscope-extensions/.../agentscope-extensions-a2a-server -am test passes (231 tests, 0 failures)

A lease heartbeat renewal can fail after DurableRuntime's tick()/process()
has already returned, e.g. because the backend hiccuped or the lease was
taken over. The old code called thread.interrupt() unconditionally, so a
late heartbeat failure interrupted whatever the worker thread was running
next instead of the finished invocation.

Introduce a settled flag: once the invocation's finally block has run, the
heartbeat's stop() only flips the stopped flag and never interrupts. While
the invocation is still in flight, cancellation behavior is unchanged.

Split out of agentscope-ai#4102 for independent review per maintainer feedback.
doFinally releases the task id only after the terminal signal has been
delivered downstream, so a subscriber that resumes the task from its
completion or error callback (e.g. after an input-required turn) hit
"Agent already exists for taskId". Register the release through
doOnTerminate/doOnCancel instead, so the id is freed before the terminal
event reaches the executor's client.

Split out of agentscope-ai#4102 for independent review per maintainer feedback.

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.

1 participant