Skip to main content

MAX_REDELEGATIONS

Constant MAX_REDELEGATIONS 

Source
pub const MAX_REDELEGATIONS: u32 = 3;
Expand description

Maximum engineer attempts for ONE delegate_to_agent call — 1 initial invocation plus up to 2 reuse-aware retries (#2265, re-scoped by #2852).

Why: This — not the PM’s own turn budget — is the ceiling on retry count. 3 attempts is deliberately modest: each retry costs up to 40 engineer turns (#2233’s raised default), so a generous bound would reintroduce the runaway-cost failure mode #2265 closed. #2852 re-scoped it from “per run” to “per delegation”: as a RUN-wide bound it silently guillotined PMs that used delegation for legitimate reconnaissance before building, since a successful delegation consumed budget a later one then lacked. Retries are what needs bounding; delegations are not. What: Checked against a counter local to each [RedelegatingRunner::run_with_retries] call, reset at loop entry. Once exceeded, that delegation stops without invoking the inner runner and returns a recoverable error — the PM’s loop continues and may delegate again with a full, fresh budget (see [MAX_FAILED_INVOCATIONS] for the run-wide backstop that keeps “again” from being unbounded). Test: redelegating_runner_stops_at_per_call_cap_without_latching_stop_signal, successful_delegations_never_consume_a_later_delegations_budget.