

















@@ -21,6 +21,12 @@ export class FailoverError extends Error {
2121readonly status?: number;
2222readonly code?: string;
2323readonly rawError?: string;
24+// Originating request attribution propagated through wrapper errors so
25+// structured log ingestion (e.g. api_health_log) can attribute exhausted
26+// failover failures back to a session/lane and the last attempted provider.
27+// See #42713.
28+readonly sessionId?: string;
29+readonly lane?: string;
24302531constructor(
2632message: string,
@@ -32,6 +38,8 @@ export class FailoverError extends Error {
3238status?: number;
3339code?: string;
3440rawError?: string;
41+sessionId?: string;
42+lane?: string;
3543cause?: unknown;
3644},
3745) {
@@ -44,6 +52,8 @@ export class FailoverError extends Error {
4452this.status = params.status;
4553this.code = params.code;
4654this.rawError = params.rawError;
55+this.sessionId = params.sessionId;
56+this.lane = params.lane;
4757}
4858}
4959@@ -422,6 +432,11 @@ export function describeFailoverError(err: unknown): {
422432reason?: FailoverReason;
423433status?: number;
424434code?: string;
435+provider?: string;
436+model?: string;
437+profileId?: string;
438+sessionId?: string;
439+lane?: string;
425440} {
426441if (isFailoverError(err)) {
427442return {
@@ -430,6 +445,11 @@ export function describeFailoverError(err: unknown): {
430445reason: err.reason,
431446status: err.status,
432447code: err.code,
448+provider: err.provider,
449+model: err.model,
450+profileId: err.profileId,
451+sessionId: err.sessionId,
452+lane: err.lane,
433453};
434454}
435455const signal = normalizeErrorSignal(err);
@@ -439,6 +459,7 @@ export function describeFailoverError(err: unknown): {
439459reason: resolveFailoverReasonFromError(err) ?? undefined,
440460status: signal.status,
441461code: signal.code,
462+provider: signal.provider,
442463};
443464}
444465@@ -448,6 +469,8 @@ export function coerceToFailoverError(
448469provider?: string;
449470model?: string;
450471profileId?: string;
472+sessionId?: string;
473+lane?: string;
451474},
452475): FailoverError | null {
453476if (isFailoverError(err)) {
@@ -465,9 +488,11 @@ export function coerceToFailoverError(
465488466489return new FailoverError(message, {
467490 reason,
468-provider: context?.provider,
491+provider: context?.provider ?? signal.provider,
469492model: context?.model,
470493profileId: context?.profileId,
494+sessionId: context?.sessionId,
495+lane: context?.lane,
471496 status,
472497 code,
473498rawError: message,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。