Skip to content

Commit 1af83c3

Browse files
committed
docs: attach JSDoc directly to remaining diff-touched declarations
1 parent 3c19337 commit 1af83c3

6 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎src/images/loop.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,10 @@ export async function runWithImageBridge(deps: ImageBridgeDeps): Promise<Respons
434434

435435
let headerDeadline = clearableDeadline(connectTimeoutMs, signal);
436436
try {
437+
/**
438+
* Build and fetch one image-bridge iteration on the given adapter, under the iteration
439+
* header deadline. The caller owns same-target 429 replays and key rotation around it.
440+
*/
437441
const fetchOnce = async (requestAdapter: ProviderAdapter): Promise<IterationResponse> => {
438442
const request = await requestAdapter.buildRequest(iterParsed, {
439443
headers: deps.forwardHeaders ? new Headers(deps.forwardHeaders) : new Headers(),

‎src/providers/key-failover.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ function parseRetryAfterMs(value: string | null | undefined, now = Date.now()):
5959
return Math.min(Math.max(delay, 1), MAX_COOLDOWN_MS);
6060
}
6161

62+
/**
63+
* True while the given key is inside its 429 cooldown window (lazily evicting the entry once the
64+
* window expires). Used to skip keys that the upstream just rate-limited during failover.
65+
*/
6266
function isKeyInCooldown(providerName: string, keyId: string, now = Date.now()): boolean {
6367
const entry = keyCooldowns.get(cooldownKey(providerName, keyId));
6468
if (!entry) return false;

‎src/server/responses/core.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2589,13 +2589,15 @@ async function handleResponsesInner(
25892589

25902590
cancelBodyOnAbort(upstreamResponse.body, upstream.signal);
25912591

2592+
// Anthropic-only: one bounded internal continuation re-ask for clean end_turn turns that
2593+
// announced an edit without emitting a tool call.
2594+
const terminalGuardEnabled = activeAdapter.name === "anthropic" && !options.comboAttempt && !routedCompaction;
25922595
/**
25932596
* One bounded internal re-ask for Anthropic end_turn-without-tool-call turns. Replays the
25942597
* continuation on a 429 with the same-key retry budget (hoisted per request), then falls
25952598
* back to key/account failover; a failure becomes an in-stream adapter error so the client
25962599
* never sees a second hidden HTTP response or an unbounded retry loop.
25972600
*/
2598-
const terminalGuardEnabled = activeAdapter.name === "anthropic" && !options.comboAttempt && !routedCompaction;
25992601
const fetchTerminalGuardContinuation = async function* (nextParsed: OcxParsedRequest): AsyncGenerator<AdapterEvent> {
26002602
let imageTierBias = 0;
26012603
let response: Response | undefined;

‎src/types.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,10 @@ export interface RateLimitRetryPolicy {
924924
respectRetryAfter?: boolean;
925925
}
926926

927+
/**
928+
* One configured provider entry. `authMode` (default `"key"`) decides whether same-target 429
929+
* retries are allowed; OAuth/forward credentials and local runtimes are never replayed.
930+
*/
927931
export interface OcxProviderConfig {
928932
adapter: string;
929933
/** Cursor MCP compatibility bounds; positive integers when configured. */

‎src/web-search/loop.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ export async function runWithWebSearch(deps: WebSearchLoopDeps): Promise<Respons
325325
// the returned response body through AbortSignal.any().
326326
let headerDeadline = clearableDeadline(connectTimeoutMs, signal);
327327
try {
328+
/**
329+
* Build and fetch one web-search iteration on the given adapter, under the iteration
330+
* header deadline. The caller owns same-target 429 replays and key rotation around it.
331+
*/
328332
const fetchOnce = async (requestAdapter: ProviderAdapter): Promise<IterationResponse> => {
329333
const request = await requestAdapter.buildRequest(iterParsed, {
330334
headers: selectedForwardHeaders,

‎tests/usage-log.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe("usage log", () => {
6262
expect(readUsageEntries()[0]?.attempts?.[0]?.recoveryKinds).toEqual(["rate-limit-429"]);
6363
});
6464

65+
/** Build one minimal persisted-usage JSONL line for the given request id. */
6566
const persistedLine = (requestId: string) => JSON.stringify({
6667
requestId,
6768
timestamp: 1,

0 commit comments

Comments
 (0)