Skip to content

fix(chat): forward caller service_tier through the chat-to-responses conversion (#1886) - #1904

Merged
lidge-jun merged 5 commits into
lidge-jun:devfrom
olddonkey:codex/fastwire-chat-tier-copy
Aug 18, 2026
Merged

fix(chat): forward caller service_tier through the chat-to-responses conversion (#1886)#1904
lidge-jun merged 5 commits into
lidge-jun:devfrom
olddonkey:codex/fastwire-chat-tier-copy

Conversation

@olddonkey

@olddonkey olddonkey commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Independent bug-fix unit of the FastWire umbrella (#1886): the chat→responses converter (chatCompletionsToResponsesBody) dropped service_tier, so a tier declared by a /v1/chat/completions caller vanished before the responses pipeline could see it — fast-mode override, the capability gate, and serialization all behaved as if no tier was requested, while the identical request through /v1/responses worked. The two inbound entries now agree.

One production line: copy service_tier under the converter's existing optional-scalar convention (typeof === "string", matching the adjacent user / prompt_cache_key handling). No normalization, no injection — the downstream pipeline keeps owning tier semantics, so the fail-closed gate still strips it on supportsServiceTier: false routes.

Stacked on the A0 characterization PR #1892, deliberately: A0 locked this bug as a (known bug) characterization cell, and the design's flip protocol says the bug-fix unit updates that cell in the same change. Review this PR by its top commit. (#1892 is now merged as dec332c49; no rebase is needed — this branch already contains its commit 0cdd07d51 through common history.)

Tests

  • Converter: caller-supplied tier preserved; no tier invented when absent.
  • End-to-end through handleChatCompletions (forced chat→responses fallback): caller tier reaches the outbound body on a tier-capable route; stripped on an explicit supportsServiceTier: false route.
  • A0 characterization cell flipped from drop-assertion to preserve-assertion, annotated with the unit reference.

Verification

  • Full suite at this commit: 12,750 pass / 10 skip / 0 fail (12,760 tests across 823 files).
  • bun x tsc --noEmit clean.

Part of #1886 (independent bug-fix unit; shrinks the later B1 migration surface).

🤖 Generated with Claude Code

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features

    • Service-tier options are now preserved when converting chat completion requests.
    • Service tiers are forwarded to compatible providers and omitted when unsupported.
    • Provider metadata and routing now accurately reflect service-tier availability.
  • Tests

    • Added coverage for supported, unsupported, and unclassified service-tier scenarios.
    • Added validation for exact-model forwarding, compatibility behavior, logging, and request handling.

…conversion

chatCompletionsToResponsesBody dropped service_tier, so a tier declared by a
/v1/chat/completions caller vanished before the responses pipeline could see
it — fast override, the capability gate, and serialization all behaved as if
no tier was requested, while the same request through /v1/responses worked.
Copy the field under the converter's existing optional-scalar convention and
let the downstream pipeline keep owning the semantics.

Flips the A0 known-bug characterization for this exact behavior (FastWire
umbrella lidge-jun#1886, independent bug-fix unit), and adds
converter + end-to-end regressions including the fail-closed strip on a
supportsServiceTier:false route. Full suite at this commit: 12750 pass / 10
skip / 0 fail.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Aug 17, 2026
@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun @Ingwannu @Wibias

@github-actions
github-actions Bot marked this pull request as draft August 17, 2026 07:38
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6614d378-d4da-4364-a3f0-1ac1bd74656d

📥 Commits

Reviewing files that changed from the base of the PR and between c603dcd and 936aef8.

📒 Files selected for processing (1)
  • tests/chat-completions-endpoint.test.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The Chat Completions translator now forwards service_tier to the Responses request body. Tests cover conversion, endpoint fallback behavior, routing compatibility, catalog metadata, adapter forwarding, logging, and raw-body handling.

Changes

Service tier support

Layer / File(s) Summary
Chat conversion and endpoint forwarding
src/chat/inbound.ts, tests/chat-completions-endpoint.test.ts
The converter preserves a supplied string service_tier and omits it when absent. Endpoint tests verify forwarding for capable providers and removal for unsupported providers.
Routing and metadata compatibility
tests/fastwire-characterization-routing.test.ts
Routing tests cover service-tier capability checks, compatibility projections, and catalog metadata fields for supported and unsupported providers.
Adapter and wire characterization
tests/fastwire-characterization-wire.test.ts
Wire tests cover service-tier forwarding and logging across response and chat adapters, plus raw-body observation and related adapter behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 936ae

This is a localized fix that preserves an optional service tier during chat-to-responses conversion, with coverage for supported and fail-closed routes. No actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested labels: review-ready

Suggested reviewers: lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes forwarding caller-provided service_tier through the chat-to-responses conversion.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@olddonkey

Copy link
Copy Markdown
Contributor Author

Gate transparency for the merged head (936aef8be, dev merged in at 90fdc3a62):

  • Full suite: 12,783 pass / 10 skip / 1 fail (12,794 tests, 825 files).
  • The single failure — CLI key-login live-update overlay preservation > notify after key login pushes the merged row and keeps modelCosts on live and disk (tests/key-login-live-update.test.ts:100, live row comes back with modelCosts: undefined) — reproduces identically on pristine upstream/dev at 90fdc3a62 with none of this PR's changes present. It is a pre-existing dev-side regression, unrelated to this unit (which touches the chat→responses converter and service-tier tests only).
  • At this PR's pre-merge base the suite was fully green: 12,750 pass / 0 fail.

Flagging so the baseline failure gets triaged on dev rather than attributed to this branch.

@olddonkey
olddonkey marked this pull request as ready for review August 18, 2026 00:30
@lidge-jun

Copy link
Copy Markdown
Owner

Its baseline is in: #1892 merged as dec332c49, so the A0 characterization is now on dev.

This PR is next in the Wave 5B order and is being held only by its own draft state — all four
readiness boxes are unticked, and enforce-target and label are CANCELLED at head, so there
is no passing gate to merge against. That is the checklist doing its job, not an objection to
the change.

Two things worth knowing before you tick the boxes:

Ready for review-readiness whenever you are.

@github-actions
github-actions Bot marked this pull request as draft August 18, 2026 00:32
@github-actions
github-actions Bot marked this pull request as ready for review August 18, 2026 01:13
@olddonkey

Copy link
Copy Markdown
Contributor Author

Thanks — and the draft state you saw is now cleared: head 4b74f6359 has all four readiness boxes ticked, hygiene / enforce-target / label / resolve-pr all green, and the gate comment flipped to ✅ READY at that SHA.

On your two points:

  • No rebase — agreed, and the branch took the merge route rather than a rebase, so the shared history you verified is intact. I've dropped the "will rebase" line from the description as obsolete.
  • The flipped cell is the point — exactly right. characterization (known bug): …drops service_tiercharacterization: …preserves service_tier is the A0 protocol: A0 locks the bug as current behavior, and the bug-fix unit flips that same cell in the same change, so the two PRs read as one intentional sequence.

Local full-suite evidence at 4b74f6359 (which now contains dev tip 2a9f08324): 12,788 pass / 10 skip / 1 fail.

The single failure is the pre-existing dev-side one I flagged above — tests/key-login-live-update.test.ts:100, live row returns modelCosts: undefined — and it reproduces on pristine upstream/dev with none of this branch's changes present. Unrelated to this unit; worth its own triage on dev. Happy to open a separate issue for it if that's useful.

One caveat for the 5B ordering: four suites (oauth-refresh-lock-multiprocess, port-reclaim, codex-shim, autostart-health) are load-sensitive here — they time out under a fully parallel run and pass in isolation — so a red in those on a busy runner is likely noise rather than a real regression.

@github-actions
github-actions Bot marked this pull request as draft August 18, 2026 01:20
luvs01 pushed a commit to luvs01/opencodex that referenced this pull request Aug 18, 2026
…B gate

The audit caught a false statement I wrote: lidge-jun#1892 and lidge-jun#1904 are not disjoint,
they modify the same two test files. The pair is safe for a better reason -
lidge-jun#1904 contains lidge-jun#1892's commit 0cdd07d, so git resolves through the common
ancestor instead of seeing two unrelated additions, and the one blob that
differs is the intentional A0 flip. Verified both directions, and a sequential
merge of all five onto origin/dev in a scratch worktree produced five clean
merges.

Two things the plan had backwards. lidge-jun#1888's sponsorship label is its third
blocker, not its first - it is also CONFLICTING against dev and carries
CHANGES_REQUESTED. And the reason not to self-apply that label is sharper than
an agent not unblocking itself: MAINTAINERS.md requires explicit security review
for auth surfaces, and the label is the record that the review happened, so
applying it without doing the review makes the record false rather than merely
skipping a step.

The train's real gate was never merge order. All five sit behind maintainer
approval under Protect dev. Recording per-PR dispositions: lidge-jun#1884 and lidge-jun#1892 are
ready, lidge-jun#1902 has no exact-head CI on production routing code, lidge-jun#1904 is a draft
with unticked boxes, and lidge-jun#1898 is missing two of the five tests this plan
required - account appears zero times in its diff.
luvs01 pushed a commit to luvs01/opencodex that referenced this pull request Aug 18, 2026
Three of six landed: lidge-jun#1884, lidge-jun#1892, lidge-jun#1902. Three carried forward, each with a
reason that belongs to the PR rather than to the wave - lidge-jun#1904 is a draft whose
author has not ticked its readiness boxes, lidge-jun#1898 is missing the two pacing tests
this plan required, and lidge-jun#1888 has three independent blockers including an
unsponsored auth surface.

Focused verification on the merged tree covers the replay, fastwire and router
suites: 54 pass, 0 fail. Dev's own CI at 2a9f083 is still in progress, and the
two runs before it were cancelled by supersession, so the branch has no
completed green run on its current head yet. That matters for WP9's promotion,
not for these merges.
@lidge-jun

Copy link
Copy Markdown
Owner

Validation before merge: scratch-worktree merge onto dev (post-#1965) — fastwire-characterization-wire + chat-completions-endpoint suites 112/0, tsc --noEmit clean. Review threads all resolved; hunk overlap with landed B1 confirmed disjoint by the plan-audit reviewer.

@lidge-jun
lidge-jun merged commit 237f8c0 into lidge-jun:dev Aug 18, 2026
10 of 11 checks passed
AlinJiang pushed a commit to AlinJiang/opencodex that referenced this pull request Aug 18, 2026
Windows stack (lidge-jun#1944-lidge-jun#1947, lidge-jun#1949) and FastWire train (lidge-jun#1893, lidge-jun#1965
absorbing lidge-jun#1956, lidge-jun#1904) all terminal on dev; lidge-jun#1885 held behind the B2
pricing gate. Per-PR validation evidence recorded in the ledger; unit
moves to _fin per the devlog contract.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants