Gate concurrency and cache reuse together
Use when: a dynamic workflow runs in Docker, Kubernetes, a self-hosted runner, or any fan-out where sibling agents receive a long shared rubric. Before 2.1.229, CPU-limited containers could size concurrency from host cores, while simultaneous same-prefix siblings could each pay to create the same prompt cache. The result was misleading parallelism: too many local workers, repeated prefix cost, and rate-limit bursts before useful work began.
CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS
unset—the
vendor
states
that
zero
disables
the
new
staggering.
Start
with
a
small
/config
workflowSizeGuideline=small
and
raise
it
only
after
measuring
peak
live
agents,
queue
depth,
cache
creation/read
tokens,
429s,
and
wall
time.
Do
not
treat
the
size
guideline
as
a
cap;
the
current
workflow
guide
calls
it
advice,
while
runtime
limits
remain
separate.
Acceptance
check:
on
a
high-core
host,
run
the
same
disposable
three-lane
workflow
in
containers
capped
at
four
and
eight
CPUs.
Each
lane
should
start
with
an
identical
roughly
14k-token
prefix
and
end
with
a
unique
sentinel.
Record
peak
live
agents
and
inspect
each
workflow
agent
journal
under
~/.claude/projects/.
Pass
only
if
peak
concurrency
changes
with
the
container
budget
rather
than
staying
fixed
to
host
cores,
excess
lanes
queue,
all
sentinels
return,
the
first
same-prefix
sibling
performs
the
large
cache
creation,
and
later
siblings
show
cache
reads
instead
of
equivalent
fresh
creations.
Repeat
once
with
CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS=0;
the
cache-read
advantage
should
disappear.
Keep
that
negative
canary
out
of
production.
Caveat: prefix staggering is a cache optimization, not rate-limit-aware admission control. Open issue #70498 reports heavy-read fan-outs still bursting input-token limits, dropping agents after 429 retries, and forcing manual concurrency reduction. Cache reuse also requires a genuinely shared leading prefix; early per-agent variation defeats it. CPU compliance does not bound nested subprocesses, memory, total agents, or spend, so retain independent budgets and fail-visible completion receipts.