Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/providers/fastwire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,15 @@ export function tierObservationContext(
policy: ResolvedFastPolicy,
fastMode: boolean | undefined,
callerTier: string | undefined,
responseTierAuthoritative?: boolean,
): TierObservationContext {
return {
capability: policy.capability,
eligibility: policy.eligibility,
fastWire: policy.fastWire,
demandDecision: fastMode === true ? "force-fast" : fastMode === false ? "force-default" : "inherit",
...(callerTier !== undefined ? { callerTier } : {}),
...(responseTierAuthoritative !== undefined ? { responseTierAuthoritative } : {}),
};
}

Expand Down Expand Up @@ -344,7 +346,11 @@ export function createAdapterTierMetadata(

const responseCanConfirmFast = effectiveFastRequested
&& context.eligibility === "eligible"
&& wireValue !== null;
&& wireValue !== null
// 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 👍 / 👎.

return {
outcome,
observeResponseServiceTier(value: unknown) {
Expand Down
10 changes: 9 additions & 1 deletion src/server/responses/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,15 @@ async function applyFinalRouteRequestNormalization(args: {
);
const modelServiceTierSupport = serviceTierSupportFromPolicy(fastPolicy);
const callerTier = parsed.options.serviceTier;
parsed.options.tierObservation = tierObservationContext(fastPolicy, config.fastMode, callerTier);
// The ChatGPT-internal Codex backend echoes `service_tier: "default"` even on turns it
// scheduled as priority, so its echo cannot confirm OR deny Fast. Believing it reported every
// Fast request as `response-declined` (#2558). The public API's echo stays authoritative.
parsed.options.tierObservation = tierObservationContext(
fastPolicy,
config.fastMode,
callerTier,
isCanonicalOpenAiForwardProvider(route.provider) ? false : undefined,
);
parsed.options.tierDecision = decideTier(fastPolicy, config.fastMode, callerTier);
parsed.options.serviceTier = tierValueAfterDecision(parsed.options.tierDecision, callerTier);
if (fastPolicy.capability === true && fastPolicy.fastWire === null) {
Expand Down
9 changes: 9 additions & 0 deletions src/types/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ export interface TierObservationContext {
fastWire: FastWire | null;
demandDecision: "force-fast" | "force-default" | "inherit";
callerTier?: string;
/**
* Whether the destination's echoed `service_tier` is authoritative about Fast scheduling.
*
* The ChatGPT-internal Codex backend returns `service_tier: "default"` on turns that were in
* fact scheduled as priority, so treating its echo as a downgrade produced a false
* `response-declined` on every Fast request (#2558). Absent means "assume authoritative",
* preserving the behaviour for the public API where the echo does mean what it says.
*/
responseTierAuthoritative?: boolean;
}

export type TierDecision =
Expand Down
48 changes: 48 additions & 0 deletions tests/fastwire-observability.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,3 +827,51 @@ describe("FastWire gate and compatibility fingerprint", () => {
expect(buildBehaviorFingerprintV1(base)).not.toBe(buildBehaviorFingerprintV1(performance));
});
});

describe("#2558 a non-authoritative destination cannot confirm or deny Fast", () => {
/**
* The ChatGPT-internal Codex backend echoes service_tier: "default" even on turns it
* scheduled as priority. Believing that echo classified every Fast request as
* response-declined, which is a false negative that also drives priority cost attribution.
*/
const nonAuthoritative = () => observation({ responseTierAuthoritative: false });

test("an echoed default is not a downgrade when the destination is not authoritative", () => {
const tracker = createAdapterTierMetadata(
nonAuthoritative(),
{ kind: "set", value: "priority" },
"service-tier",
"priority",
)!;
tracker.observeResponseServiceTier("default");
expect(tracker.outcome.fastDowngradeReason).toBeUndefined();
expect(tracker.outcome.fastOutcome).not.toBe("downgraded");
// The raw echo is still recorded — this suppresses a verdict, not the evidence.
expect(tracker.outcome.responseServiceTier).toBe("default");
});

test("the same echo IS a downgrade on an authoritative destination", () => {
const tracker = createAdapterTierMetadata(
observation(),
{ kind: "set", value: "priority" },
"service-tier",
"priority",
)!;
tracker.observeResponseServiceTier("default");
expect(tracker.outcome.fastOutcome).toBe("downgraded");
expect(tracker.outcome.fastDowngradeReason).toBe("response-declined");
});

test("an omitted flag keeps the authoritative default", () => {
// Absent must mean "assume authoritative" so the public API path is unchanged.
const tracker = createAdapterTierMetadata(
observation({}),
{ kind: "set", value: "priority" },
"service-tier",
"priority",
)!;
tracker.observeResponseServiceTier("default");
expect(tracker.outcome.fastOutcome).toBe("downgraded");
});
});

Loading