Repository navigation
fix(a2a): inbound correlation test fails intermittently on unrelated PRs - #199882
Merged
fuller-stack-dev merged 1 commit intoNov 16, 2026
Merged
fuller-stack-dev merged 1 commit into
fuller-stack-dev merged 1 commit into
Conversation
The interleaved-reply case starts two inbound runs at once and read dispatch.mock.calls[0] as the first run. Each run awaits a session-entry read in a worker before it dispatches. Since openclaw#198194 those reads share a two-worker lane, so either run can reach dispatch first and the case failed in 12 of 30 local runs. Find each turn by the message it carries and assert that dispatch ran twice. The session-key, sender, and per-task reply assertions are unchanged, and replies are still delivered in reverse order. Also drop the queuedFinal argument from the two dispatch-result helpers. Every caller passed false, so the values they return are the same.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Member
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 16, 2026
…PRs (openclaw#199882) The interleaved-reply case starts two inbound runs at once and read dispatch.mock.calls[0] as the first run. Each run awaits a session-entry read in a worker before it dispatches. Since openclaw#198194 those reads share a two-worker lane, so either run can reach dispatch first and the case failed in 12 of 30 local runs. Find each turn by the message it carries and assert that dispatch ran twice. The session-key, sender, and per-task reply assertions are unchanged, and replies are still delivered in reverse order. Also drop the queuedFinal argument from the two dispatch-result helpers. Every caller passed false, so the values they return are the same.
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.
What Problem This Solves
Fixes: the A2A test "correlates interleaved same-context replies from hermes/crew" in
extensions/a2a/src/inbound.test.tsfails intermittently on PRs that do not touch A2A, and blocks them from landing.Seen in CI shard
changed-extensions-config-32(projectextension-database-workers, jobchecks-node-changed-extensions-bundle-31-1):[{text:'second reply'}], wanted[{text:'first reply'}]. Line 175: got['a2a:crew','a2a:hermes'], wanted['a2a:hermes','a2a:crew']Neither PR changes
extensions/a2a.User Impact
User impact: none for people running OpenClaw. Contributors stop getting this red check on unrelated PRs. A2A reply correlation in production is unchanged, and the evidence below shows it was never wrong.
Why This Change Was Made
The case starts two inbound runs with
Promise.all, then treateddispatch.mock.calls[0]as the first run and[1]as the second. Nothing guarantees that order. Before a run callsdispatchit awaits a session-entry read in a worker (createChannelInboundEnvelopeBuilderAsynccallsreadSessionUpdatedAtInWorker).Until #198194 (67ecf6b, merged 2026-11-14) those reads used the "Session projection" lane, which had one worker, so they finished in the order they started. That commit folded the lane into "Session store", which gets two workers on any host with three or more cores. Two concurrent reads now run on separate threads and either one can finish first.
The case now finds each turn by the message it carries (
ctxPayload.MessageSid) and asserts thatdispatchran exactly twice. The message id reaches the turn throughbuildContext, and the task id reaches it through the delivery closure, so matching on one does not presuppose the other. The rest of the case is untouched: the session-key comparison, theFromvalues, replies delivered in reverse order, and the per-task artifact checks.I left production alone.
docs/channels/a2a.mdpromises that replies go to the task that started the turn, including when messages in one context finish out of order. It promises nothing about which of two concurrent requests dispatches first, andchannel.tsstarts each request as independent detached work with no queue.One cleanup in the same file: the
dispatchedandcreateA2aDispatchResulthelpers took aqueuedFinalargument that every caller passed asfalse. I removed it. The helpers return the same values as before.This PR is test-only on purpose. The failing check is the defect.
Evidence
Head f18eecf on base 7d90a90. Local runs use the pinned Bun fork, the runtime the CI shard uses. Every loop runs
node scripts/run-vitest.mjs extensions/a2a/src/inbound.test.ts.Red, unmodified main at e970cf6
Cause
A temporary probe, not committed, repeated the two-run scenario in one process and recorded which run reached
dispatchfirst.git bisect --first-parentwith that probe, from 9151ac2 (good) to b2f5706 (bad), 2,431 commits, ends at 67ecf6b. Its parent 7f7b16c swapped 0 of 80 rounds. The commit itself swapped 40 of 80.So the hermes failure at line 181, where the first task received "second reply", comes from the mislabelled
firstTurnandsecondTurnvariables. Both hermes runs share a session key and aFromvalue, so line 175 cannot notice the swap. The test then hands "second reply" to the turn that owns the first task.Green, this change
The loops ran on df0211ccf84, which is this commit on main at d2bb335. Main then moved eight commits to 7d90a90. None of them touch
extensions/a2a, session storage, the worker runtime, the channel helpers or the Vitest config, so I rebased and ran the file once more instead of repeating the loops.pnpm test extensions/a2a/src/inbound.test.ts --maxWorkers=1: 15 passed, 42 s wall. Vitest reports 90% of that as transform and 1% as test time.pnpm exec oxfmt --check extensions/a2a/src/inbound.test.tsandgit diff --check: clean.OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 node scripts/check-changed.mjs: passed, including the extension test typecheck and lint of the changed file.The case still catches miscorrelation
Two temporary edits to
extensions/a2a/src/inbound.ts, each run four times against the fixed test and then reverted:File audit
I read all of
extensions/a2a/src/inbound.test.ts: 15 cases, the fixture, both helpers, imports and teardown.dispatch.mock.callsfollow one awaited run, or two runs awaited one after the other in "routes a stable peer binding", so their order is fixed.afterEach, which also resets the plugin registry. There are no timers, sleeps, skips or unused imports.queuedFinalargument described above. No case or assertion was removed.dmScope: "per-channel-peer"but only compares the two session keys with each other, so it would not notice if A2A stopped pinningper-account-channel-peer. "routes a stable peer binding" asserts exact session keys, but without that override. I did not widen this PR to cover it.Not done
check-changedfails on main forresolveRollbackWorkerInputsinsrc/cli/update-cli/update-command-database-rollback.test-support.ts. This PR does not touch that file, so I skipped the scan for the final run.dispatchin either order. Reply correlation holds either way. If arrival order should hold too, that needs a queue inchannel.ts, not a change to this test.