Skip to content

test(google): make first-response deadline coverage deterministic - #150663

Merged
steipete merged 1 commit into
mainfrom
upd/flake-gemini-first-response-deadline
Sep 17, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/flake-gemini-first-response-deadline

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #150523

What Problem This Solves

Fixes a flaky Google transport regression test whose real-time safety abort could preempt Gemini first-response deadline recovery on a loaded worker.

User Impact

Developers get deterministic coverage of pending response-callback recovery. Runtime behavior, timeout settings, and configuration are unchanged.

Why This Change Was Made

The fixture started a real five-second parent abort before transport setup, while the Google-owned first-response deadline starts later, before fetch. If the safety abort fires, the transport correctly suppresses retry because the parent is canceled.

The test now waits until its first onResponse callback is pending, advances fake time to 9 ms and then the existing 10 ms deadline, and checks cancellation and recovery. It retains the recovered-content, two-fetch, two-callback, and single-cancellation assertions, adds a successful stop assertion, and uses the existing teardown to restore real timers. Production LOC: 0 changed. Test LOC: +24 / −24, in one existing test.

Evidence

Pinned baseline: 90b421ae252ceaea5bf5a9f106eab51bf384431b. Validated head: b12daa16187c09b652a5b92e8f89b808595ec9e9 (committed test bytes match all 20 stress runs).

Cohort Google deadline case Entire run Other failures
Original Google file, 10 runs 10/10 passed 10/10 green; 173 tests each None
Original full provider shard, 10 runs 10/10 passed 7/10 green 3 known Qwen budget assertions
Fixed full provider shard, 20 runs 20/20 passed 11/20 green 9 known Qwen budget assertions

The reported spontaneous Google failure did not recur in these baseline runs. A controlled fake-clock probe advancing five seconds during onPayload setup made the original fixture abort with zero response callbacks and fail with:

AssertionError: expected [] to deeply equal [ { type: 'text', text: 'recovered' } ]
stopReason: aborted
errorMessage: Request was aborted
parentReason: test safety deadline reached

The clock-driven replacement passed with the same setup-delay probe. Temporarily removing the attempt deadline signal from response notification made the revised test fail at the 10 ms boundary:

AssertionError: expected "vi.fn()" to be called 2 times, but got 1 times

All probes were removed and production source was restored byte-for-byte. All 20 final stress runs used identical candidate bytes. Each full shard had 71 files / 1,296 tests, two workers, and file isolation. The 1,297-test count in the related Qwen validation includes the additional test from #150523. That PR has since merged; the pinned baseline here still contains its original timing assertion (119995–119999 versus 120000).

node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.extension-providers.config.ts \
  --shard=4/4 --maxWorkers=2 --fileParallelism=true --isolate=true

node scripts/check-changed.mjs: every step passed except extension lint's documented nested-checkout declaration-input guard. The campaign-prescribed substitute was verified on the changed file:

node_modules/.bin/oxlint --tsconfig test/tsconfig/tsconfig.extensions.test.json \
  extensions/google/transport-stream.test.ts
CANARY exit=1
extensions/google/transport-stream.test.ts:3669:7: error eslint(no-unused-vars): Variable 'l523LintCanary' is declared but never used. Unused variables should start with a '_'. help: Consider removing this declaration.

CLEAN exit=0
(no diagnostics after restoring the candidate)

Hosted extension lint remains the authoritative full boundary check. git diff --check passed. Codex autoreview was scoped-clean at P1 before commit and for the committed branch (--mode branch --base origin/main --max-priority P1), with no accepted/actionable findings.

@steipete
steipete marked this pull request as ready for review September 17, 2026 06:03
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 3:18 AM ET / 07:18 UTC (Revision 2).

ClawSweeper review

What this changes

The PR makes Google's pending-response recovery test deterministic by replacing its wall-clock safety abort with controlled advancement across the retry deadline.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, focused test repair that current main does not contain. No actionable correctness or security findings remain; the maintainer-authored PR is also protected from automated closure.

Priority: P3
Reviewed head: 670ec180e08528ee7cd819fd30a91a8080901639

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test repair with preserved behavioral assertions, useful reported stress and mutation validation, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary real-setup gate does not apply to this maintainer-authored test-only PR; its reported controlled-clock and mutation runs exercise the Google callback-deadline test, with unchanged validated test bytes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary real-setup gate does not apply to this maintainer-authored test-only PR; its reported controlled-clock and mutation runs exercise the Google callback-deadline test, with unchanged validated test bytes.
Evidence reviewed 8 items Verified introduced change: The merge-base-to-head diff changes only the existing deadline test. It retains cancellation, fetch-count, callback-count, and recovered-content assertions while adding a pre-deadline check and successful stop assertion.
Production deadline and cancellation contract: The attempt deadline starts before fetch, covers response notification, and permits timeout recovery only while the parent signal is not aborted. The adjacent test independently preserves caller-abort-without-retry coverage; suite teardown restores real timers.
Shared callback implementation: The provider SDK delegates notification to the repository's @openclaw/ai workspace package. Its callback owner races the callback against the attempt signal and cancels the unread response body on failure, matching the test's observable assertions.
Findings None None.
Security None None.

How this fits together

The Google provider plugin converts agent requests into streaming Gemini calls and retries eligible requests that stall before their first response. This test exercises a stalled response callback through that transport and checks cancellation followed by successful recovery.

flowchart TD
  A[Agent request] --> B[Google streaming transport]
  B --> C[First response callback]
  C --> D{Deadline reached?}
  D -->|No| E[Wait for response]
  D -->|Yes| F[Cancel unread response]
  F --> G[Retry and return recovered text]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests 0. Total 0 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 24 24 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 24 24 0

Review metrics

None.

Technical review

Best possible solution:

Keep deadline recovery coverage in the existing transport test, with controlled time and independent caller-cancellation coverage.

Do we have a high-confidence way to reproduce the issue?

Yes, for the fixture race: source shows the parent safety timer starts before transport setup, and the captured body reports a controlled setup-delay reproduction. This read-only review did not execute tests or independently reproduce the spontaneous load-dependent failure.

Is this the best way to solve the issue?

Yes. Controlling time in the existing boundary test removes the competing safety abort while preserving recovery checks; the reported mutation failure supports its ability to detect a broken deadline path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 68b4251368c1.

Labels

Label justifications:

  • P3: This stabilizes developer regression coverage without changing production behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary real-setup gate does not apply to this maintainer-authored test-only PR; its reported controlled-clock and mutation runs exercise the Google callback-deadline test, with unchanged validated test bytes.

Evidence

What I checked:

  • Verified introduced change: The merge-base-to-head diff changes only the existing deadline test. It retains cancellation, fetch-count, callback-count, and recovered-content assertions while adding a pre-deadline check and successful stop assertion. (extensions/google/transport-stream.test.ts:1930, 670ec180e085)
  • Production deadline and cancellation contract: The attempt deadline starts before fetch, covers response notification, and permits timeout recovery only while the parent signal is not aborted. The adjacent test independently preserves caller-abort-without-retry coverage; suite teardown restores real timers. (extensions/google/transport-stream.ts:783, 670ec180e085)
  • Shared callback implementation: The provider SDK delegates notification to the repository's @openclaw/ai workspace package. Its callback owner races the callback against the attempt signal and cancels the unread response body on failure, matching the test's observable assertions. (packages/ai/src/transports/transport-stream-shared.ts:311, 670ec180e085)
  • Still necessary on current main: Fetched main still starts a five-second parent safety abort before invoking the transport. The proposed controlled-clock replacement is absent. (extensions/google/transport-stream.test.ts:1930, 68b4251368c1)
  • Latest release retains the old fixture: The v2026.9.4 source also contains the real five-second safety abort, so the test repair is not already present in the supplied latest release. (extensions/google/transport-stream.test.ts:1928, 3a9d69db306c)
  • Previous review and validation continuity: GitHub reports blob 1853260aecec1e254236bb7ec5a58b0a66a94f67 for the previously reviewed and validated head; the current checkout has the identical test-file blob. The captured body reports 20 passing Google shard executions, a controlled setup-delay failure in the original fixture, and a mutation that makes the replacement fail at its deadline assertion. These are contributor-reported test results, not reviewer-executed or live-provider proof. The previous review retained no findings or published rank-up moves. (extensions/google/transport-stream.test.ts:1930, 670ec180e085)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-17T06:13:26.415Z sha b12daa1 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the upd/flake-gemini-first-response-deadline branch from b12daa1 to 670ec18 Compare September 17, 2026 07:12
@steipete
steipete merged commit 0f09395 into main Sep 17, 2026
91 checks passed
@steipete
steipete deleted the upd/flake-gemini-first-response-deadline branch September 17, 2026 07:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…enclaw#150663)

Fix flaky Google pending-response callback coverage when a loaded worker spends long enough in transport setup for the fixture's parent safety abort to fire first. Parent cancellation correctly suppresses deadline recovery, so that competing timer could make the test fail despite correct runtime behavior.

Wait for callback entry and advance fake time across the existing first-response deadline. Preserve cancellation, retry, callback-count and recovered-content checks, and assert a successful stop. Production behavior, timeout settings and configuration are unchanged; the one existing test changes by +24/-24 lines.

Related: openclaw#150523

Validation: exact-head CI run 35193375763 passed; the validated test bytes are unchanged. The PR records 20/20 Google deadline passes, a controlled setup-delay reproduction and a deadline mutation failure. Codex autoreview and the exact-head ClawSweeper review found no actionable issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: google maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant