Skip to content

fix(workflow): remove unused MIN_THREADS / CPU_THRESHOLD env vars#478

Open
brycehemme wants to merge 1 commit into
strands-agents:mainfrom
brycehemme:fix/workflow-remove-unused-thread-pool-env-vars
Open

fix(workflow): remove unused MIN_THREADS / CPU_THRESHOLD env vars#478
brycehemme wants to merge 1 commit into
strands-agents:mainfrom
brycehemme:fix/workflow-remove-unused-thread-pool-env-vars

Conversation

@brycehemme
Copy link
Copy Markdown

@brycehemme brycehemme commented May 23, 2026

Description

Issue #327 reported that MIN_THREADS (STRANDS_WORKFLOW_MIN_THREADS) and CPU_THRESHOLD (STRANDS_WORKFLOW_CPU_THRESHOLD) are defined in workflow.py but never read, and that the module/class docstrings advertise behaviors the implementation doesn't have ("automatic thread pool scaling 2-8 threads", "CPU usage monitoring and optimization", "dynamic scaling and resource monitoring" on TaskExecutor).

Per the maintainer's suggestion on the issue (Option 1), this PR deletes the dead code rather than implementing the advertised features:

  • Drop MIN_THREADS and CPU_THRESHOLD module constants.
  • Drop the unused min_workers parameter and self.min_workers attribute on TaskExecutor (verified internal-only via grep; the single call site TaskExecutor() passes no args).
  • Fix the module-level docstring: change "dynamic thread pooling" → "fixed-size thread pool"; replace the inaccurate "Resource Optimization" section with a "Rate Limiting" section reflecting what's actually implemented.
  • Fix the TaskExecutor class docstring.

MAX_THREADS / STRANDS_WORKFLOW_MAX_THREADS (the one env var that does flow through to ThreadPoolExecutor) is preserved unchanged.

Note that this removes two environment variables. Any user who currently sets STRANDS_WORKFLOW_MIN_THREADS or STRANDS_WORKFLOW_CPU_THRESHOLD is already getting silently no-op'd today, so the observable behavior doesn't change.

Related Issues

Fixes #327

Type of Change

Bug fix

Testing

Ran hatch run prepare end-to-end via python:3.12 in Docker:

docker run --rm -v "$PWD:/work" -w /work python:3.12 bash -c \
  "git config --global --add safe.directory /work && pip install --quiet hatch && hatch run prepare"
  • format: clean (no changes)
  • lint: clean
  • test-lint (ruff format --check): clean
  • test: 1210 passed, 33 skipped, 1 failure

The single failure is tests/test_file_write.py::test_file_write_error_handling. I verified it reproduces on main without this PR (same Python 3.12 / hatch environment), so it's pre-existing and unrelated to this change.

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works (no new tests needed — change is removal of unused code; the existing 32 test_workflow.py tests cover TaskExecutor())
  • I have updated the documentation accordingly (the module/class docstrings; no separate user-facing docs reference these env vars)
  • I have added an appropriate example to the documentation to outline the feature (N/A — removal, not new feature)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

`MIN_THREADS` (`STRANDS_WORKFLOW_MIN_THREADS`) and `CPU_THRESHOLD`
(`STRANDS_WORKFLOW_CPU_THRESHOLD`) were defined but never read. The
`min_workers` parameter on `TaskExecutor.__init__` was assigned to
`self.min_workers` and likewise never used downstream. Drop all three.

Also fix module/class docstrings that advertised features the code
does not implement: "Automatic thread pool scaling (2-8 threads)",
"CPU usage monitoring and optimization", "Resource-aware task
distribution", and "dynamic scaling" on `TaskExecutor`.

`MAX_THREADS` / `STRANDS_WORKFLOW_MAX_THREADS` (the one variable that
does affect `ThreadPoolExecutor`) is preserved unchanged.

Fixes strands-agents#327
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.

[BUG] Workflow - Title: Thread pool configuration variables MIN_THREADS and CPU_THRESHOLD are defined but not used

1 participant