Skip to content

fix(alpha): cap pytest-xdist workers in agent runs - #338

Merged
tbhb-agent merged 1 commit into
mainfrom
agent/tools-xdist-cap
Nov 23, 2026
Merged

tbhb-agent merged 1 commit into
mainfrom
agent/tools-xdist-cap

Conversation

@tbhb-agent

Copy link
Copy Markdown
Collaborator

Why

Agent runs that call pytest -n auto start one worker per CPU. On a 30-CPU Linux build host that's 30 workers at about 200 MB each, which fills the agent account's 8 GB limit and drives fleet load past 50, so reviews can't find a host.

Behavior change

Every agent run, for both harnesses, now starts with PYTEST_XDIST_AUTO_NUM_WORKERS=4 in its environment. pytest-xdist reads that variable for -n auto, so existing commands stay the same and use at most 4 workers. An explicit -n 8 still wins.

Deviations from the task

The request suggested min(auto, 8) or a memory-aware count. A fixed 4 is the simpler setting, and three concurrent runs then use 12 workers, not 90.

Risk

Test suites in agent runs finish slower on large hosts. The value is one constant in policy.py, so raising it takes one line.

Verification

pytest passes 1,611 tests across the policy, command-line, run-host and driver files, with the expected environment updated for both harnesses. ruff passes. CI runs the full Bazel suite.

Opened-by: LLM effort=medium;harness=claude-code:2.1.322;model=anthropic:claude-sonnet-5-5;session=sha-256-64:24ed779d56b187de;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.322;model=anthropic:claude-sonnet-5-5;session=sha-256-64:24ed779d56b187de;started_at=2026-11-15T16:51:11Z;surface=cli

Generated-by: LLM effort=medium;harness=claude-code:2.1.322;model=anthropic:claude-sonnet-5-5;session=sha-256-64:24ed779d56b187de;started_at=2026-11-15T16:51:11Z;surface=cli
@tbhb-agent
tbhb-agent requested a review from tbhb as a code owner November 23, 2026 14:28
@tbhb-agent
tbhb-agent merged commit f0644c6 into main Nov 23, 2026
5 checks passed
@tbhb-agent
tbhb-agent deleted the agent/tools-xdist-cap branch November 23, 2026 15:12
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.

1 participant