Repository navigation
fix(a2a,durable,rocketmq): fix the four flaky tests that fail unrelated builds - #4176
Merged
jujn merged 3 commits intoNov 15, 2026
Merged
Conversation
ningmao-hlyz
force-pushed
the
test/rocketmq-recovery-diagnostics
branch
from
November 14, 2026 15:39
2bc0e4f to
e096540
Compare
ningmao-hlyz
force-pushed
the
test/rocketmq-recovery-diagnostics
branch
3 times, most recently
from
November 14, 2026 16:22
c8b621d to
c77f722
Compare
ningmao-hlyz
force-pushed
the
test/rocketmq-recovery-diagnostics
branch
from
November 14, 2026 18:48
b88b07d to
4962067
Compare
…ssages, and ignore wakeups Two test-harness defects, both seen on CI. RocketMQ: `Broker.consumer` re-offers a message 50ms after handing it out unless it was acked, without knowing whether the consumer is still working on it. When the ack lands after the window the message is delivered twice, which is what failed this PR's ubuntu build: authorizationPrecedesAdmissionAndCancellationTombstoneSurvivesLateExecute:604 expected: <1> but was: <2> A single CANCEL produced two acks. Narrowing the window to 1ms reproduces it locally, together with the recovery flake: expected: <1> but was: <2> turn.status=WAITING, modelCalls=1, commandAcks=10, eventAcks=17, queuedEvents=2 A real invisible duration is measured in seconds; these tests only need redelivery to happen inside their 10s waits. Name the window, raise it to one second, and record the constraint next to it. ProcessRecovery: the test polls `backend.turn(...)` while ticking, and the runtime interrupts the ticking thread to deliver a wakeup, so `Thread.sleep` threw `InterruptedException` and failed a run in which nothing was wrong (agentscope-ai#4102, and main). The fixture loop in the same file already cleared the flag; route all three sleeps through one `pause` helper instead. The deadlines and the terminal assertion are untouched, so a real stall still fails.
…e resume `BaseReActAgentRunner.streamEvents` refuses a task id that is still in `agentCache`, and the entry is only removed in `.doFinally`, once the previous stream has unwound. A client that receives `input-required` confirms right away, which cancels the stream it was reading, so the confirmation can arrive before that cleanup runs. The runner then threw synchronously, `AgentScopeAgentExecutor` answered with `emitter.sendMessage(...)` — a plain `Message`, not a terminal task state — and the client saw a stream that simply ended: the stream ended without reaching TASK_STATE_FAILED which is what fails intermittently on linux CI as `streamingConfirmationWithoutStateStoreFails` and, on another run, as `streamingApprovalResumesAndCompletes`. The task now carries a latch that `doFinally` and `stop` release, and a request for the same task waits up to two seconds for it instead of failing at once. A genuinely concurrent run still fails, after the wait; a resume that was only waiting for cleanup proceeds. The `putIfAbsent` guard is untouched, so two runs can never hold the same task.
…removed `HttpServerApplicationTest` keeps the runtime's data directory in a static `@TempDir`. JUnit deletes it when the class ends, but the Spring context is cached and still open, so the SQLite file and the server threads are still there and the deletion fails on linux: Failed to delete temp directory /tmp/junit-...: the following paths could not be deleted Windows never shows it because the durable example modules are skipped there, so linux CI is the only place this test runs. Dirty the context after the class so it is closed, and its beans destroyed, before the directory is removed.
ningmao-hlyz
force-pushed
the
test/rocketmq-recovery-diagnostics
branch
from
November 14, 2026 19:29
4962067 to
29be1dd
Compare
ningmao-hlyz
added a commit
to ningmao-hlyz/agentscope-java
that referenced
this pull request
Nov 14, 2026
`Broker.consumer` re-offers a message 50ms after handing it out unless it was acked, without knowing whether the consumer is still working on it, so a slow ack becomes a duplicate delivery and the recovery assertion times out: agentScopeResumesThroughSeparateLedgersDespitePublicationAndAckFailures Time elapsed: 14.22 s <<< FAILURE! This is the flake tracked in agentscope-ai#4175 and fixed in agentscope-ai#4176. The change is carried here as the same three lines so this branch is not blocked by an unrelated module; drop it on rebase once agentscope-ai#4176 lands.
5 tasks done
5 tasks done
z43460018724
added a commit
to z43460018724/agentscope-java
that referenced
this pull request
Nov 16, 2026
…cope-ai#4176 flaky-test fix + agentscope-ai#4180 a2a-sdk bump)
xzxiaoshan
added a commit
to xzxiaoshan/agentscope-java
that referenced
this pull request
Nov 18, 2026
Both scenarios ride fixed one-second broker redelivery windows and lease-rediscovery chains that stack serially; a shared ubuntu runner adds scheduling delay on every hop, so the 5s/10s budgets expired while convergence was still in progress (observed on this PR and on unrelated builds, cf. agentscope-ai#4176). Convergence stays the assertion — only the deadline widens: - RocketMqExecutionTest: shared 10s wait -> named 30s budget - AgentScopeAdapterTest: host-rebuild/recovery awaits 5s -> 30s
1 of 2 tasks
xzxiaoshan
added a commit
that referenced
this pull request
Nov 20, 2026
…#4274) ## Background Swept the last 125 PRs (#4272→#4075) for single-OS CI failures under `mvn -B -T1C clean verify` (one build OS red, the other green on the same commit = flake suspect). Cross-PR repeats and main's own red run on 2026-11-19 (ubuntu, run 44516464414) pinpoints four still-broken test classes; all fixes are test-side only (no `src/main` changes). ## Fixes and evidence | Test class | Victims | Signature | Fix | |---|---|---|---| | `RocketMqExecutionTest` | #4182, #4192, #4103 + main run 44516464414 (2026-11-19, ubuntu) | `turn reaches SUCCEEDED did not become true within 10s` while the turn kept progressing (modelCalls complete, acks climbing, lastFailure=none) — deadline breakthrough under starvation, not a lost turn | shared `waitUntil` deadline 10s→30s (repo tier #3726/#3774) | | `AgentScopeAdapterTest` | #4204 (same-commit re-run green = confirmed flake), #4191, #4246 | `Timed out observing Turn` at 6.7–8.5s elapsed; resume/recovery one step from terminal | `turn.await(5s)`→30s at all 3 sibling sites via `TURN_DEADLINE`, outer `get` budgets +5s margin | | `WorkerRuntimeTest` | #4219, #4224, #4255 (windows) | (a) `Worker lease lost` after 2.4s — 1s claim leases expired between claim and release; (b) `renewed.await(5s)` missed at 6.5s while the recovery lane was healthy; (c) `Interrupted sleep interrupted` — `WorkerRuntime.process()` interrupts the calling thread on lease-renewal failure and manual `tick()` runs it on the test thread | (a) claim leases 1s→30s (staleness under test still comes from `release(ZERO)` + re-claim); (b) latches 5s→30s; (c) raw `Thread.sleep`→interrupt-proof `pause()` at 5 sites, mirroring the #4176 fix for the same signature in `ProcessRecoveryTest` | | `ChatSessionsTest.await` (shared with `ChatControllerTest`) | #4233, #4182 (stuck-RUNNING at 40.8s/46.4s), #4268, #4163 (poll threw `Durable database transaction failed`) | two surfaces of one cause: every snapshot poll opens a writing sqlite transaction contending with the runtime's own writes, and windows runners starve turns past 30s (same file already measured 56.6s starvation and uses 120s elsewhere, #3726) | deadline 30s→120s (aligned tier) + tolerate transient `UNAVAILABLE` store exceptions while polling; persistent failure rethrows at the deadline, FAILED-turn fast-fail unchanged | | `CommandExecutorTest.missingExitCodeIsUnknown` | local -T2C full-repo stress (2026-11-19; pristine-main baseline of the same class green) | the 2s network budget fired on scheduler starvation before the instant fake response was processed, misclassifying the failure as a deadline miss instead of a missing exit code (2.97s elapsed) | budget 2s→30s for this non-deadline-semantics test; the two deadline-semantics tests keep their tight budgets | ## Constraint compliance - Happy path zero cost: every change only extends failure-path deadlines or hardens helpers; no new sleeps, no weakened assertions. - Minimal widening anchored to measured data (each comment cites victims + measured values); 30s follows the repo's established deflake tier, 120s follows this file's own previously measured starvation tier. - Structural hardening preferred: `pause()` helper, transient-lock retry, lease decoupling from the tested invariant. - No `src/main` changes. ## Observed but deliberately not fixed here - `ProcessRecoveryTest.replacementCollectsOriginalResultWithoutRepeatingEffect` (#4214: `expected: 2 but was: 3`): recovery-semantics race (model re-run without effect re-run after abrupt halt) — a product question for the durable recovery work, not a deadline flake. - `JevEvidenceProcessorTest.filterFailureIsWithheldButRankFailureFollowsScoredEvidence` (#4265: delivered `[]` on a 25×-slowed runner): root cause not established; single occurrence. - Already fixed upstream, victims predate the fix: `AgentScopeAgentExecutorInputRequiredTest` (#4157/#4187/#4152 all predate #4176's `BaseReActAgentRunner` change), `InboxMiddlewareTest` (#4093 predates #3738), `HarnessAgentSubagentStreamEventsTest` (#4183 predates #2917). - `SkillBoxTest$UploadContainment` quartet (#4201/#4202/#4212/#4229): test does not exist on main (fork stack only); deterministic cross-drive path bug, not load flakiness. - #4184/#4185: both-OS compile breaks from dependency major bumps (dependabot), out of scope. Also applied during review: sibling sites with the identical measured mechanism were widened in the same pass — the remaining 1s fixture claim leases in `WorkerRuntimeTest` (fenced begin/update/release sequences, same #4219 signature), the start/PAUSED 5s budgets in the same `AgentScopeAdapterTest` method as the victims, and the 5s/4s observe budgets in `completeLocalBackendRunsNativeAgentWhileManagedObserverIsBlocked`. ## Test plan - [x] Full local `mvn -B -T2C clean verify` green (stricter than CI's -T1C). Locally excluded, each verified to fail identically on pristine main on this machine (Windows/git-bash) while passing on CI: `JsonFileAgentStateStoreTest` (symlink permissions), the `agentscope-extensions-durable-sandbox` trio plus `ToolInSandboxExampleTest`/`SandboxRoundTripTest` (sandbox shell heredoc incompatible with local git-bash python3), and the `AgentScopeAdapterTest`/`ProcessRecoveryTest`/`HarnessExternalToolProcessRecoveryTest` trio (durable-adapter classes whose Windows runs are skipped on CI; the same named tests fail on pristine main locally). - [ ] CI green on both OS.
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.
Why
Four test failures, in four different modules, all intermittent and all reported in #4175 because they take down PRs that do not touch them. This branch fixes each one at its cause instead of retrying the build.
Everything here is small; only one change touches production code, and only to make a legitimate resume stop being rejected.
How often this happens
Of the 120 most recent
Java CI with Mavenruns (13–14 November), 41 failed, and 25 of those failures were one of these four classes. They are spread over 19 pull requests and onemainbuild; 17 of those PRs — seven dependency bumps and ten feature or fix branches — failed on code they do not touch:AgentScopeAgentExecutorInputRequiredTestRocketMqExecutionTestProcessRecoveryTestHttpServerApplicationTestEach of those builds cost its author a re-run, and because these classes fail on timing rather than on a change, the re-run often reproduces the same red build.
1. A2A: a resume that arrives while the paused run is still unwinding is rejected
BaseReActAgentRunner.streamEventsstarts withbut the entry is removed in
.doFinally, i.e. only once the previous stream has fully unwound. A client that receivesinput-requiredconfirms immediately, which cancels the stream it was reading; the confirmation can arrive in the gap beforedoFinallyruns. The runner then throws synchronously,AgentScopeAgentExecutor.executecatches it and answers withemitter.sendMessage(...)— a plainMessage, not a terminal task state — so the client sees a stream that simply ends. That is the failure:which also appeared as
streamingApprovalResumesAndCompleteson another run, and on #3287, #4102 and #4103.The task now carries a latch:
doFinallyandstoprelease it, and a new request waits up to 2 seconds for that release instead of failing immediately. A genuinely concurrent run still fails, just after the wait; a resume that was only waiting for cleanup proceeds. TheputIfAbsentguard is unchanged, so two runs can never hold the same task.2. RocketMQ: the fake broker re-offers messages that are still in flight
Broker.consumerre-enqueues a message 50ms after handing it out unless it was acked, without knowing whether the consumer is still working on it. When the ack lands later, the same message is delivered twice. That failed this branch's own ubuntu build:One CANCEL produced two acks. Narrowing the window to 1ms reproduces it deterministically, together with the recovery stall:
A real invisible duration is measured in seconds; these tests only need redelivery inside their 10s waits. The window is now a named constant set to one second, with the constraint documented next to it.
3. Process recovery: a runtime wakeup is not a test failure
ProcessRecoveryTestpollsbackend.turn(...)while callingreplacement.tick(...), and the runtime interrupts the ticking thread to deliver a wakeup, soThread.sleepthrows. Seen four times, always at the same line:on #4102, on
main(run 43396004630), on run 43592515698, and on #4177. The fixture loop in the same file already cleared the flag for this reason; the two polling loops in the test body did not. All three sleeps now go through onepausehelper. Deadlines and the terminalSUCCEEDEDassertion are unchanged, so a real stall still fails.4. Http server: the temp directory is deleted before the context closes
HttpServerApplicationTestkeeps the runtime's data directory in a static@TempDir. JUnit deletes it when the class ends, but the Spring context is cached and still open, so the SQLite file and the server threads are there and the deletion fails:Windows never shows it because the durable example modules are skipped there, so Linux CI is the only place this test runs.
@DirtiesContext(AFTER_CLASS)closes the context first; the test body is unchanged.Verification
Local checks, plus repeated runs on the same GitHub-hosted runners that fail these classes. The repeats used a temporary workflow in this branch that ran each class N times in a row on one runner; that file is not part of the diff.
AgentScopeAgentExecutor*(A2A) locallyAgentScopeAgentExecutorInputRequiredTest, 20 consecutive ubuntu-latest runsRocketMqExecutionTest, 20 consecutive ubuntu-latest runsProcessRecoveryTest, 10 consecutive ubuntu-latest runsHttpServerApplicationTest, 10 consecutive ubuntu-latest runsRocketMqExecutionTestbefore the window fixspotless:checkThe repeat counts are not arbitrary: A2A failed this class in roughly half of its Linux runs before the fix, and RocketMQ failed within a handful of runs at the old window, so 20 consecutive passes are unlikely by chance.
Closes #4175