feat: add retry wave visibility controls

This commit is contained in:
2026-07-07 20:28:24 +08:00
parent 446a0e99a8
commit a62f2cf1b9
11 changed files with 1760 additions and 267 deletions
+24
View File
@@ -149,6 +149,10 @@ async function run() {
gatewayConfig.upstream_base_url === `http://127.0.0.1:${upstreamPort}`,
"Gateway config did not preserve original upstream_base_url",
);
assert(
gatewayConfig.reasoning_match_mode === "formula_518n_minus_2",
"Gateway config did not default reasoning_match_mode to formula_518n_minus_2",
);
assert(Array.isArray(gatewayConfig.endpoints), "Gateway config endpoints must be an array");
assert(
gatewayConfig.endpoints.includes("/responses") &&
@@ -195,6 +199,13 @@ async function run() {
});
assert(blocked516Response.status === 502, `Default 516 block did not trigger: ${blocked516Response.status}`);
const blocked2070Response = await fetch(`http://127.0.0.1:${gatewayPort}/responses`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ test_reasoning_tokens: 2070 }),
});
assert(blocked2070Response.status === 502, `Default 2070 formula block did not trigger: ${blocked2070Response.status}`);
const metricsStatusResponse = await fetch(`http://127.0.0.1:${gatewayPort}/__codex_retry_gateway/api/status`);
const metricsStatusPayload = await metricsStatusResponse.json();
assert(metricsStatusResponse.status === 200, `Status API failed after traffic: ${metricsStatusResponse.status}`);
@@ -220,6 +231,7 @@ async function run() {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
reasoning_match_mode: "manual",
reasoning_equals: [1024],
retryable_status_codes: [429, 503, 529],
retryable_error_messages: ["Selected model is at capacity. Please try a different model."],
@@ -231,10 +243,15 @@ async function run() {
const saveConfigPayload = await saveConfigResponse.json();
assert(saveConfigResponse.status === 200, `Save config API failed: ${saveConfigResponse.status}`);
assert(saveConfigPayload.config?.non_stream_status_code === 503, "Save config API did not return updated config");
assert(saveConfigPayload.config?.reasoning_match_mode === "manual", "Save config API did not return updated reasoning_match_mode");
const updatedGatewayConfig = JSON.parse(
await readFile(path.join(stateRoot, "config", "config.json"), "utf8"),
);
assert(
updatedGatewayConfig.reasoning_match_mode === "manual",
"Saved config file did not persist reasoning_match_mode",
);
assert(
JSON.stringify(updatedGatewayConfig.reasoning_equals) === JSON.stringify([1024]),
"Saved config file did not persist reasoning_equals",
@@ -261,6 +278,13 @@ async function run() {
});
assert(blockedAfterSave.status === 503, `Hot reloaded config did not take effect: ${blockedAfterSave.status}`);
const manualModePassthrough = await fetch(`http://127.0.0.1:${gatewayPort}/responses`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ test_reasoning_tokens: 2070 }),
});
assert(manualModePassthrough.status === 200, `manual 模式下 2070 不应继续被拦截: ${manualModePassthrough.status}`);
const restoreViaUiResponse = await fetch(`http://127.0.0.1:${gatewayPort}/__codex_retry_gateway/api/restore`, {
method: "POST",
headers: { "content-type": "application/json" },