packages/core/src/errors.ts:272 LeaseExpiredError, packages/core/src/errors.ts:286 BudgetExhaustedError, and packages/core/src/errors.ts:300 AgentVersionNotAvailableError are documented as "always non-retryable" because a naive retry would fail identically. Each constructor passes { retryable: false, ...opts } to super(...), but the spread order is wrong: ...opts comes after retryable: false, so a caller who passes new LeaseExpiredError("...", { retryable: true }) ends up with retryable: true on the wire. The opposite order — { ...opts, retryable: false } — would enforce the invariant the docs promise. The same problem applies in all three classes; the rest of the always-non-retryable family in the same file is unaffected because they don't accept opts.
Fix prompt: in the three constructors at packages/core/src/errors.ts:272, packages/core/src/errors.ts:286, and packages/core/src/errors.ts:300, change { retryable: false, ...opts } to { ...opts, retryable: false } so that the invariant survives caller overrides. Add a unit test in packages/core/test/errors.test.ts for each class that constructs it with { retryable: true } and asserts .retryable === false after construction. Confirm the round-trip via arcpFromTagged still preserves the false value.
packages/core/src/errors.ts:272LeaseExpiredError,packages/core/src/errors.ts:286BudgetExhaustedError, andpackages/core/src/errors.ts:300AgentVersionNotAvailableErrorare documented as "always non-retryable" because a naive retry would fail identically. Each constructor passes{ retryable: false, ...opts }tosuper(...), but the spread order is wrong:...optscomes afterretryable: false, so a caller who passesnew LeaseExpiredError("...", { retryable: true })ends up withretryable: trueon the wire. The opposite order —{ ...opts, retryable: false }— would enforce the invariant the docs promise. The same problem applies in all three classes; the rest of the always-non-retryable family in the same file is unaffected because they don't acceptopts.Fix prompt: in the three constructors at
packages/core/src/errors.ts:272,packages/core/src/errors.ts:286, andpackages/core/src/errors.ts:300, change{ retryable: false, ...opts }to{ ...opts, retryable: false }so that the invariant survives caller overrides. Add a unit test inpackages/core/test/errors.test.tsfor each class that constructs it with{ retryable: true }and asserts.retryable === falseafter construction. Confirm the round-trip viaarcpFromTaggedstill preserves the false value.