Skip to content

fix(client): stop resending a 429 that settles the request - #37

Merged
ArtemKosolap merged 2 commits into
mainfrom
fix/no-retry-on-allowance-429
Nov 6, 2026
Merged

ArtemKosolap merged 2 commits into
mainfrom
fix/no-retry-on-allowance-429

Conversation

@ArtemKosolap

Copy link
Copy Markdown
Contributor

What changed

send in src/utils/client.ts no longer resends a 429 whose body names a reference or says a daily or weekly allowance has run out. The answer goes back to the caller after one attempt. Any other 429 keeps its retry and its Retry-After handling exactly as before.

The README's two paragraphs on retries say so.

Why

A direct LinkedIn send refused at a provider limit answers 429 with directLinkedIn.weeklyLimitReached, a reference and state: failed: Reply recorded the attempt, and a failed send does not hold its Idempotency-Key, so a repeat is a new attempt. That answer has no Retry-After, so the retry loop resent it three times with backoff, and one send could leave four failed records. The retries could not have helped either: an allowance that has run out does not come back within the few seconds the loop waits.

How the decision is made

  • It reads the body, not the route, so another route answering in the same shape is covered. A read is treated the same way.
  • A reference counts when it is a non-empty string. Reply's problem bodies can carry reference: null, which names nothing.
  • An allowance code is matched on the part after the last dot, so directLinkedIn.weeklyLimitReached and weeklyLimitReached both match. The part before the dot only says which route family answered, and matching it would turn the decision back into a list of routes. Matching the whole last part, not a substring, leaves a code like dailySampleLimitReached an ordinary 429.
  • One effect outside direct sends: supportRequest.dailyLimitReached matches too. It already came back at once because its Retry-After runs to hours; now it also comes back in the last 3 seconds of that wait.

What did not change

  • src/operations/direct-send.ts is untouched: LIMITS still maps a 429 with a limit code to linkedin.limit_reached, and at any other status those codes still map to reply.refused.
  • send already read the body before the retry decision, so the caller gets the same refusal as before, with reference, state, sendAfter and any Retry-After. A short Retry-After on such a 429 is passed on, not waited out.
  • The 409 for a reused idempotency key is not involved.

How it was verified

Tests were written first and run against the unchanged client: 15 failed, each on the call count: four calls where one was expected.

  • One send, one fetch for a 429 with a reference, and for each allowance code with and without a family, through request_raw, request and the direct-send command.
  • A plain 429 still retries: empty body, title only, another code, a look-alike code, a null, empty or non-string reference, and bodies that are JSON null, a JSON list or not JSON. A short Retry-After is still waited out, and a retried send goes through.
  • An allowance code at a non-429 status stays reply.refused, one call, and still names the send.

npm test: 963 passed, 5 skipped. npm run build passes.

A direct LinkedIn send refused at a provider limit answers 429 with a reference and
state failed: Reply has recorded the attempt. That answer carries no Retry-After, so
the retry loop resent it three times, and one send could leave four failed records.

A 429 is now returned as it is when its body names a reference or says a daily or
weekly allowance has run out. The decision reads the body, so another route answering
in the same shape is covered, and an allowance code matches on its last part because
the part before the dot only names the family of the route. A 429 with neither keeps
its retry and its Retry-After handling.

The body was already read before the decision, so the caller gets the refusal of the
one attempt, with its reference, state and Retry-After, as before.
The reply-api and reply-cli skills told an agent that the CLI retries every 429. A 429
that names a reference or says a daily or weekly limit was reached is never resent and
comes back at once as the refusal it is, so each skill now says so. Their versions move
one patch: reply-api to 1.5.1, reply-cli to 1.3.1.
@ArtemKosolap
ArtemKosolap marked this pull request as ready for review November 6, 2026 00:04
@ArtemKosolap
ArtemKosolap merged commit ddee022 into main Nov 6, 2026
6 checks passed
@ArtemKosolap
ArtemKosolap deleted the fix/no-retry-on-allowance-429 branch November 6, 2026 00:07
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.

2 participants