[codex] HTTP-first Codex upstream websocket settings (#280)

* http-first codex upstream websocket settings

* address websocket runtime review comments

---------

Co-authored-by: apple <apple@appledeMacBook-Pro.local>
This commit is contained in:
Cita
2026-03-25 21:01:01 +08:00
committed by GitHub
parent 5d2596285b
commit 7e1fb8eb1b
14 changed files with 677 additions and 86 deletions
@@ -264,6 +264,7 @@ export async function handleChatSurfaceRequest(
};
let startTime = Date.now();
const leaseResult = await acquireSurfaceChannelLease({
stickySessionKey,
selected,
});
if (leaseResult.status === 'timeout') {
@@ -789,6 +790,7 @@ export async function handleClaudeCountTokensSurfaceRequest(
const oauth = getOauthInfoFromAccount(selected.account);
const startTime = Date.now();
const leaseResult = await acquireSurfaceChannelLease({
stickySessionKey,
selected,
});
if (leaseResult.status === 'timeout') {
@@ -380,6 +380,7 @@ export async function handleOpenAiResponsesSurfaceRequest(
const startTime = Date.now();
const leaseResult = await acquireSurfaceChannelLease({
stickySessionKey,
selected,
});
if (leaseResult.status === 'timeout') {
@@ -187,13 +187,17 @@ export function clearSurfaceStickyChannel(input: {
}
export async function acquireSurfaceChannelLease(input: {
stickySessionKey?: string | null;
selected: {
channel: { id: number };
account?: { extraConfig?: string | null } | null;
};
}) {
return await proxyChannelCoordinator.acquireChannelLease({
channelId: input.selected.channel.id,
// Only session-addressable requests should consume the guarded per-channel
// lease pool. Requests without a stable downstream session key should keep
// the pre-sticky-session parallel behavior instead of contending globally.
channelId: input.stickySessionKey ? input.selected.channel.id : 0,
accountExtraConfig: input.selected.account?.extraConfig,
});
}