Repository navigation
feat(durable): resume queued model calls across runtimes and worker attempts - #4218
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
chickenlj
approved these changes
Nov 24, 2026
xzxiaoshan
added a commit
to xzxiaoshan/agentscope-java
that referenced
this pull request
Nov 24, 2026
Merge main (a067f5c, 1 commit) into the final-answer-gate branch and resolve: - ReActAgent.runPostReasoningPipeline (content conflict): main's agentscope-ai#4218 replaces reasoningCompleted(iter) with reasoningApplied(iter, answer) — once a round's result is in memory, a resumed (handed-off) model call is checkpointed with "model_result_applied" and its terminal answer preserved for re-entry — while this branch lands a terminal candidate only after the gate verdict. Keep main's deferred per-branch bookkeeping without its unconditional memory write, and drop this branch's eager reasoningCompleted(iter): it ran before the terminal branch and cleared the pending call, which would have silently disabled both of main's new effects for every agent. - FinalAnswerGateEngine: the loop's terminal exit now hands its bookkeeping to the gate (new overload taking this::reasoningApplied), which reports each round once its outcome is in memory — the landed (certified) message after the memory write and before the projection on accept; nothing on a veto, before the retry re-entry. Reporting the pre-verdict candidate preserved a draft the gate had replaced or rejected as the call's answer; skipping the veto report left the retry round rejected with "Cannot call the model while waiting for <call>"; reporting after gate() returned re-applied a stale iteration. The plain three-argument gate(...) lost its only caller and is folded into the transform form. - New ReActAgentFinalAnswerGateHandoffTest (5 cases) over a handed-off model call: the replacement is what lands and ships on resume; a run lost after landing re-enters with the preserved certified answer, without a model call or another consultation; a veto releases the call for the retry round (plain and native structured-output exits); a rejected draft is never the preserved answer. The last four cases were checked to fail under the wrong resolutions above; the first pins the happy path. Known gap, not addressed here: the per-call retry fuse does not bound a Turn whose gate retries run over handed-off model calls. Every resume is a new call with retryCount 0, so a gate that keeps vetoing re-dispatches the model without limit instead of failing closed after 10 retries. Settling the budget per Turn needs a durable design decision. Verified: mvn -T1C clean test-compile over the whole reactor (114 modules, spotless:check clean); core and harness full suites (3586 and 1918 tests, 0 failures, 0 errors), including ReActAgentFinalAnswerGateHandoffTest (5), ReActAgentFinalAnswerGateTest (58) and main's ReActAgentFailoverBoundaryTest (11). Not introduced here — the failing set of the durable adapter closure is a subset of pure main's, reproduced on a067f5c (exported with git archive) on this Windows machine: the durable adapter module (AgentScopeAdapterTest 4 of 49, ModelWorkerTest 3, ProcessRecoveryTest 2, HarnessExternalToolProcessRecoveryTest 1) and the sandbox module (13).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.1.0-SNAPSHOT
Description
A durable ReAct or Harness Turn can dispatch a reasoning request to a model queue, release its Runtime invocation, and resume on another Runtime from a complete response or ordered streaming replies.
Workers begin each generation with a unique delivery ID. The backend assigns a transactional epoch, fences superseded replies, and seals the winning generation before tool dispatch. A replacement generation continues the original Turn and replaces partial text through a new message revision. Superseded, sealed and terminal replies return an
ignoredreceipt that consumers can acknowledge.This change also adds persistent idle deadlines, bounded recovery for uncertain publication and transient provider failures, standard model request observation events, backend wakeup subscriptions with polling repair, and core codec deserialization for tool schemas and generation options. EN/ZH documentation describes the worker protocol and failure semantics. The JEV benchmark fixture now uses isolated state after repeated repository verification exposed state leaking between runs.
Validation
mvn -B -ntp -T1C -fae verify -DexcludedGroups=e2e -Dmaven.javadoc.skip=true.clean verifyalso exercised repository-wide Javadoc generation.External provider
e2etests were excluded. Docker provider behavior was verified using a local HTTP Mock. Early broker memory failures were corrected in the test environment, followed by reruns of the affected acceptance scenarios.Recovery boundaries
Lost publication acknowledgements can still cause another provider call and additional billing. If a Runtime dies after an external tool effect occurs but before its result is persisted, recovery retains
WAITINGwith explicit reconciliation required. The crash regression observes one external receipt and disables automatic repetition.Checklist
mvn spotless:applye2etests excluded