Skip to content

fix: deflake four tests under parallel -T1C builds - #3616

Merged
xzxiaoshan merged 1 commit into
agentscope-ai:mainfrom
xzxiaoshan:fix/build-error-162118
Oct 16, 2026
Merged

xzxiaoshan merged 1 commit into
agentscope-ai:mainfrom
xzxiaoshan:fix/build-error-162118

Conversation

@xzxiaoshan

Copy link
Copy Markdown
Collaborator

Deflakes the four failures from the 162118 CI batch. All are load-induced races under -T1C; each fix is argued from code logic, not from reruns.

JevSupervisionMiddlewareTest (ubuntu, 2 failures)

runtimeIterationLimitCannotTurnIntoCompletionEvenWithPositiveJudgments (expected MANUAL_REVIEW, got CONTINUE) and synchronousWorkerIsSubscribedOnceAndAllEventsAreIdentical (expected 1 observation, got 2).

The supervision tick stream is Flux.interval(minInterval) cancelled by worker completion, plus a final tick emitted by that cancellation (concatWith). The tests use the shared helper with a 10ms interval, and their workers are synchronous (Flux.just). When a loaded runner preempts the subscribing thread mid-subscription, the 10ms periodic tick fires first and publishes a superseded mid-run observation ahead of the terminal one, which breaks both assertions.

Fix: construct the middleware with an interval beyond any test lifetime (Duration.ofDays(1)). The terminal tick is emitted on worker completion, not on a timer, so a mid-run tick becomes structurally impossible and the test duration is unchanged. The same upgrade is applied to concurrentCalls..., which previously used a probabilistic 250ms widening for the identical race.

ChatSessionsTest.pendingExternalRequestSurvivesRestartAndContinuesSameTurn (windows)

Timed out waiting for suspended with the turn shown as interrupted.

Root cause (reproduced locally under full-core load, transient interrupted before every suspended): ChatSessions.snapshot computed the active run from one head() read while ChatHistory.snapshot re-read the head and scanned facts separately. A snapshot that straddles a run's writer acquisition (GC pause / preemption between the two reads under -T1C) sees run/start in the facts but no lease owner, and mislabels the starting turn as interrupted. The CI log shows the failing run stalled 17s between PRE_CALL and PRE_REASONING, so the 15s await deadline landed mid-startup and caught exactly this window.

Fix: derive activeRun from the same single head read that bounds the facts scan, making the lease view and the facts view consistent by construction. Verified by rerunning the reproduction harness: zero mislabels after the fix (previously reproduced within 2-5 iterations).

Additionally, the phase-1 await is raised to 60s: the CI run needed 23.45s for a single suspension under contention, above the 15s default. This matches the existing 60s budgets already used in this class for the same scenario, and adds no time to the happy path (poll-based exit).

ToolConfirmationCoordinatorTest.nonOwnerPersistsDecisionButOwnerPollerAloneReleasesContinuation (windows)

continuationReady was expected false but was true: the owner poller daemon polls the shared ticket every 200ms, so asserting it has not yet released is timing-dependent by construction — any preemption longer than one poll cycle breaks it. The guarantee the assertion aimed at is already pinned deterministically by OWNER_UNAVAILABLE (the non-owner returns before any release side effect) plus the poller-driven release and idempotency assertions below it. The racy intermediate assertion is dropped with an explanatory comment.

Testing

  • mvn -pl agentscope-examples/agents/agentscope-chat test — 10/10 (×6)
  • mvn -pl agentscope-examples/jev test — 185/185 (fixed class ×9)
  • mvn -pl agentscope-service/service-dataplane test — 135 pass / 2 skipped, same as CI (fixed class ×9)
  • Loaded reproduction harness on the chat snapshot: transient false interrupted eliminated

- JevSupervisionMiddlewareTest (two failing tests plus concurrentCalls):
  the shared helper's 10ms periodic supervision tick can fire before a
  preempted subscribing thread emits a synchronous worker's terminal
  event, adding a superseded mid-run observation ahead of the terminal
  one. Schedule the middleware with an interval beyond any test
  lifetime: the terminal tick is emitted on worker completion, not on a
  timer, so the periodic tick becomes structurally impossible with no
  added test time.
- ChatSessionsTest.pendingExternalRequestSurvivesRestartAndContinuesSameTurn:
  ChatSessions.snapshot derived the active run from a head read separate
  from the facts scan; a snapshot straddling a run's writer acquisition
  sees run/start without a lease owner and mislabels the starting turn
  as interrupted. Derive activeRun from the same head read that bounds
  the scan, and raise the two lifecycle awaits to 60s to cover the 23s
  observed under -T1C contention (same precedent as the rest of the
  class).
- ToolConfirmationCoordinatorTest.nonOwnerPersistsDecisionButOwnerPollerAloneReleasesContinuation:
  drop the assertion that the 200ms owner poller has not released yet;
  that intermediate state is timing-dependent by design, while the
  guarantees are pinned by OWNER_UNAVAILABLE and the release assertions.
@xzxiaoshan
xzxiaoshan merged commit 5af7ffd into agentscope-ai:main Oct 16, 2026
7 checks passed
@xzxiaoshan
xzxiaoshan deleted the fix/build-error-162118 branch October 16, 2026 15:05
xzxiaoshan added a commit that referenced this pull request Oct 17, 2026
Follow-up to #3616. In its post-merge CI run,
`ChatSessionsTest.injectionDoesNotStartExecutionAndSurvivesRestart`
timed out on `session.await(task).block(Duration.ofSeconds(15))`: the
turn completed normally but needed 16.5s under -T1C contention (submit
to run/end), missing the hard ceiling by 1.5s. All four fixes from #3616
passed in that same run; this is the next wait site in the same class,
previously left alone because it had a nominal ~1.2s load and no failure
record.

`AgentSession.await` polls the task every 100ms and completes as soon as
it settles, so the ceiling only bounds the failure deadline — the block
returns immediately on completion. Raising it to 60s adds no time to the
happy path (measured ~4.5s locally, ~7-19s across CI runs) and matches
the 60s budgets already used for the same scenario in this test class.
No assertions change.
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.

2 participants