Skip to content

[WRONG BRANCH] fix(chat-native): share transient send budget across recovery - #386

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-transient-retry-budget-issue
Draft

[WRONG BRANCH] fix(chat-native): share transient send budget across recovery#386
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-transient-retry-budget-issue

Conversation

@luvs01

@luvs01 luvs01 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent native chat 429/key-failover recovery legs from re-arming the transientRetryOn5xx.attempts total-send budget so a single inbound request cannot amplify upstream sends beyond the configured per-request ceiling.

Description

  • Add a request-scoped transient send counter (transientSendsUsed) in src/server/chat-native.ts and compute the remaining allowance before each fetch call so every recovery leg draws from the same budget.
  • Pass the remainder into fetchWithTransientRetry and wire onSendsConsumed so the helper reports actual sends back into the shared counter.
  • Stop dispatching further same-target 429 retries and key-pool failover legs once the request-wide transient allowance is exhausted by guarding the recovery loops with a transientSendAvailable() check.
  • Add a source-level regression test tests/transient-budget-scope-source.test.ts that asserts the native-chat wiring draws from the shared counter and that both recovery loops observe the budget, alongside existing tests/upstream-transient-retry.test.ts coverage.

Testing

  • Ran bun test tests/transient-budget-scope-source.test.ts tests/upstream-transient-retry.test.ts and both focused test files passed.
  • Ran bun run typecheck and bun run privacy:scan, both succeeded.
  • Attempted the full suite with bun run test; focused regressions are green but the full PR-ready suite run was aborted after unrelated, pre-existing failures in other tests, so only the focused tests and typecheck/privacy checks were relied on for verification.

Codex Task

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T01:00:58.004306Z c1716f4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d06a3972-0ddc-4774-8636-870cee8e4403


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1716f4917

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +27 to +29
expect(chat.match(/let transientSendsUsed = 0;/g)).toHaveLength(1);
expect(chat).toContain("transientPolicy.attempts - transientSendsUsed");
expect(chat).toContain("onSendsConsumed: (sends: number) => { transientSendsUsed += Math.max(0, sends); }");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exercise the native request path instead of matching source

These assertions only match implementation strings, so they can remain green even if the counter or guards are placed on a path that does not constrain dispatches. The existing tests/chat-completions-endpoint.test.ts recovery test exercises 429 retry and key rotation without enabling transientRetryOn5xx, leaving the changed interaction untested. Add an endpoint regression with transient retry enabled, a 429/5xx recovery sequence, and an assertion that actual upstream calls never exceed attempts.

AGENTS.md reference: AGENTS.md:L336-L339

Useful? React with 👍 / 👎.

@github-actions github-actions Bot added the bug Something isn't working label Aug 31, 2026
@github-actions

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request is being kept as a draft automatically. Once every issue above is resolved, it will be marked ready for review again.

@github-actions github-actions Bot changed the title fix(chat-native): share transient send budget across recovery [WRONG BRANCH] fix(chat-native): share transient send budget across recovery Aug 31, 2026
@github-actions
github-actions Bot marked this pull request as draft August 31, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant