Skip to content

docs: clarify --workers parallelism scope and workspace-mode semantics#1050

Merged
christso merged 8 commits intomainfrom
docs/1039-workers-workspace-semantics
Apr 12, 2026
Merged

docs: clarify --workers parallelism scope and workspace-mode semantics#1050
christso merged 8 commits intomainfrom
docs/1039-workers-workspace-semantics

Conversation

@christso
Copy link
Copy Markdown
Collaborator

Closes #1039

Summary

Answers the three questions raised in #1039 about --workers and --workspace-mode semantics:

1. What is the scope of --workers N?

--workers N is a global concurrent test-case budget distributed across the entire run:

  • Single eval file: up to N test cases run in parallel within that file.
  • Multiple eval files: min(N, files) eval files run concurrently, each receiving floor(N / concurrent_files) workers for intra-file parallelism.

So with 3 eval files and --workers 6: 3 files run concurrently, each with 2 workers → up to 6 concurrent test cases total.

Use --workers 1 to run everything sequentially (one eval file at a time, one test case at a time).

2. What are the semantics of --workspace-mode?

The workspace-pool.mdx guide already documents all three modes. This PR adds cross-file concurrency context:

  • pooled (default for evals with repos): Each active worker acquires its own pool slot, regardless of which eval file it belongs to. No cross-file contention.
  • temp: Each test case gets its own scratch directory. No contention.
  • static: Single fixed path shared by all workers and all eval files. Race-prone when multiple eval files run concurrently against the same path.

3. Is there a way to opt into eval-file-level serialization?

Yes: --workers 1 serializes both files and test cases. Alternatively, use --workspace-mode pooled (the default) which gives each worker its own slot and avoids cross-file contention automatically.

Changes

  • apps/cli/src/commands/eval/commands/run.ts: Updated --workers help text to explain the global-budget-split-across-files semantics.
  • apps/web/src/content/docs/docs/evaluation/running-evals.mdx: Added a "Parallelism" section with single-file vs multi-file examples and a static-workspace race condition warning.
  • apps/web/src/content/docs/docs/guides/workspace-pool.mdx: Extended the Concurrency section to explain multi-file slot allocation and the static-workspace cross-file hazard.

Red / Green UAT

Before: agentv eval --help shows:

--workers <number>   Number of parallel workers (default: 3, max: 50). Can also be set per-target in targets.yaml

After:

--workers <number>   Maximum concurrent test cases across the run (default: 3, max: 50). With a single eval file, N test cases run in parallel. With multiple eval files, the budget is split: up to min(N, files) eval files run concurrently, each receiving floor(N / concurrent_files) workers. Use --workers 1 to serialize everything. Can also be set per-target in targets.yaml

🤖 Generated with Claude Code

#1039)

Answers the questions from #1039:
- --workers N is a global concurrent test-case budget: with a single
  eval file, N test cases run in parallel; with M eval files,
  min(N, M) files run concurrently each with floor(N/min(N,M)) workers.
- Documents the static workspace race condition when multiple eval files
  share the same path and run concurrently, with --workers 1 as the
  serialization escape hatch.
- Updates workspace-pool.mdx concurrency section to explain multi-file
  slot allocation and the static-workspace cross-file hazard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 12, 2026

Deploying agentv with  Cloudflare Pages  Cloudflare Pages

Latest commit: f09ffa7
Status: ✅  Deploy successful!
Preview URL: https://82922c69.agentv.pages.dev
Branch Preview URL: https://docs-1039-workers-workspace.agentv.pages.dev

View logs

christso and others added 7 commits April 12, 2026 07:10
… run concurrently

Surfaces workspace.path from EvalSuiteResult so the CLI can detect
cross-file workspace collisions before starting concurrent execution.
Emits a console.warn pointing users to --workers 1 as the fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…te literals

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the global worker-budget-split scheduler with workspace-aware
grouping: eval files sharing the same static workspace.path run
sequentially within their group; groups with distinct paths (or no
static workspace) run in parallel. Each file gets the full --workers N
budget with no splitting.

Also removes the now-unnecessary concurrent-workspace warning added
in the previous commit and updates docs + CLI help to reflect the new
semantics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rrency

runWithLimit limits how many groups run in parallel to --workers N.
Each file within a group still gets the full --workers budget for
within-file test-case parallelism. Max concurrent test cases is
bounded by workers² rather than unbounded across all groups.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace workspace-group scheduler with a plain for-of loop.
Eval files always run sequentially; --workers N controls within-file
test-case parallelism. This matches the standard model used by
promptfoo and convex-evals and eliminates all cross-file workspace
race conditions without any grouping complexity.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove runWithLimit (unused after switching to plain for-of loop) and
workspacePath from fileMetadata Map type (set but never read).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@christso christso marked this pull request as ready for review April 12, 2026 08:21
@christso christso merged commit 1732dc3 into main Apr 12, 2026
4 checks passed
@christso christso deleted the docs/1039-workers-workspace-semantics branch April 12, 2026 08:21
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.

Clarify --workers parallelism scope (test-level vs eval-file-level) and --workspace-mode semantics

1 participant