Skip to content

test(subagent-announce): fix flaky Windows-only test failure (#31298)#31370

Merged
Takhoffman merged 2 commits intoopenclaw:mainfrom
zwffff:fix/31298-windows-test-flaky
Mar 2, 2026
Merged

test(subagent-announce): fix flaky Windows-only test failure (#31298)#31370
Takhoffman merged 2 commits intoopenclaw:mainfrom
zwffff:fix/31298-windows-test-flaky

Conversation

@zwffff
Copy link
Contributor

@zwffff zwffff commented Mar 2, 2026

Summary

Fixes flaky Windows-only test failure in subagent-announce.format.e2e.test.ts.

Problem

The test "waits for updated synthesized output before announcing nested subagent completion" was failing intermittently on Windows CI because:

  1. FAST_TEST_MODE is evaluated at module load time in subagent-announce.ts
  2. The test was setting vi.stubEnv(\"OPENCLAW_TEST_FAST\", \"1\") in beforeEach, which runs after beforeAll where the module is imported
  3. On Windows, setTimeout(100) routinely overshoots to 115-150ms due to default timer resolution (~15.6ms)
  4. Without fast mode, the poll loop only had 1-2 iterations — not enough to reach the 3rd chatHistory mock call

Solution

Move process.env.OPENCLAW_TEST_FAST = \"1\" to beforeAll before the dynamic module import, so the module-level constant captures the fast mode setting.

Changes

Testing

  • All 52 tests in subagent-announce.format.e2e.test.ts pass
  • This fix ensures consistent fast mode behavior across all platforms

Fixes #31298

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Mar 2, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR correctly fixes a Windows-specific flaky test by ensuring OPENCLAW_TEST_FAST is set before the module import. The root cause was that subagent-announce.ts evaluates FAST_TEST_MODE at module load time, but the test was setting the env var in beforeEach after the module had already been imported in beforeAll. Without fast mode, Windows timer resolution (~15.6ms) caused insufficient polling iterations to complete the test reliably. The fix follows the established pattern used in other test files like reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is straightforward and follows established patterns in the codebase. It moves environment variable initialization to the correct lifecycle hook (beforeAll before module import) to ensure the module-level constant captures the value. The changes are minimal, well-documented, and include proper cleanup in afterAll.
  • No files require special attention

Last reviewed commit: 83d7500

@Takhoffman Takhoffman force-pushed the fix/31298-windows-test-flaky branch from 83d7500 to b3b699c Compare March 2, 2026 16:32
@Takhoffman Takhoffman merged commit 8828418 into openclaw:main Mar 2, 2026
9 checks passed
@Takhoffman
Copy link
Contributor

PR #31370 - test(subagent-announce): fix flaky Windows-only test failure (#31298) (#31370)

Merged after verification.

  • Merge commit: MERGE_SHA_PLACEHOLDER
  • Verified: pnpm install --frozen-lockfile, pnpm build, pnpm check (baseline issues outside PR), pnpm test:e2e src/agents/subagent-announce.format.e2e.test.ts
  • Autoland updates:
    M CHANGELOG.md
  • Rationale:
    Windows flake fix needed a changelog entry for merge policy compliance.
  • Changelog: CHANGELOG.md updated=true required=true opt_out=false

@Takhoffman
Copy link
Contributor

PR #31370 - test(subagent-announce): fix flaky Windows-only test failure (#31298) (#31370)

Merged after verification.

  • Merge commit: 8828418
  • Verified: pnpm install --frozen-lockfile, pnpm build, pnpm check (baseline issues outside PR), pnpm test:e2e src/agents/subagent-announce.format.e2e.test.ts
  • Autoland updates:
    M CHANGELOG.md
  • Rationale:
    Windows flake fix needed a changelog entry for merge policy compliance.
  • Changelog: CHANGELOG.md updated=true required=true opt_out=false

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3b699c19f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


### Fixes

- Tests/Subagent announce: set `OPENCLAW_TEST_FAST=1` before importing `subagent-announce` format suites so module-level fast-mode constants are captured deterministically on Windows CI, preventing timeout flakes in nested completion announce coverage. (#31370) Thanks @zwffff.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Drop non-user-facing changelog note

This changelog item describes an internal test-only stabilization (setting OPENCLAW_TEST_FAST before importing a test module) rather than a user-visible behavior change, so it should not be in release notes. The repository guideline in AGENTS.md says “Changelog: user-facing changes only” and that pure test additions/fixes generally do not need a changelog entry, so this line introduces policy-breaking noise in published release history.

Useful? React with 👍 / 👎.

execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
…w#31298) (openclaw#31370) thanks @zwffff

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check (fails on main baseline issues in extensions/googlechat and extensions/phone-control)
- pnpm test:e2e src/agents/subagent-announce.format.e2e.test.ts

Co-authored-by: zwffff <5809959+zwffff@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
…w#31298) (openclaw#31370) thanks @zwffff

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check (fails on main baseline issues in extensions/googlechat and extensions/phone-control)
- pnpm test:e2e src/agents/subagent-announce.format.e2e.test.ts

Co-authored-by: zwffff <5809959+zwffff@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
…w#31298) (openclaw#31370) thanks @zwffff

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check (fails on main baseline issues in extensions/googlechat and extensions/phone-control)
- pnpm test:e2e src/agents/subagent-announce.format.e2e.test.ts

Co-authored-by: zwffff <5809959+zwffff@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…w#31298) (openclaw#31370) thanks @zwffff

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check (fails on main baseline issues in extensions/googlechat and extensions/phone-control)
- pnpm test:e2e src/agents/subagent-announce.format.e2e.test.ts

Co-authored-by: zwffff <5809959+zwffff@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(test): flaky Windows-only failure in subagent-announce.format.test.ts

2 participants