Repository navigation
Support max_parallel_workers on Agent parallel workers #7641
Description
Is your feature request related to a specific problem?
Agent(parallel_worker=True) starts one worker for every input item. Unlike
function workers and Node subclasses, an agent worker cannot set
max_parallel_workers: Pydantic rejects the field. Workflow.max_concurrency
does not bound these dynamic item runs, as the parallel worker guide documents.
This makes it difficult to limit simultaneous model calls when processing a
large batch. Users currently need to rebuild the fan-out with their own
semaphore around ctx.run_node().
Describe the Solution You'd Like
Accept max_parallel_workers: int | None = None on Agent/LlmAgent when
parallel_worker=True, and forward the value to the existing parallel worker.
Keep None as today's unbounded behavior. Reject values below one and a limit
provided without parallel worker mode, consistently with function workers.
Impact on your work
I am building concurrent agent workflows and need to bound simultaneous model
and tool work without replacing the standard worker primitive. No fixed
release deadline.
Willingness to contribute
Yes. I can contribute the field, wiring, validation, regression tests, a Runner
example demonstrating the observed concurrency bound, and guide updates.
Describe Alternatives You've Considered
Workflow.max_concurrency: does not cover dynamic parallel-worker items.- A semaphore around
ctx.run_node(): works, but requires a custom wrapper for
behavior already supported by the equivalent function-worker API. - A provider rate limiter: useful separately, but not a per-worker concurrency
setting and does not cover arbitrary tool work inside the agent.
Proposed API / Implementation
from google.adk import Agent
analyzer = Agent(
name="analyzer",
instruction="Analyze the text in the user message.",
parallel_worker=True,
max_parallel_workers=4,
)Use the existing _ParallelWorker scheduling and failure behavior. Check that
the limit is forwarded when an agent becomes a Workflow node; preserve input
order, the unlimited default, fail-fast cleanup, and resume behavior.
Additional Context
The current guide explicitly describes this gap:
https://github.com/google/adk-python/blob/main/docs/guides/workflow/parallel_worker/index.md
I searched issues and PRs for max_parallel_workers, parallel_worker, and
agent concurrency limits and did not find this specific request. Please link
any existing work if this is already planned.
Activity