Skip to content

fix(fastwire): do not read a non-authoritative tier echo as a Fast downgrade - #2589

Merged
lidge-jun merged 1 commit into
devfrom
codex/fast-tier-classification-2558
Aug 25, 2026
Merged

fix(fastwire): do not read a non-authoritative tier echo as a Fast downgrade#2589
lidge-jun merged 1 commit into
devfrom
codex/fast-tier-classification-2558

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #2558.

OpenCodex reported every Codex Fast request as fastOutcome: downgraded /
fastDowngradeReason: response-declined, while the request was correctly sent as
service_tier: "priority" and observed throughput differed from a no-tier request. The
issue's suspicion was right: the ChatGPT-internal Codex backend returns
service_tier: "default" even on turns it scheduled as priority, so its echo was being
read as a verdict it cannot give.

Two consequences, not one. The visible symptom is a false negative in the diagnostics; the
quieter one is cost attribution, because fastOutcome drives priority pricing.

TierObservationContext gains responseTierAuthoritative. Absent means "assume
authoritative", so the public API path — where an echoed default really does mean the
request was declined — is unchanged. core.ts sets it false only for the canonical
ChatGPT-forward destination, using the existing isCanonicalOpenAiForwardProvider check.

The raw echo is still recorded in responseServiceTier. This suppresses a verdict, not the
evidence: an operator can still see exactly what the backend returned.

Verification

Driven red first — removing the guard fails exactly the new case and nothing else:

# guard removed
$ bun test tests/fastwire-observability.test.ts
 31 pass, 1 fail

# with the fix
$ bun test tests/fastwire-observability.test.ts
 32 pass, 0 fail, 95 expect() calls

$ bun x tsc --noEmit
(clean)

The three added cases pin all three states: a non-authoritative destination does not
classify a downgrade, an authoritative one still does, and an omitted flag keeps the
authoritative default.

Checklist

  • Targets dev
  • Based on the current dev head
  • Regression driven red first, then green
  • Existing fastwire behaviour unchanged for authoritative destinations
  • Typecheck clean
  • No secrets or account identifiers in the diff

Summary by CodeRabbit

  • Bug Fixes

    • Improved Fast-mode status reporting for routes that cannot reliably confirm the upstream service tier.
    • Prevented echoed default-tier responses from being incorrectly classified as declined Fast requests.
    • Preserved existing downgrade detection for destinations with authoritative tier information.
  • Tests

    • Added coverage for authoritative and non-authoritative service-tier responses.

The ChatGPT-internal Codex backend returns service_tier: default even on
turns it scheduled as priority, so treating that echo as a verdict marked
every Fast request response-declined. That is a false negative, and it also
skews cost attribution because fastOutcome drives priority pricing.

TierObservationContext gains responseTierAuthoritative. Absent means assume
authoritative, so the public API path is unchanged; core.ts sets it false
only for the canonical ChatGPT-forward destination, where the echo can
neither confirm nor deny Fast. The raw echo is still recorded - this
suppresses a verdict, not the evidence.

Driven red first: removing the guard fails exactly the new case.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 25, 2026 16:51
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 25, 2026
@lidge-jun
lidge-jun merged commit b3999c1 into dev Aug 25, 2026
8 of 9 checks passed
@lidge-jun
lidge-jun deleted the codex/fast-tier-classification-2558 branch August 25, 2026 16:51
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0261532b-4453-46ad-b18f-1cf4151384ab

📥 Commits

Reviewing files that changed from the base of the PR and between 48602ce and aacd24c.

📒 Files selected for processing (4)
  • src/providers/fastwire.ts
  • src/server/responses/core.ts
  • src/types/provider.ts
  • tests/fastwire-observability.test.ts

📝 Walkthrough

Walkthrough

The change adds destination-aware response-tier authority. Canonical OpenAI forward routes mark echoed tiers as non-authoritative, while other routes retain authoritative behavior. Tests cover non-authoritative echoes, authoritative downgrades, and omitted-flag compatibility.

Changes

Fast tier authority

Layer / File(s) Summary
Authority contract and classification
src/types/provider.ts, src/providers/fastwire.ts
TierObservationContext accepts an optional authority flag. Non-authoritative response tiers cannot confirm or deny Fast.
Route wiring and regression coverage
src/server/responses/core.ts, tests/fastwire-observability.test.ts
Canonical OpenAI forward routes pass non-authoritative context. Tests cover non-authoritative echoes, authoritative downgrades, and default behavior when the flag is omitted.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: review-ready

Suggested reviewers: ingwannu, olddonkey

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fast-tier-classification-2558

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: aacd24c537

ℹ️ 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 src/providers/fastwire.ts
// A destination whose echo is not authoritative can neither confirm nor deny Fast. The
// ChatGPT-internal Codex backend echoes "default" on priority-scheduled turns, so believing
// it reported every Fast request as `response-declined` (#2558).
&& context.responseTierAuthoritative !== false;

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 Exclude non-authoritative echoes from pricing provenance

When a canonical ChatGPT Fast request receives the known service_tier: "default" echo, this guard keeps the outcome as assumed priority, but observeResponseServiceTier still stores "default". serviceTierContextFromOutcome in src/usage/cost.ts:380-384 prioritizes that stored response over the assumed canonical tier, so estimateAttemptCost sees the default tier and skips the OpenAI priority multiplier. Consequently, the cost-attribution regression described by this change remains for every affected request; preserve the echo for diagnostics while ensuring the pricing path ignores it when it is non-authoritative, and add a multiplier regression assertion.

Useful? React with 👍 / 👎.

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