Skip to content

fix(logs): attribute proxy replay refusals as transport-ambiguous - #6887

Merged
lidge-jun merged 1 commit into
devfrom
codex/6658-replay-refusal-attribution
Oct 10, 2026
Merged

lidge-jun merged 1 commit into
devfrom
codex/6658-replay-refusal-attribution

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

The request log no longer records a proxy replay refusal as a provider rate limit. When an ambiguous pre-header reset cannot be replayed, OpenCodex answers with a synthetic HTTP 429 upstream_reset_replay_refused (by design, so clients do not resend a turn the upstream may already be running). The final request and attempt attribution treated every 429 as failureCause: rate-limit with resendPermission: permitted. That is the contradictory pair in #6658, where one Anthropic send produced upstream_reset_replay_refused alongside rate-limit/permitted, and it sent triage looking for an Anthropic quota problem that the trace did not show.

responseWithDeferredRequestLog now reads the in-process isReplayRefusalResponse marker before logging and carries terminalSource: "synthetic" plus a closed transport-ambiguous cause hint into attributeFinalRequest. The logical row and final attempt both show transport-ambiguous / refused-ambiguous. requestLogErrorCode prefers that provenance and keeps the message match only as a fallback.

The client-visible refusal (status, body, no Retry-After) is unchanged, a genuine provider 429 still attributes as rate-limit/permitted, and provider text that merely resembles the refusal wording cannot set the hint. Routing and health decisions read statuses and transport outcomes, not the persisted cause, so only the log projection changes.

The "exceeded retry limit" wording in #6658 comes from the Codex client's handling of non-quota 429 bodies, as noted in the issue triage; this PR does not change what the client receives.

Closes #6658

Verification

  • bun test tests/responses/responses-translated-reset.test.ts tests/usage/request-log.test.ts tests/usage/request-log-nonstream.test.ts tests/lib/failure-attribution.test.ts: 243 pass, 0 fail. Eight new cases in responses-translated-reset.test.ts cover the logical row and final attempt, empty and bodyless marked refusals, unmarked refusal-like provider text, a genuine 429, and cancellation precedence.
  • With the three source changes reverted, the new deferred replay refusal attribution cases give 4 pass, 4 fail (marked refusals attributed rate-limit).
  • bun run typecheck, bun run structure:check, bun scripts/file-size-ratchet.ts: pass. src/server/request-log.ts is 1999 lines (threshold 2000), so two existing comments were shortened to fit.
  • Full suite not run locally; exact-head hosted CI is the gate.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

A synthetic 429 upstream_reset_replay_refused was attributed like a provider throttle (rate-limit/permitted) because attribution treated every 429 as a rate limit. Read the in-process replay-refusal marker in the deferred logger and carry a synthetic transport-ambiguous cause hint into final request and attempt attribution. Client-visible refusal behavior is unchanged. Closes #6658.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 10, 2026 09:20
@lidge-jun lidge-jun added the bug Something isn't working label Oct 10, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 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-10-10T09:23:03.535752Z e396cf5 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 Oct 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4b94f092-2feb-4110-85c8-9fa7634901b8

📥 Commits

Reviewing files that changed from the base of the PR and between 6524ce8 and e396cf5.


📒 Files selected for processing (6)
  • docs-site/src/content/docs/guides/web-dashboard.md
  • src/server/relay.ts
  • src/server/request-log-failure-attribution.ts
  • src/server/request-log.ts
  • structure/overview.md
  • tests/responses/responses-translated-reset.test.ts

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@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: e396cf5102

ℹ️ 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 thread structure/overview.md
Comment on lines +174 to 178
A proxy replay refusal is one such fact: the deferred logger in `src/server/relay.ts` reads the
in-process `isReplayRefusalResponse` marker and passes a synthetic `transport-ambiguous` cause
hint, so its 429 keeps the `upstream_reset_replay_refused` code but is never attributed as a
provider rate limit; refusal-like provider text alone cannot establish it.
Enforced by `tests/lib/failure-attribution.test.ts`.

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 Bind the replay-refusal invariant to its regression test

The expanded invariant claims that responseWithDeferredRequestLog recognizes the in-process replay-refusal marker, but its Enforced by target remains tests/lib/failure-attribution.test.ts, which only tests the generic attribution functions and never exercises that logger or marker. The new end-to-end assertions are instead in tests/responses/responses-translated-reset.test.ts without the invariant ID, so the documented binding and structure gate would remain green if the actual marker wiring regressed or those assertions disappeared. Split/rebind the invariant so the exercising test carries the ID, while retaining an honest binding for the generic attribution contract.

AGENTS.md reference: structure/AGENTS.md:L100-L108

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun
lidge-jun merged commit 6c826bd into dev Oct 10, 2026
35 of 38 checks passed
@lidge-jun
lidge-jun deleted the codex/6658-replay-refusal-attribution branch October 10, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant