@bitkyc08/opencodex 2.100.4 → 2.100.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gui/dist/assets/{App-DcpyI78f.js → App-BRExzhwL.js} +21 -21
- package/gui/dist/assets/{Tray-CzjPJprT.js → Tray-DHCWAn8V.js} +1 -1
- package/gui/dist/assets/{brand-mark-BTIi7e69.js → brand-mark-C70PuQ3j.js} +1 -1
- package/gui/dist/assets/index-Dy1jIGty.js +138 -0
- package/gui/dist/assets/{segment-thumb-features-Bn6Y-g3R.js → segment-thumb-features-Bquysdn5.js} +1 -1
- package/gui/dist/classic/assets/{App-eYJAyNHM.js → App-CaC-E6Vl.js} +20 -20
- package/gui/dist/classic/assets/{Tray-xHMYxLkV.js → Tray-BG253fiL.js} +1 -1
- package/gui/dist/classic/assets/index-CR_AThOp.js +138 -0
- package/gui/dist/classic/assets/{quota-summary-DyzHlkFl.js → quota-summary-B7KQPpEC.js} +1 -1
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +1 -1
- package/native/ocx-child/src/link_ws.rs +24 -19
- package/native/ocx-child/src/link_ws_frame.rs +136 -50
- package/package.json +3 -3
- package/src/adapters/anthropic-input-schema.ts +270 -0
- package/src/adapters/anthropic.ts +1 -63
- package/src/adapters/command-code-tool-text.ts +9 -1
- package/src/adapters/command-code.ts +18 -2
- package/src/adapters/devin/cloud-direct/chat.ts +24 -0
- package/src/adapters/devin/live-models.ts +11 -1
- package/src/adapters/kiro/reasoning.ts +3 -0
- package/src/adapters/kiro-tools.ts +14 -9
- package/src/adapters/openai-responses/passthrough.ts +3 -1
- package/src/adapters/openai-responses/request-strips.ts +1 -0
- package/src/adapters/tool-catalog-nudge.ts +1 -1
- package/src/claude/chat-tool-dispatch.ts +4 -1
- package/src/cli/logout-command.ts +23 -4
- package/src/cli/provider.ts +3 -2
- package/src/client/connect.ts +10 -2
- package/src/clients/config-export.ts +12 -7
- package/src/codex/account-lifecycle.ts +3 -1
- package/src/codex/catalog/metadata.ts +8 -0
- package/src/codex/catalog/native-models.ts +16 -6
- package/src/codex/catalog/pinned-models.ts +1 -0
- package/src/codex/catalog/provider-models.ts +5 -5
- package/src/codex/catalog-auto-refresh.ts +13 -2
- package/src/codex/config-drift-heal.ts +40 -12
- package/src/codex/config-write-lock.ts +39 -1
- package/src/codex/data/roster-pinned-models.json +346 -1
- package/src/codex/inject/config-write-section.ts +39 -1
- package/src/codex/inject/plan.ts +10 -8
- package/src/codex/inject/remove.ts +21 -19
- package/src/codex/inject/restore.ts +5 -1
- package/src/codex/inject-coordination.ts +58 -7
- package/src/codex/inject.ts +10 -12
- package/src/codex/journal-config-restore.ts +42 -0
- package/src/codex/journal.ts +62 -8
- package/src/codex/main-account.ts +7 -2
- package/src/codex/native-main-credentials.ts +11 -5
- package/src/combos/failover.ts +183 -0
- package/src/config/subagent-models.ts +20 -12
- package/src/generated/compatibility-version.json +99 -83
- package/src/generated/model-metadata.ts +3 -3
- package/src/lib/client-error-body.ts +6 -0
- package/src/lib/developer-role-rejection.ts +15 -0
- package/src/lib/upstream-retry.ts +1 -1
- package/src/messaging/remote-ports.ts +22 -10
- package/src/oauth/credential-siblings.ts +32 -0
- package/src/oauth/generic-account-failover.ts +25 -13
- package/src/oauth/index.ts +22 -14
- package/src/oauth/store.ts +38 -7
- package/src/providers/anthropic-reset-grants.ts +4 -0
- package/src/providers/claude-cli-usage.ts +2 -0
- package/src/providers/codebuddy-models.ts +11 -0
- package/src/providers/google-vertex-model-discovery.ts +43 -14
- package/src/providers/kiro-models.ts +5 -0
- package/src/providers/registry/entries-core.ts +9 -3
- package/src/providers/registry/entries-extended.ts +20 -9
- package/src/providers/registry/model-seeds.ts +4 -1
- package/src/providers/stale-context-window-migration.ts +2 -0
- package/src/responses/citation-markers.ts +26 -23
- package/src/server/management/link-enrollment.ts +3 -3
- package/src/server/management/link-route-request.ts +11 -5
- package/src/server/management/oauth-account-routes.ts +21 -8
- package/src/server/management/provider-credential-release.ts +44 -0
- package/src/server/management/provider-routes.ts +8 -8
- package/src/server/management/usage-aggregate-cache.ts +6 -3
- package/src/server/messages-native.ts +16 -2
- package/src/server/request-log-conversation.ts +6 -2
- package/src/server/request-log-failure-detail.ts +26 -9
- package/src/server/responses/adapter-continuation.ts +59 -25
- package/src/server/responses/adapter-dispatch.ts +8 -8
- package/src/server/responses/codex-tool-catalog.ts +47 -10
- package/src/server/responses/combo-session-recall.ts +26 -1
- package/src/server/responses/combo-stream-preflight.ts +35 -26
- package/src/server/responses/core-combo-failure.ts +6 -0
- package/src/server/responses/core-combo-native.ts +2 -1
- package/src/server/responses/core-combo.ts +43 -19
- package/src/server/responses/core-options.ts +2 -0
- package/src/server/responses/input-admission.ts +41 -3
- package/src/server/responses/request-send-budget.ts +1 -1
- package/src/server/responses/request-transport.ts +10 -2
- package/src/server/responses/sidecar-execution.ts +6 -4
- package/src/service/windows-checked-stop-live.ts +28 -5
- package/src/types/request.ts +4 -3
- package/src/usage/expected-prices.ts +35 -0
- package/src/usage/ledger-scanner.ts +44 -10
- package/src/web-search/loop.ts +20 -2
- package/src/web-search/parse.ts +2 -12
- package/src/web-search/sources.ts +13 -0
- package/gui/dist/assets/index-DVgU6S3y.js +0 -138
- package/gui/dist/classic/assets/index-DSaVRW4F.js +0 -138
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { upstreamValidationIssues } from "../lib/upstream-validation-detail";
|
|
1
|
+
import { upstreamValidationIssues, type ValidationIssue } from "../lib/upstream-validation-detail";
|
|
2
|
+
import { isDeveloperRoleRejection } from "../lib/developer-role-rejection";
|
|
2
3
|
import { clientFacingModelText, errorDestinationText, providerErrorDestinationLabel } from "../lib/error-destination";
|
|
3
4
|
import { knownModelIdentity } from "../lib/model-identity";
|
|
4
5
|
/**
|
|
@@ -80,20 +81,36 @@ export function projectLocalModelRefusalLog(
|
|
|
80
81
|
|| decision.selected && (!known(decision.selected.model) || !providerKnown(decision.selected.provider)))) logCtx.routeDecision = undefined;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
const isRecord = (value: unknown): value is Record<string, unknown> => !!value && typeof value === "object" && !Array.isArray(value);
|
|
85
|
+
/**
|
|
86
|
+
* The closed pair a developer-role rejection records (#8864); the dashboard already renders it. A fresh
|
|
87
|
+
* array per row, because a valid list is stored by reference and must not be shared between rows.
|
|
88
|
+
*/
|
|
89
|
+
const developerRoleValidation = (): ValidationIssue[] => [{ field: "messages.role", type: "enum" }];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Capture bounded schema facts before a 4xx is replaced by the client-facing error policy. Only a caller
|
|
93
|
+
* holding the provider's own body sets `providerBody`, which also reads its message once for a
|
|
94
|
+
* developer-role rejection; a body this proxy formatted keeps validation-only capture.
|
|
95
|
+
*/
|
|
96
|
+
export function recordUpstreamValidationDetail(
|
|
97
|
+
logCtx: { failureDetail?: FailureDetail }, status: number, payload: unknown, options: { providerBody?: boolean } = {},
|
|
98
|
+
): void {
|
|
85
99
|
if (status < 400 || status >= 500) return;
|
|
86
100
|
let parsed = payload;
|
|
87
101
|
if (typeof payload === "string") {
|
|
88
102
|
if (payload.length > 256 * 1024) return;
|
|
89
103
|
try { parsed = JSON.parse(payload); } catch { return; }
|
|
90
104
|
}
|
|
91
|
-
const
|
|
105
|
+
const record = isRecord(parsed) ? parsed : undefined;
|
|
106
|
+
const nested = record && isRecord(record.error) ? record.error : undefined;
|
|
107
|
+
const message = typeof nested?.message === "string" ? nested.message
|
|
108
|
+
: typeof record?.message === "string" ? record.message : typeof record?.error === "string" ? record.error : undefined;
|
|
109
|
+
// Read once to choose the closed pair; the message itself is dropped here.
|
|
110
|
+
const validation = upstreamValidationIssues(parsed)
|
|
111
|
+
?? (options.providerBody && isDeveloperRoleRejection(status, message) ? developerRoleValidation() : undefined);
|
|
92
112
|
if (!validation) return;
|
|
93
|
-
|
|
94
|
-
const nested = record.error !== null && typeof record.error === "object" && !Array.isArray(record.error)
|
|
95
|
-
? record.error as Record<string, unknown> : undefined;
|
|
96
|
-
logCtx.failureDetail = boundedFailureDetail({ code: "provider_error", type: nested?.type ?? record.type, validation });
|
|
113
|
+
logCtx.failureDetail = boundedFailureDetail({ code: "provider_error", type: nested?.type ?? record?.type, validation });
|
|
97
114
|
}
|
|
98
115
|
|
|
99
116
|
/**
|
|
@@ -112,7 +129,7 @@ export function recordUpstreamProviderErrorDetail(
|
|
|
112
129
|
): void {
|
|
113
130
|
if (status < 400 || status >= 600) return;
|
|
114
131
|
const before = logCtx.failureDetail;
|
|
115
|
-
recordUpstreamValidationDetail(logCtx, status, payload);
|
|
132
|
+
recordUpstreamValidationDetail(logCtx, status, payload, { providerBody: true });
|
|
116
133
|
if (logCtx.failureDetail !== before) { providerDetails.set(logCtx, logCtx.failureDetail!); return; }
|
|
117
134
|
let type = response ? providerFailureDetailOf(response)?.type : undefined;
|
|
118
135
|
if (type === undefined) {
|
|
@@ -43,7 +43,6 @@ import { redactSecretString } from "../../lib/redact";
|
|
|
43
43
|
import { resolveWireProtocolOverride } from "../adapter-resolve";
|
|
44
44
|
import { bindRouteReasoningReplayScope } from "./core-replay";
|
|
45
45
|
import {
|
|
46
|
-
ANTHROPIC_POOL_MAX_FAILOVERS_PER_REQUEST,
|
|
47
46
|
anthropicRoutingFor,
|
|
48
47
|
formatAnthropicProviderForLog,
|
|
49
48
|
} from "../../oauth/anthropic-routing";
|
|
@@ -102,7 +101,7 @@ export function createAdapterContinuations(
|
|
|
102
101
|
| "commitResolvedOAuthSelection"
|
|
103
102
|
| "genericFailoverAccountId"
|
|
104
103
|
| "genericFailovers"
|
|
105
|
-
| "genericFailoverLimit"
|
|
104
|
+
| "genericFailoverLimit" | "anthropicFailoverLimit"
|
|
106
105
|
| "applyFailoverSnapshot"
|
|
107
106
|
| "replayOAuthCredentialSnapshot"
|
|
108
107
|
| "noteRoutedAttemptSend"
|
|
@@ -201,8 +200,16 @@ export function createAdapterContinuations(
|
|
|
201
200
|
allowAccountRefusal = false,
|
|
202
201
|
): AsyncGenerator<AdapterEvent> {
|
|
203
202
|
let response: Response | undefined;
|
|
204
|
-
let
|
|
205
|
-
let
|
|
203
|
+
let refusalPendingReplay: Response | undefined;
|
|
204
|
+
let replaySetupFailed = false;
|
|
205
|
+
// Refused account's request attribution, restored when its replacement fails before sending.
|
|
206
|
+
let refusalAttribution: { provider: string; label?: string; ordinal?: number; sends?: number;
|
|
207
|
+
attemptLabel?: NonNullable<typeof logCtx.activeAttempt>["accountLogLabel"] } | undefined;
|
|
208
|
+
const captureRefusalAttribution = () => {
|
|
209
|
+
const attempt = logCtx.activeAttempt;
|
|
210
|
+
refusalAttribution = { provider: logCtx.provider, label: logCtx.accountLogLabel, ordinal: attempt?.ordinal,
|
|
211
|
+
sends: attempt?.sendCount, attemptLabel: attempt?.accountLogLabel };
|
|
212
|
+
};
|
|
206
213
|
// One-shot recovery label for the next top-of-loop continuation send after a failover rotation.
|
|
207
214
|
let nextContinuationRecoveryKind: AttemptRecoveryKind | undefined = initialRecoveryKind;
|
|
208
215
|
/**
|
|
@@ -313,9 +320,11 @@ export function createAdapterContinuations(
|
|
|
313
320
|
// Same request-scoped budget as the initial send and the 429/rotation refetches:
|
|
314
321
|
// a terminal-guard continuation is another leg of ONE request, so handing it a
|
|
315
322
|
// fresh `attempts` would let one request exceed the configured total-send ceiling.
|
|
316
|
-
...(continuationTransientPolicy || sendBudgetState.adapterSendBudget?.spendEnforced
|
|
323
|
+
...(continuationTransientPolicy || anthropicInstance || sendBudgetState.adapterSendBudget?.spendEnforced
|
|
317
324
|
? {
|
|
318
|
-
attempts:
|
|
325
|
+
attempts: Math.min(continuationTransientPolicy?.attempts ?? 1,
|
|
326
|
+
remainingTransientSendBudget(continuationTransientPolicy?.attempts ?? 1)
|
|
327
|
+
+ (sendBudgetState.pendingHopPermit ? 1 : 0)),
|
|
319
328
|
onSendsConsumed: deferredContinuation?.report ?? continuationReporter,
|
|
320
329
|
}
|
|
321
330
|
: {}),
|
|
@@ -338,20 +347,34 @@ export function createAdapterContinuations(
|
|
|
338
347
|
invalidateSameTargetRequest();
|
|
339
348
|
response = await fetchContinuation("opaque-blob-rejection");
|
|
340
349
|
}
|
|
341
|
-
if (
|
|
342
|
-
try { void
|
|
343
|
-
|
|
350
|
+
if (refusalPendingReplay) {
|
|
351
|
+
try { void refusalPendingReplay.body?.cancel().catch(() => {}); } catch { /* already closed */ }
|
|
352
|
+
refusalPendingReplay = undefined;
|
|
344
353
|
sendBudgetState.pendingHopPermit = undefined;
|
|
345
354
|
}
|
|
346
355
|
} catch (error) {
|
|
347
|
-
if (
|
|
356
|
+
if (refusalPendingReplay && !options.abortSignal?.aborted && !upstream.signal.aborted) {
|
|
348
357
|
sendBudgetState.pendingHopPermit?.release();
|
|
349
358
|
sendBudgetState.pendingHopPermit = undefined;
|
|
350
|
-
response =
|
|
351
|
-
|
|
352
|
-
|
|
359
|
+
response = refusalPendingReplay;
|
|
360
|
+
refusalPendingReplay = undefined;
|
|
361
|
+
replaySetupFailed = true;
|
|
362
|
+
const attempt = logCtx.activeAttempt;
|
|
363
|
+
// Same attempt and send count: the replacement never dispatched, so the refusal stays the refused account's.
|
|
364
|
+
if (attempt && refusalAttribution && attempt.ordinal === refusalAttribution.ordinal && attempt.sendCount === refusalAttribution.sends) {
|
|
365
|
+
logCtx.provider = refusalAttribution.provider;
|
|
366
|
+
if (refusalAttribution.label === undefined) delete logCtx.accountLogLabel;
|
|
367
|
+
else logCtx.accountLogLabel = refusalAttribution.label;
|
|
368
|
+
if (refusalAttribution.attemptLabel === undefined) delete attempt.accountLogLabel;
|
|
369
|
+
else attempt.accountLogLabel = refusalAttribution.attemptLabel;
|
|
370
|
+
}
|
|
353
371
|
} else {
|
|
354
|
-
|
|
372
|
+
if (refusalPendingReplay) {
|
|
373
|
+
sendBudgetState.pendingHopPermit?.release();
|
|
374
|
+
sendBudgetState.pendingHopPermit = undefined;
|
|
375
|
+
try { void refusalPendingReplay.body?.cancel().catch(() => {}); } catch { /* closed */ }
|
|
376
|
+
}
|
|
377
|
+
yield continuationFailureEvent(error); return;
|
|
355
378
|
}
|
|
356
379
|
}
|
|
357
380
|
|
|
@@ -360,7 +383,7 @@ export function createAdapterContinuations(
|
|
|
360
383
|
// loop; only after the attempts are exhausted does the continuation fail over.
|
|
361
384
|
while (
|
|
362
385
|
response.status === 429
|
|
363
|
-
&& !
|
|
386
|
+
&& !replaySetupFailed
|
|
364
387
|
// A synthesized replay refusal is not a rate limit; replaying the continuation on
|
|
365
388
|
// it would re-send a turn whose first send may already have been processed.
|
|
366
389
|
&& !isNonReplayableResponse(response) && !isSameTargetRetryHold(response)
|
|
@@ -447,19 +470,26 @@ export function createAdapterContinuations(
|
|
|
447
470
|
(response.status === 429 || response.status === 403 || response.status === 401)
|
|
448
471
|
&& anthropicInstance
|
|
449
472
|
&& transportState.anthropicPoolAccountId
|
|
450
|
-
&& !isNonReplayableResponse(response)
|
|
473
|
+
&& !replaySetupFailed && !isNonReplayableResponse(response)
|
|
451
474
|
) {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
475
|
+
const adapterOwnsDispatch = transportState.activeAdapter.fetchResponse !== undefined;
|
|
476
|
+
const hop = reserveCredentialHop("auth-recovery", `${route.providerName}|${route.modelId}|continuation-anthropic-429`,
|
|
477
|
+
!adapterOwnsDispatch);
|
|
478
|
+
let nextAccountId: string | null;
|
|
479
|
+
try {
|
|
480
|
+
nextAccountId = await rotateAnthropicAccountOnResponseForInstance(anthropicInstance, response, {
|
|
481
|
+
config, accountId: transportState.anthropicPoolAccountId, sessionKey: anthropicSessionKey,
|
|
482
|
+
model: route.modelId, requestKey: transportState, decision: transportState.anthropicRouteDecision, currentDecision: currentAnthropicRouteDecision, signal: upstream.signal,
|
|
483
|
+
canRetry: hop.allowed && transportState.anthropicPoolFailovers < transportState.anthropicFailoverLimit,
|
|
484
|
+
allowAccountRefusal, allow429Recovery: allowAccountRefusal,
|
|
485
|
+
});
|
|
486
|
+
} catch (error) { hop.permit?.release(); throw error; }
|
|
487
|
+
if (!nextAccountId) hop.permit?.release();
|
|
458
488
|
if (nextAccountId) {
|
|
489
|
+
captureRefusalAttribution();
|
|
459
490
|
try {
|
|
460
491
|
const admitted = await commitResolvedOAuthSelection(await anthropicRoutingFor(anthropicInstance).getAnthropicPoolAccessSnapshot(nextAccountId));
|
|
461
492
|
if (!admitted) throw new Error("OAuth selection changed during recovery");
|
|
462
|
-
try { void response.body?.cancel().catch(() => {}); } catch { /* already consumed/closed */ }
|
|
463
493
|
transportState.anthropicPoolAccountId = admitted.accountId;
|
|
464
494
|
transportState.anthropicPoolFailovers += 1;
|
|
465
495
|
route.provider = { ...route.provider, apiKey: admitted.accessToken };
|
|
@@ -483,8 +513,11 @@ export function createAdapterContinuations(
|
|
|
483
513
|
recordAttemptCredentialSource(logCtx.activeAttempt, route.providerName, route.provider, transportState.activeAdapter.name);
|
|
484
514
|
nextContinuationRecoveryKind = response.status === 401 ? "oauth-401"
|
|
485
515
|
: response.status === 403 ? "oauth-account-403" : "anthropic-oauth-429";
|
|
516
|
+
sendBudgetState.pendingHopPermit = hop.permit;
|
|
517
|
+
refusalPendingReplay = response;
|
|
486
518
|
continue;
|
|
487
519
|
} catch {
|
|
520
|
+
hop.permit?.release();
|
|
488
521
|
// fall through to emit continuation error below
|
|
489
522
|
}
|
|
490
523
|
}
|
|
@@ -499,7 +532,7 @@ export function createAdapterContinuations(
|
|
|
499
532
|
(response.status === 429 || response.status === 400 || response.status === 403)
|
|
500
533
|
&& transportState.genericFailoverAccountId
|
|
501
534
|
&& !isNonReplayableResponse(response)
|
|
502
|
-
&& !
|
|
535
|
+
&& !replaySetupFailed
|
|
503
536
|
) {
|
|
504
537
|
const refusal = classifyKiroRefusal(response.status,
|
|
505
538
|
await readDisplaySafeErrorText(response.clone(), upstream.signal, ""));
|
|
@@ -550,6 +583,7 @@ export function createAdapterContinuations(
|
|
|
550
583
|
// metadata, so a token-only swap would mix one account's credential with another's
|
|
551
584
|
// routing data.
|
|
552
585
|
const snapshot = await failoverAccountSnapshot(route.providerName, nextAccountId);
|
|
586
|
+
captureRefusalAttribution();
|
|
553
587
|
const applied = await applyFailoverSnapshot(snapshot, nextParsed);
|
|
554
588
|
if (!applied) hop.permit?.release();
|
|
555
589
|
if (applied) {
|
|
@@ -583,7 +617,7 @@ export function createAdapterContinuations(
|
|
|
583
617
|
// same permit so its reporter settles only this booking.
|
|
584
618
|
sendBudgetState.pendingHopPermit = hop.permit;
|
|
585
619
|
nextContinuationRecoveryKind = "oauth-account-429";
|
|
586
|
-
|
|
620
|
+
refusalPendingReplay = response;
|
|
587
621
|
continue;
|
|
588
622
|
}
|
|
589
623
|
} catch {
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
SendBudgetExhaustedError, errorDestinationLabel,
|
|
62
62
|
UpstreamRetryEvidenceError,
|
|
63
63
|
prepareSameTarget429Wait,
|
|
64
|
-
sleepWithAbort,
|
|
64
|
+
sleepWithAbort, RESET_RETRY_MAX_ATTEMPTS,
|
|
65
65
|
} from "../../lib/upstream-retry";
|
|
66
66
|
import { describeUpstreamConnectFailure } from "./upstream-error";
|
|
67
67
|
import { createProviderOfflineResendWait } from "../../lib/offline-resend";
|
|
@@ -82,7 +82,6 @@ import { resolveWireProtocolOverride } from "../adapter-resolve";
|
|
|
82
82
|
import { bindRouteReasoningReplayScope } from "./core-replay";
|
|
83
83
|
import {
|
|
84
84
|
AnthropicAccountCooldownError,
|
|
85
|
-
ANTHROPIC_POOL_MAX_FAILOVERS_PER_REQUEST,
|
|
86
85
|
anthropicRoutingFor,
|
|
87
86
|
formatAnthropicProviderForLog,
|
|
88
87
|
} from "../../oauth/anthropic-routing";
|
|
@@ -172,7 +171,7 @@ export async function prepareAdapterExchange(
|
|
|
172
171
|
| "commitResolvedOAuthSelection"
|
|
173
172
|
| "genericFailoverAccountId"
|
|
174
173
|
| "genericFailovers"
|
|
175
|
-
| "genericFailoverLimit"
|
|
174
|
+
| "genericFailoverLimit" | "anthropicFailoverLimit"
|
|
176
175
|
| "applyFailoverSnapshot"
|
|
177
176
|
| "noteRoutedAttemptSend" | "attemptSendDeferred" | "deferPhysicalAttribution"
|
|
178
177
|
>,
|
|
@@ -406,7 +405,7 @@ export async function prepareAdapterExchange(
|
|
|
406
405
|
let billingRecoveryActive = false;
|
|
407
406
|
const genericRefetchCountsSends = () => !!sendBudgetState.workflowRootId || options.comboAttempt === true || sendBudgetState.adapterSendBudget?.spendEnforced === true
|
|
408
407
|
|| transientRetryPolicyFor(route.provider) !== null || resetReplayPolicyFor(route.provider) !== null
|
|
409
|
-
|| billingPoolRequest || billingRecoveryActive || autoPauseEnabled;
|
|
408
|
+
|| !!anthropicInstance || billingPoolRequest || billingRecoveryActive || autoPauseEnabled;
|
|
410
409
|
let handoffPermit: ResponsesSendBudget["pendingHopPermit"];
|
|
411
410
|
try {
|
|
412
411
|
if (transportState.activeAdapter.fetchResponse) {
|
|
@@ -475,7 +474,8 @@ export async function prepareAdapterExchange(
|
|
|
475
474
|
|| (options.comboAttempt && route.provider.adapter === "google")
|
|
476
475
|
? transientSendCapFor(transientPolicy?.attempts,
|
|
477
476
|
(options.comboAttempt || compactPrepaid) ? 0 : sendBudgetState.sendsUsed)
|
|
478
|
-
:
|
|
477
|
+
// Anthropic sends are counted for the funded roster, not narrowed: keep the reset ladder.
|
|
478
|
+
: anthropicInstance && !options.comboAttempt && !compactPrepaid && !autoPauseEnabled ? RESET_RETRY_MAX_ATTEMPTS : 1;
|
|
479
479
|
const fetchWithRetryPolicy = (route.provider.adapter === "google" || transientPolicy)
|
|
480
480
|
? fetchWithTransientRetry
|
|
481
481
|
: fetchWithResetRetry;
|
|
@@ -527,10 +527,10 @@ export async function prepareAdapterExchange(
|
|
|
527
527
|
claimAmbiguousResend: claimPreHeaderResend,
|
|
528
528
|
offlineWait: options.comboAttempt ? undefined : createProviderOfflineResendWait(route.providerName, route.provider, builtInitialRequest.url, config.offlineResendWaitSec),
|
|
529
529
|
...(sendBudgetState.workflowRootId || sendBudgetState.adapterSendBudget?.spendEnforced || options.comboDispatchPermit || transientPolicy || resetPolicy || compactPrepaid || options.comboAttempt
|
|
530
|
-
|| billingPoolRequest || autoPauseEnabled
|
|
530
|
+
|| anthropicInstance || billingPoolRequest || autoPauseEnabled
|
|
531
531
|
? {
|
|
532
532
|
// A pending compaction permit already booked this leg's first physical send.
|
|
533
|
-
...(transientPolicy || resetPolicy || compactPrepaid || options.comboAttempt || autoPauseEnabled
|
|
533
|
+
...(transientPolicy || resetPolicy || compactPrepaid || options.comboAttempt || anthropicInstance || autoPauseEnabled
|
|
534
534
|
? {
|
|
535
535
|
attempts: Math.min(initialSendCap,
|
|
536
536
|
sendBudgetState.initialSendAllowance(initialSendCap) + (compactPrepaid ? 1 : 0)),
|
|
@@ -1387,7 +1387,7 @@ export async function prepareAdapterExchange(
|
|
|
1387
1387
|
model: route.modelId, requestKey: transportState, decision: transportState.anthropicRouteDecision, currentDecision: currentAnthropicRouteDecision, signal: upstream.signal,
|
|
1388
1388
|
// A denied reservation must not rotate on base headroom its bounds cannot see.
|
|
1389
1389
|
canRetry: hop.allowed && (hop.permit !== undefined || !sendBudgetExhausted())
|
|
1390
|
-
&& transportState.anthropicPoolFailovers <
|
|
1390
|
+
&& transportState.anthropicPoolFailovers < transportState.anthropicFailoverLimit,
|
|
1391
1391
|
});
|
|
1392
1392
|
} catch (rotationError) {
|
|
1393
1393
|
hop.permit?.release();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { currentTurnWireToolCatalogBody } from "../responses-undeclared-tool-guard";
|
|
2
2
|
import { sessionLaneIdFromRequest } from "../request-log-conversation";
|
|
3
3
|
import { codeModeRenderedToolNames } from "./code-mode-collab-surface";
|
|
4
|
+
import { CODE_MODE_EXEC_TOOL_NAME } from "../../types";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Eager MCP definitions at which a Codex request is diagnosed as carrying an expanded catalog.
|
|
@@ -21,6 +22,17 @@ const warnedSessions = new Map<string, true>();
|
|
|
21
22
|
/** Logical requests already warned without a session identity; weak so completed requests leave no trace. */
|
|
22
23
|
const warnedAnonymousRequests = new WeakSet<object>();
|
|
23
24
|
const CODEX_CLIENT_IDENTITY = /^(?:codex|codex_cli_rs|codex_app|codex_work_desktop|codexless_agent|Codex Desktop)(?:\/|$)/i;
|
|
25
|
+
// This optional diagnostic has a request-wide work/storage budget, not an admission limit.
|
|
26
|
+
const MAX_DIAGNOSTIC_ITEMS = 4_096;
|
|
27
|
+
const MAX_DIAGNOSTIC_CHARACTERS = 1 << 20;
|
|
28
|
+
interface DiagnosticBudget { items: number; characters: number }
|
|
29
|
+
|
|
30
|
+
function reserveDiagnosticBudget(budget: DiagnosticBudget, items: number, characters = 0): boolean {
|
|
31
|
+
if (items > budget.items || characters > budget.characters) return false;
|
|
32
|
+
budget.items -= items;
|
|
33
|
+
budget.characters -= characters;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
24
36
|
|
|
25
37
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
26
38
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -36,32 +48,48 @@ export function eagerCodexToolCatalogSurface(
|
|
|
36
48
|
): "responses" | "compact" {
|
|
37
49
|
if (compactionRecoveryKind === "compaction-v1") return "compact";
|
|
38
50
|
const input = isRecord(body) && Array.isArray(body.input) ? body.input : [];
|
|
51
|
+
// An oversized unknown surface is skipped by the count's input budget too.
|
|
52
|
+
if (input.length > MAX_DIAGNOSTIC_ITEMS) return "responses";
|
|
39
53
|
return input.some(item => isRecord(item) && item.type === "compaction_trigger") ? "compact" : "responses";
|
|
40
54
|
}
|
|
41
55
|
|
|
42
|
-
function collectEagerMcpTools(specs: unknown[], names: Set<string>, namespace?: string):
|
|
56
|
+
function collectEagerMcpTools(specs: unknown[], names: Set<string>, budget: DiagnosticBudget, namespace?: string): boolean {
|
|
57
|
+
if (!reserveDiagnosticBudget(budget, specs.length)) return false;
|
|
43
58
|
for (const spec of specs) {
|
|
44
59
|
if (!isRecord(spec) || spec.defer_loading === true) continue;
|
|
45
60
|
// Codex namespaces are one level deep. A namespace nested inside another is not a Codex
|
|
46
61
|
// declaration, and recursing into caller-shaped depth could exhaust the stack.
|
|
47
62
|
if (spec.type === "namespace" && typeof spec.name === "string" && Array.isArray(spec.tools)) {
|
|
48
|
-
if (namespace === undefined
|
|
63
|
+
if (namespace === undefined && !collectEagerMcpTools(spec.tools, names, budget, spec.name)) return false;
|
|
49
64
|
continue;
|
|
50
65
|
}
|
|
51
66
|
const tool = isRecord(spec.function) ? spec.function : spec;
|
|
52
67
|
if (tool.defer_loading === true || typeof tool.name !== "string") continue;
|
|
53
68
|
// `functions` is the reserved unnamespaced group (as in the undeclared-tool guard and parser),
|
|
54
69
|
// so an MCP tool declared inside it keeps its own `mcp__` name.
|
|
55
|
-
const
|
|
56
|
-
|
|
70
|
+
const prefix = namespace && namespace !== "functions" ? namespace : undefined;
|
|
71
|
+
const isMcp = prefix === undefined ? tool.name.startsWith("mcp__")
|
|
72
|
+
: prefix === "mcp" || prefix === "mcp_" || prefix.startsWith("mcp__");
|
|
73
|
+
if (isMcp) {
|
|
74
|
+
// Charge every occurrence, including duplicates, before concatenation or Set hashing.
|
|
75
|
+
const length = tool.name.length + (prefix === undefined ? 0 : prefix.length + 2);
|
|
76
|
+
if (!reserveDiagnosticBudget(budget, 0, length)) return false;
|
|
77
|
+
names.add(prefix === undefined ? tool.name : `${prefix}__${tool.name}`);
|
|
78
|
+
}
|
|
57
79
|
// Code Mode renders each enabled, non-deferred nested tool into the exec description. Codex
|
|
58
80
|
// sends exec bare or, on Responses Lite, inside its `functions` namespace.
|
|
59
|
-
if ((namespace === undefined || namespace === "functions") && spec.type === "custom"
|
|
60
|
-
|
|
81
|
+
if ((namespace === undefined || namespace === "functions") && spec.type === "custom"
|
|
82
|
+
&& tool.name === CODE_MODE_EXEC_TOOL_NAME && typeof tool.description === "string") {
|
|
83
|
+
// Reserving the complete description bounds parsing, copies and all names it can render.
|
|
84
|
+
if (!reserveDiagnosticBudget(budget, 0, tool.description.length)) return false;
|
|
85
|
+
const rendered = codeModeRenderedToolNames(tool.name, tool.description);
|
|
86
|
+
if (!reserveDiagnosticBudget(budget, rendered.length)) return false;
|
|
87
|
+
for (const nested of rendered) {
|
|
61
88
|
if (nested.startsWith("mcp__")) names.add(nested);
|
|
62
89
|
}
|
|
63
90
|
}
|
|
64
91
|
}
|
|
92
|
+
return true;
|
|
65
93
|
}
|
|
66
94
|
|
|
67
95
|
/**
|
|
@@ -86,7 +114,8 @@ function clientSentAdditionalTools(input: unknown[]): unknown[][] {
|
|
|
86
114
|
* Eager MCP definitions a canonical Codex client declared for this request, or 0 for any other
|
|
87
115
|
* client. `replayPrefixLength` is the leading input the proxy restored from stored continuation
|
|
88
116
|
* state; those items are history and grant no declaration for this turn. Compaction reads only
|
|
89
|
-
* top-level `tools`: its `input` is history.
|
|
117
|
+
* top-level `tools`: its `input` is history. Exceeding the diagnostic budget returns 0 rather
|
|
118
|
+
* than a partial count; it neither rejects nor rewrites the request.
|
|
90
119
|
*/
|
|
91
120
|
export function eagerCodexMcpToolCount(
|
|
92
121
|
body: unknown,
|
|
@@ -97,12 +126,20 @@ export function eagerCodexMcpToolCount(
|
|
|
97
126
|
if (!headers.has("x-codex-turn-metadata")
|
|
98
127
|
&& !CODEX_CLIENT_IDENTITY.test(headers.get("originator") ?? "")
|
|
99
128
|
&& !CODEX_CLIENT_IDENTITY.test(headers.get("user-agent") ?? "")) return 0;
|
|
100
|
-
|
|
129
|
+
if (!isRecord(body)) return 0;
|
|
130
|
+
const budget = { items: MAX_DIAGNOSTIC_ITEMS, characters: MAX_DIAGNOSTIC_CHARACTERS };
|
|
131
|
+
const input = surface === "responses" && Array.isArray(body.input) ? body.input : undefined;
|
|
132
|
+
if (input !== undefined && !reserveDiagnosticBudget(budget, input.length)) return 0;
|
|
133
|
+
// Bound replay scans/copies before invoking the shared helper, and never spread unrelated
|
|
134
|
+
// request fields or inspect compaction history just to compute an optional diagnostic.
|
|
135
|
+
const current = currentTurnWireToolCatalogBody({ tools: body.tools, input }, replayPrefixLength);
|
|
101
136
|
if (!isRecord(current)) return 0;
|
|
102
137
|
const names = new Set<string>();
|
|
103
|
-
if (Array.isArray(current.tools)
|
|
138
|
+
if (Array.isArray(current.tools) && !collectEagerMcpTools(current.tools, names, budget)) return 0;
|
|
104
139
|
if (surface === "responses" && Array.isArray(current.input)) {
|
|
105
|
-
for (const tools of clientSentAdditionalTools(current.input))
|
|
140
|
+
for (const tools of clientSentAdditionalTools(current.input)) {
|
|
141
|
+
if (!collectEagerMcpTools(tools, names, budget)) return 0;
|
|
142
|
+
}
|
|
106
143
|
}
|
|
107
144
|
return names.size;
|
|
108
145
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/** Process-local recall of the last completed combo response on an explicit session lane. */
|
|
2
2
|
import { getCombo, targetKey } from "../../combos/types";
|
|
3
3
|
import { captureConfigGeneration, type GenerationContext } from "../../lib/state-store-sweeper";
|
|
4
|
-
import type { OcxConfig, OcxComboTarget } from "../../types";
|
|
4
|
+
import type { OcxComboDefaultEffort, OcxConfig, OcxComboTarget } from "../../types";
|
|
5
|
+
|
|
6
|
+
/** The effort a JEV decision set for a lane's turn; `null` is its explicit no-effort choice. */
|
|
7
|
+
export interface ComboTurnEffort {
|
|
8
|
+
effort: OcxComboDefaultEffort | null;
|
|
9
|
+
}
|
|
5
10
|
|
|
6
11
|
interface ComboRecallEntry {
|
|
7
12
|
comboId: string;
|
|
@@ -10,6 +15,8 @@ interface ComboRecallEntry {
|
|
|
10
15
|
at: number;
|
|
11
16
|
/** UTF-8 size of `responseModel`, the only client-influenced field of unbounded length. */
|
|
12
17
|
bytes: number;
|
|
18
|
+
/** Present only when a JEV decision, not ordinary Combo policy, set the completed request's effort. */
|
|
19
|
+
turnEffort?: ComboTurnEffort;
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
const RECALL_CAPACITY = 256;
|
|
@@ -60,6 +67,7 @@ export function rememberComboForLane(
|
|
|
60
67
|
target: Pick<OcxComboTarget, "provider" | "model">,
|
|
61
68
|
responseModel: string,
|
|
62
69
|
writerGeneration: number,
|
|
70
|
+
turnEffort?: ComboTurnEffort,
|
|
63
71
|
): void {
|
|
64
72
|
if (!lane || !comboId || !responseModel.trim()) return;
|
|
65
73
|
// Reject even a same-named recreated owner: its previous in-flight turn is obsolete.
|
|
@@ -75,6 +83,7 @@ export function rememberComboForLane(
|
|
|
75
83
|
responseModel,
|
|
76
84
|
at: Date.now(),
|
|
77
85
|
bytes,
|
|
86
|
+
...(turnEffort ? { turnEffort: { effort: turnEffort.effort } } : {}),
|
|
78
87
|
};
|
|
79
88
|
if (liveOwners && !ownsEntry(liveOwners, entry)) return;
|
|
80
89
|
deleteEntry(lane);
|
|
@@ -135,6 +144,22 @@ export function recallComboTargetForLane(
|
|
|
135
144
|
return { provider: entry.target.provider, model: entry.target.model };
|
|
136
145
|
}
|
|
137
146
|
|
|
147
|
+
/**
|
|
148
|
+
* The effort a JEV decision set for the lane's turn, when `target` is the one that completed it.
|
|
149
|
+
* Freshness and ownership are `recallComboTargetForLane`'s job: a tool-loop pin reads this only
|
|
150
|
+
* for the target that call just returned, in the same synchronous turn.
|
|
151
|
+
*/
|
|
152
|
+
export function recallComboTurnEffortForLane(
|
|
153
|
+
lane: string | undefined,
|
|
154
|
+
comboId: string,
|
|
155
|
+
target: Pick<OcxComboTarget, "provider" | "model">,
|
|
156
|
+
): ComboTurnEffort | undefined {
|
|
157
|
+
if (!lane || !comboId) return undefined;
|
|
158
|
+
const entry = recall.get(lane);
|
|
159
|
+
if (!entry || entry.comboId !== comboId || targetKey(entry.target) !== targetKey(target)) return undefined;
|
|
160
|
+
return entry.turnEffort ? { effort: entry.turnEffort.effort } : undefined;
|
|
161
|
+
}
|
|
162
|
+
|
|
138
163
|
/**
|
|
139
164
|
* Periodic expiry. Without it a lane that is never read again and never touched by a config
|
|
140
165
|
* reconciliation holds its entry for the life of the process: the existing TTL is only
|
|
@@ -138,7 +138,8 @@ function snapshotMetadataIsSafe(snapshot: Record<string, unknown>): boolean {
|
|
|
138
138
|
if (typeof snapshot.tool_choice === "string" && !["none", "auto", "required"].includes(snapshot.tool_choice)) return false;
|
|
139
139
|
if (snapshot.tool_choice != null && typeof snapshot.tool_choice !== "string") {
|
|
140
140
|
if (!recordWithOnly(snapshot.tool_choice, ["type", "name", "namespace", "function"])
|
|
141
|
-
||
|
|
141
|
+
|| typeof snapshot.tool_choice.type !== "string"
|
|
142
|
+
|| !["function", "custom", "tool_search"].includes(snapshot.tool_choice.type)
|
|
142
143
|
|| (snapshot.tool_choice.name != null && typeof snapshot.tool_choice.name !== "string")
|
|
143
144
|
|| (snapshot.tool_choice.namespace != null && typeof snapshot.tool_choice.namespace !== "string")) return false;
|
|
144
145
|
const selected = snapshot.tool_choice.function;
|
|
@@ -160,7 +161,8 @@ function snapshotMetadataIsSafe(snapshot: Record<string, unknown>): boolean {
|
|
|
160
161
|
|| (snapshot.text.verbosity != null && typeof snapshot.text.verbosity !== "string")) return false;
|
|
161
162
|
const format = snapshot.text.format;
|
|
162
163
|
if (format != null && (!recordWithOnly(format, ["type", "name", "description", "schema", "strict"])
|
|
163
|
-
||
|
|
164
|
+
|| typeof format.type !== "string"
|
|
165
|
+
|| !["text", "json_object", "json_schema"].includes(format.type)
|
|
164
166
|
|| (format.name != null && typeof format.name !== "string")
|
|
165
167
|
|| (format.description != null && typeof format.description !== "string")
|
|
166
168
|
|| (format.schema != null && !isRecord(format.schema))
|
|
@@ -665,31 +667,38 @@ export async function preflightComboStreamResponse(
|
|
|
665
667
|
onOpaquePayload: () => { outputCommitted = true; },
|
|
666
668
|
onParsedPayload: payload => {
|
|
667
669
|
if (terminalStatus !== undefined || outputCommitted || retryableTerminalPayload) return;
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
670
|
+
try {
|
|
671
|
+
if (payload !== null && typeof payload === "object" && !Array.isArray(payload)
|
|
672
|
+
&& (payload as { type?: unknown }).type === "response.created") responseCreated = true;
|
|
673
|
+
const retryable = retryableTerminalFor(payload);
|
|
674
|
+
const matchedBareError = retryable && payload !== null && typeof payload === "object"
|
|
675
|
+
&& !Array.isArray(payload) && (payload as { type?: unknown }).type === "error";
|
|
676
|
+
// A zero-output bare error is terminal evidence. Explicit client errors stay
|
|
677
|
+
// committed; unknown and retryable upstream failures may advance the combo.
|
|
678
|
+
const heldReasoning = options?.requiredToolPrelude && requiredToolReasoningPrelude(payload);
|
|
679
|
+
if (heldReasoning) holdDeadline ??= new Promise(resolve => {
|
|
680
|
+
holdTimer = setTimeout(() => resolve("hold-expired"), COMBO_REQUIRED_TOOL_REASONING_HOLD_MS);
|
|
681
|
+
});
|
|
682
|
+
if (comboStreamPayloadCommitsOutput(payload) && !matchedBareError && !heldReasoning) outputCommitted = true;
|
|
683
|
+
if (options?.requiredToolPrelude && payload && typeof payload === "object") {
|
|
684
|
+
const event = payload as { type?: unknown; response?: { output?: unknown; error?: { code?: unknown; retryable?: unknown } } };
|
|
685
|
+
const output = event.response?.output;
|
|
686
|
+
const contractFailure = event.type === "response.failed" && event.response?.error?.code === REQUIRED_TOOL_CONTRACT_CODE
|
|
687
|
+
&& event.response.error.retryable !== false && Array.isArray(output) && output.every(item =>
|
|
688
|
+
item !== null && typeof item === "object" && !Array.isArray(item)
|
|
689
|
+
&& ["message", "reasoning"].includes((item as { type: string }).type));
|
|
690
|
+
// Other lifecycle/terminal snapshots can hide effects too. Only our checked contract
|
|
691
|
+
// failure may discard a terminal-only text snapshot that was held in its entirety.
|
|
692
|
+
if (output !== undefined && (!Array.isArray(output) || output.length > 0) && !contractFailure) outputCommitted = true;
|
|
693
|
+
}
|
|
694
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return;
|
|
695
|
+
if (retryable) retryableTerminalPayload = payload as Record<string, unknown>;
|
|
696
|
+
} catch {
|
|
697
|
+
// The generic inspector swallows observer errors. Replay requires a successful proof
|
|
698
|
+
// of no effects, so a failed classification keeps this attempt and its original bytes.
|
|
699
|
+
outputCommitted = true;
|
|
700
|
+
retryableTerminalPayload = undefined;
|
|
690
701
|
}
|
|
691
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return;
|
|
692
|
-
if (retryable) retryableTerminalPayload = payload as Record<string, unknown>;
|
|
693
702
|
},
|
|
694
703
|
onTerminal: status => { terminalStatus = status; },
|
|
695
704
|
});
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
codexAccountModelRefusalHardStopCode,
|
|
9
9
|
isMalformedResponseFormatRequest,
|
|
10
10
|
isOpenRouterOpaque400Envelope,
|
|
11
|
+
isUnofferedToolCallRefusal,
|
|
11
12
|
isProviderModerationRefusal,
|
|
12
13
|
upstreamEnvelopeRootCode,
|
|
13
14
|
type CodexAccountModelRefusal,
|
|
@@ -67,6 +68,7 @@ export async function consumeComboFailure(
|
|
|
67
68
|
let codexModelRefusal: CodexAccountModelRefusal | undefined;
|
|
68
69
|
let malformedResponseFormat: boolean | undefined;
|
|
69
70
|
let openRouterOpaque400: boolean | undefined;
|
|
71
|
+
let unofferedToolCallRefusal: boolean | undefined;
|
|
70
72
|
let providerModerationRefusal: boolean | undefined;
|
|
71
73
|
let usage: OcxUsage | undefined;
|
|
72
74
|
let upstreamCode: string | undefined;
|
|
@@ -108,6 +110,9 @@ export async function consumeComboFailure(
|
|
|
108
110
|
codexModelRefusal = codexAccountModelRefusal(response.status, body.text);
|
|
109
111
|
malformedResponseFormat = isMalformedResponseFormatRequest(response.status, body.text);
|
|
110
112
|
openRouterOpaque400 = isOpenRouterOpaque400Envelope(body.text);
|
|
113
|
+
// The intact bounded body, not the 500-char display prefix: a long refusal envelope
|
|
114
|
+
// would fail the classifier's JSON parse on truncated text and stop the combo.
|
|
115
|
+
unofferedToolCallRefusal = isUnofferedToolCallRefusal(response.status, body.text);
|
|
111
116
|
}
|
|
112
117
|
// Judged on the whole body: the classification text below is cut at 500 characters, and a
|
|
113
118
|
// hard refusal after the cut must still veto a moderation hop.
|
|
@@ -196,6 +201,7 @@ export async function consumeComboFailure(
|
|
|
196
201
|
...(codexModelRefusal !== undefined ? { codexModelRefusal } : {}),
|
|
197
202
|
...(malformedResponseFormat !== undefined ? { malformedResponseFormat } : {}),
|
|
198
203
|
...(openRouterOpaque400 !== undefined ? { openRouterOpaque400 } : {}),
|
|
204
|
+
...(unofferedToolCallRefusal !== undefined ? { unofferedToolCallRefusal } : {}),
|
|
199
205
|
...(providerModerationRefusal !== undefined ? { providerModerationRefusal } : {}),
|
|
200
206
|
...(normalizedUpstreamCode !== undefined ? { upstreamCode: normalizedUpstreamCode } : {}),
|
|
201
207
|
// A rewritten identity (policy, replay refusal) is the whole verdict; the root's own code
|
|
@@ -426,7 +426,8 @@ export async function dispatchNativeComboChild(input: {
|
|
|
426
426
|
attempt,
|
|
427
427
|
startedAt,
|
|
428
428
|
seal: label => sealRequestAttemptIdentity(attempt, childLog.provider, childLog.providerAdapter ?? attempt.adapter, label),
|
|
429
|
-
|
|
429
|
+
// A rotation inside the child seals the earlier account and moves the segment start forward.
|
|
430
|
+
finish: (status, usage) => finishRequestAttempt(attempt, status, Date.now() - (childLog.activeAttemptStartedAt ?? startedAt), usage),
|
|
430
431
|
};
|
|
431
432
|
const child = {
|
|
432
433
|
route: plan.route,
|