Skip to content

fix(durable): stop a late lease heartbeat from interrupting the caller - #4302

Open
xseruer wants to merge 3 commits into
agentscope-ai:mainfrom
xseruer:fix/durable-late-heartbeat-interrupt
Open

xseruer wants to merge 3 commits into
agentscope-ai:mainfrom
xseruer:fix/durable-late-heartbeat-interrupt

Conversation

@xseruer

@xseruer xseruer commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A lease heartbeat renewal can fail after DurableRuntime's tick()/process() has already returned (backend hiccup, lease takeover). The old code called thread.interrupt() unconditionally, so the late heartbeat 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. Cancellation behavior while the invocation is still in flight is unchanged.
  • Split out of fix(harness): report failed background subagent tasks correctly #4102 for independent review per maintainer feedback.

Test plan

  • New contract test lateHeartbeatFailureDoesNotInterruptTheCallerAfterTheInvocationReturns asserts a late renewal failure leaves the caller's interrupt status clean and the turn SUCCEEDED
  • mvn -pl agentscope-durable/durable-runtime -am test passes (36 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.

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