Repository navigation
Keep agent-runtime test bridges at the test worker's CPU priority - #8198
Merged
Merged
Conversation
Since #8068 graduated agentCpuPriority, deprioritizeAgentWorkload renices every provider process to nice 10 unconditionally. In @bb/agent-runtime tests that puts each spawned bridge below the nice-0 Vitest workers. On a contended 4-vCPU Linux CI runner the bridges get a small share of CPU, so bridge startup and exit take seconds and tests with wall-clock bounds time out. macOS ignores nice across processes, so this never reproduces locally. The agent-runtime Vitest setup now stubs deprioritizeAgentWorkload, so test bridges run at the worker's priority as they did before #8068. Production renicing is unchanged. "fires onProcessExit when provider crashes" also stops polling with the 1s waitForRuntimeState default. That window covered the bridge's process.exit and the close event, which the runtime itself allows up to PROVIDER_PROCESS_CLOSE_GRACE_MS (1s) to report. The test now awaits the callback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
Since #8068 graduated
agentCpuPriority(merged 2026-11-24 04:53 UTC),deprioritizeAgentWorkloadrenices every provider process to nice 10 unconditionally. Before that it was a no-op unless the daemon turned it on, so@bb/agent-runtimetest bridges ran at the Vitest worker's priority. Now each bridge a test spawns runs below the nice-0 Vitest workers. On a contended 4-vCPU Linux runner (turbo runs four suites at once), the bridges get a small share of CPU, so bridge startup and exit take seconds and tests with wall-clock bounds fail. macOS ignores nice across processes, so this never reproduces locally.In the failing run for #8158 (run 45680230926, attempt 1), every bridge-spawning test near the start of both files took 8–12 s; they normally take 0.2–2 s:
uses the construction deadline for thread/'resume' (requestTimeoutMs=undefined)hit the 15 s test timeout. Its siblings took 10.3 s and 8.3 s.fires onProcessExit when provider crashesspent about 10 s inensureProvider. It then gave the exit callback only thewaitForRuntimeStatedefault of 1 s. That window has to cover the bridge'sprocess.exitplus thecloseevent, which the runtime itself allows up toPROVIDER_PROCESS_CLOSE_GRACE_MS(1 s) to report.Main CI has hit the same problem. Of the 60 most recent failed main CI runs (Nov 16–25), the 49 before Nov 24 had no
@bb/agent-runtimefailures. On Nov 24, 7 of 10 failed main runs wereruntime.process-lifecycle.test.tstests timing out at 15 s on Linux:ranks provider processes ahead of bb for the out-of-memory killer(4 runs),keeps an old-hash bridge process that still owns a thread(3),retires a threadless bridge process superseded by a new artifact hash, andwaits for provider retirement before starting a same-key replacement. The two tests named above did not appear in that scan.What changed
packages/agent-runtime/src/test/keep-provider-process-priority.ts, registered as a VitestsetupFilesentry, stubsdeprioritizeAgentWorkloadfrom@bb/process-utils. Test bridges now run at the worker's priority, as they did before Graduate six early adopter experiments #8068. Production renicing is unchanged. No agent-runtime test asserts nice values;@bb/process-utilskeeps its ownworkload-prioritytest.fires onProcessExit when provider crashesnow awaits theonProcessExitcallback instead of polling it against a 1 s deadline, and asserts it fired once.The construction-deadline test is unchanged. With bridges back at normal priority it runs in about 1.7 s. Its 1.5 s scripted response delay is what lets it tell the 120 s construction deadline from the 30 s request default, and that delay was not part of the failure.
How you verified
I reproduced this on Linux in an OrbStack
node:22-bookwormcontainer pinned to 4 CPUs (--cpuset-cpus=0-3 --init), with nice-0 busy-loop burners standing in for the other suites. At 6 burners, a nice-10 CPU job ran 5.3× slower than the same job at nice 0.command-contractreal-time tests), tests 222–231 sfires onProcessExit5.7–7.2 s, construction tests 7.5–9.5 sThe bridge never received thread/start/thread/resume, and 15 s timeouts forfires onProcessExitandhandles JSON-RPC error responsesensureProviderresolving toonProcessExitfiring was 484 ms in one run and 1762 ms in another. The second would fail the old 1 s wait. With renice off at 110 burners it was 175 ms.runtime.codex-topologyandruntime.skill-roots-capability, which need plugin packages the container's filtered install did not have.pnpm exec turbo run typecheck lint --filter=@bb/agent-runtimepassed, andpnpm exec turbo run test --filter=@bb/agent-runtimepassed: 23 files, 316 passed, 1 skipped (the Linux-only OOM test).Not changed here:
apps/host-daemonlifecycle scripts get the same nice-10 renice, and otherruntime.process-lifecycletests still poll exit callbacks with the 1 s default. Both are the same kind of issue, but neither failed in the runs above once bridges were back at normal priority.🤖 Generated with Claude Code